本文整理汇总了C#中KerbalKonstructs.StaticObjects.StaticObject.setSetting方法的典型用法代码示例。如果您正苦于以下问题:C# StaticObject.setSetting方法的具体用法?C# StaticObject.setSetting怎么用?C# StaticObject.setSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KerbalKonstructs.StaticObjects.StaticObject
的用法示例。
在下文中一共展示了StaticObject.setSetting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: changeGroup
public void changeGroup(StaticObject obj, string newGroup)
{
String bodyName = ((CelestialBody)obj.getSetting("CelestialBody")).bodyName;
String groupName = (string)obj.getSetting("Group");
groupList[bodyName][groupName].removeStatic(obj);
obj.setSetting("Group", newGroup);
addStatic(obj);
}
示例2: CacheHangaredCraft
public static void CacheHangaredCraft(StaticObject obj)
{
string sInStorage = (string)obj.getSetting("InStorage");
string sInStorage2 = (string)obj.getSetting("TargetID");
string sInStorage3 = (string)obj.getSetting("TargetType");
foreach (Vessel vVesselStored in FlightGlobals.Vessels)
{
if (vVesselStored == null) continue;
if (!vVesselStored.loaded) continue;
if (vVesselStored.vesselType == VesselType.SpaceObject) continue;
if (vVesselStored.vesselType == VesselType.Debris) continue;
if (vVesselStored.vesselType == VesselType.EVA) continue;
if (vVesselStored.vesselType == VesselType.Flag) continue;
if (vVesselStored.vesselType == VesselType.Unknown) continue;
string sHangarSpace = "None";
// If a vessel is hangared
if (vVesselStored.id.ToString() == sInStorage)
sHangarSpace = "InStorage";
if (vVesselStored.id.ToString() == sInStorage2)
sHangarSpace = "TargetID";
if (vVesselStored.id.ToString() == sInStorage3)
sHangarSpace = "TargetType";
if (sHangarSpace != "None")
{
if (vVesselStored == FlightGlobals.ActiveVessel)
{
// Craft has been taken control
// Empty the hangar
obj.setSetting(sHangarSpace, "None");
PersistenceUtils.saveStaticPersistence(obj);
}
else
{
// Hide the vessel - it is in the hangar
if (vVesselStored != null)
{
foreach (Part p in vVesselStored.Parts)
{
if (p != null && p.gameObject != null)
p.gameObject.SetActive(false);
else
continue;
}
vVesselStored.MakeInactive();
vVesselStored.enabled = false;
if (vVesselStored.loaded)
vVesselStored.Unload();
}
}
}
}
}
示例3: doFuelIn
public static void doFuelIn(StaticObject selectedObject)
{
if (SelectedResource == null) return;
if (SelectedTank == null) return;
string sResource1 = getResourceAlt(selectedObject, "LiquidFuel");
string sResource2 = getResourceAlt(selectedObject, "Oxidizer");
string sResource3 = getResourceAlt(selectedObject, "Monopropellant");
if (SelectedResource.resourceName == sResource3 && !bMoFIn) return;
if (SelectedResource.resourceName == sResource1 && !bLqFIn) return;
if (SelectedResource.resourceName == sResource2 && !bOxFIn) return;
if (SelectedResource.resourceName == sResource3 && fMoFCurrent >= fMoFMax) return;
if (SelectedResource.resourceName == sResource1 && fLqFCurrent >= fLqFMax) return;
if (SelectedResource.resourceName == sResource2 && fOxFCurrent >= fOxFMax) return;
if (SelectedResource.amount <= 0) return;
float dStaticFuel;
SelectedResource.amount = SelectedResource.amount - fTransferRate;
if (SelectedResource.amount < 0) SelectedResource.amount = 0;
if (SelectedResource.resourceName == sResource3)
{
dStaticFuel = ((float)selectedObject.getSetting("MoFCurrent")) + fTransferRate;
if (dStaticFuel > fMoFMax) dStaticFuel = fMoFMax;
selectedObject.setSetting("MoFCurrent", dStaticFuel);
}
if (SelectedResource.resourceName == sResource1)
{
dStaticFuel = ((float)selectedObject.getSetting("LqFCurrent")) + fTransferRate;
if (dStaticFuel > fLqFMax) dStaticFuel = fLqFMax;
selectedObject.setSetting("LqFCurrent", dStaticFuel);
}
if (SelectedResource.resourceName == sResource2)
{
dStaticFuel = ((float)selectedObject.getSetting("OxFCurrent")) + fTransferRate;
if (dStaticFuel > fOxFMax) dStaticFuel = fOxFMax;
selectedObject.setSetting("OxFCurrent", dStaticFuel);
}
}
示例4: CreatePreviewInstance
public void CreatePreviewInstance(StaticModel model)
{
StaticObject obj = new StaticObject();
obj.gameObject = GameDatabase.Instance.GetModel(model.path + "/" + model.getSetting("mesh"));
obj.setSetting("RadiusOffset", (float)FlightGlobals.ActiveVessel.altitude);
obj.setSetting("CelestialBody", KerbalKonstructs.instance.getCurrentBody());
obj.setSetting("Group", "Ungrouped");
obj.setSetting("RadialPosition", KerbalKonstructs.instance.getCurrentBody().transform.InverseTransformPoint(FlightGlobals.ActiveVessel.transform.position));
obj.setSetting("RotationAngle", 0f);
obj.setSetting("Orientation", Vector3.up);
obj.setSetting("VisibilityRange", 25000f);
obj.model = model;
KerbalKonstructs.instance.getStaticDB().addStatic(obj);
obj.spawnObject(true, true);
// KerbalKonstructs.instance.selectObject(obj, false);
currPreview = obj;
}
示例5: CraftConstructionInterface
public static void CraftConstructionInterface(StaticObject selectedFacility)
{
DeadButton = new GUIStyle(GUI.skin.button);
DeadButton.normal.background = null;
DeadButton.hover.background = null;
DeadButton.active.background = null;
DeadButton.focused.background = null;
DeadButton.normal.textColor = Color.white;
DeadButton.hover.textColor = Color.white;
DeadButton.active.textColor = Color.white;
DeadButton.focused.textColor = Color.white;
DeadButton.fontSize = 14;
DeadButton.fontStyle = FontStyle.Bold;
DeadButtonRed = new GUIStyle(GUI.skin.button);
DeadButtonRed.normal.background = null;
DeadButtonRed.hover.background = null;
DeadButtonRed.active.background = null;
DeadButtonRed.focused.background = null;
DeadButtonRed.normal.textColor = Color.red;
DeadButtonRed.hover.textColor = Color.yellow;
DeadButtonRed.active.textColor = Color.red;
DeadButtonRed.focused.textColor = Color.red;
DeadButtonRed.fontSize = 12;
DeadButtonRed.fontStyle = FontStyle.Bold;
BoxNoBorder = new GUIStyle(GUI.skin.box);
BoxNoBorder.normal.background = null;
BoxNoBorder.normal.textColor = Color.white;
Yellowtext = new GUIStyle(GUI.skin.box);
Yellowtext.normal.textColor = Color.yellow;
Yellowtext.normal.background = null;
LabelInfo = new GUIStyle(GUI.skin.label);
LabelInfo.normal.background = null;
LabelInfo.normal.textColor = Color.white;
LabelInfo.fontSize = 13;
LabelInfo.fontStyle = FontStyle.Bold;
LabelInfo.padding.left = 3;
LabelInfo.padding.top = 0;
LabelInfo.padding.bottom = 0;
ButtonSmallText = new GUIStyle(GUI.skin.button);
ButtonSmallText.fontSize = 12;
ButtonSmallText.fontStyle = FontStyle.Normal;
string sProducing = (string)selectedFacility.getSetting("Producing");
if (sProducing == null || sProducing == "")
{
sProducing = "None";
selectedFacility.setSetting("Producing", "None");
PersistenceUtils.saveStaticPersistence(selectedFacility);
}
if (GUILayout.Button("Construct a Craft", ButtonSmallText, GUILayout.Height(20)))
{
if (sProducing != "None")
MiscUtils.HUDMessage("Only one craft can be constructed at a time.", 10,
3);
}
GUILayout.Space(3);
if (sProducing == "None")
GUILayout.Label("No craft currently under construction in this facility.", LabelInfo);
else
{
GUILayout.Label("Craft Under Construction: ", LabelInfo);
// TO DO List of craft
GUILayout.Label("Cost of Construction: X Funds / X Materials", LabelInfo);
GUILayout.Label("Total Construction Time: X hours", LabelInfo);
GUILayout.Label("Time to Completion: X hours", LabelInfo);
if (GUILayout.Button("Assign a Kerbonaut Engineer", ButtonSmallText, GUILayout.Height(20)))
{ }
}
if (GUILayout.Button("Upgrade Production", ButtonSmallText, GUILayout.Height(20)))
{ }
float fAvailableMaterials;
fAvailableMaterials = (float)selectedFacility.getSetting("PrOreCurrent");
GUILayout.Space(3);
GUILayout.Label("Available Materials (Processed Ore): " + fAvailableMaterials.ToString("#0.0"), LabelInfo);
}
示例6: DrawFromBarracks
public static void DrawFromBarracks(StaticObject selectedFacility)
{
selectedFacility.setSetting("ProductionRateCurrent", (float)selectedFacility.getSetting("ProductionRateCurrent") - 1);
}
示例7: FuelTanksInterface
//.........这里部分代码省略.........
}
if (GUILayout.Button("Max", GUILayout.Height(18)))
{
fLqFAmount = (fLqFMax - fLqFCurrent).ToString();
if ((float.Parse(fLqFAmount)) < 0f) fLqFAmount = "0.00";
PersistenceUtils.saveStaticPersistence(selectedObject);
}
float flqFPrice = 0.5f;
float fLqFCost = (float.Parse(fLqFAmount)) * flqFPrice;
GUILayout.Label("Cost: " + fLqFCost.ToString("#0") + " \\F", LabelInfo);
if (GUILayout.Button("Buy", GUILayout.Height(18)))
{
if ((float)selectedObject.getSetting("LqFCurrent") + (float.Parse(fLqFAmount)) > fLqFMax)
{
ScreenMessages.PostScreenMessage("Insufficient fuel capacity!", 10, 0);
fLqFAmount = "0.00";
}
else
{
if (MiscUtils.isCareerGame())
{
double currentfunds = Funding.Instance.Funds;
if (fLqFCost > currentfunds)
{
ScreenMessages.PostScreenMessage("Insufficient funds!", 10, 0);
}
else
{
Funding.Instance.AddFunds(-fLqFCost, TransactionReasons.Cheating);
selectedObject.setSetting("LqFCurrent", (float)selectedObject.getSetting("LqFCurrent") + (float.Parse(fLqFAmount)));
}
}
else
{
selectedObject.setSetting("LqFCurrent", (float)selectedObject.getSetting("LqFCurrent") + (float.Parse(fLqFAmount)));
}
}
PersistenceUtils.saveStaticPersistence(selectedObject);
}
if (GUILayout.Button("Done", GUILayout.Height(18)))
{
PersistenceUtils.saveStaticPersistence(selectedObject);
bOrderedLqF = false;
}
GUILayout.EndHorizontal();
}
if (fOxFMax > 0)
{
GUILayout.Label("Oxidizer", LabelInfo);
GUILayout.BeginHorizontal();
GUILayout.Label("Max ", LabelInfo);
GUI.enabled = false;
GUILayout.TextField(string.Format("{0}", fOxFMax), GUILayout.Height(18));
GUI.enabled = true;
GUILayout.Label("Current ", LabelInfo);
GUI.enabled = false;
GUILayout.TextField(fOxFCurrent.ToString("#0.00"), GUILayout.Height(18));
GUI.enabled = true;
GUILayout.EndHorizontal();
示例8: doFuelOut
public static void doFuelOut(StaticObject selectedObject)
{
if (SelectedResource == null) return;
if (SelectedTank == null) return;
if (SelectedResource.resourceName == "MonoPropellant" && !bMoFOut) return;
if (SelectedResource.resourceName == "LiquidFuel" && !bLqFOut) return;
if (SelectedResource.resourceName == "Oxidizer" && !bOxFOut) return;
if (SelectedResource.resourceName == "MonoPropellant" && fMoFCurrent <= 0) return;
if (SelectedResource.resourceName == "LiquidFuel" && fLqFCurrent <= 0) return;
if (SelectedResource.resourceName == "Oxidizer" && fOxFCurrent <= 0) return;
if (SelectedResource.amount >= SelectedResource.maxAmount) return;
float dStaticFuel;
SelectedResource.amount = SelectedResource.amount + fTransferRate;
if (SelectedResource.amount > SelectedResource.maxAmount) SelectedResource.amount = SelectedResource.maxAmount;
if (SelectedResource.resourceName == "MonoPropellant")
{
dStaticFuel = ((float)selectedObject.getSetting("MoFCurrent")) - fTransferRate;
if (dStaticFuel < 0) dStaticFuel = 0;
selectedObject.setSetting("MoFCurrent", dStaticFuel);
}
if (SelectedResource.resourceName == "LiquidFuel")
{
dStaticFuel = ((float)selectedObject.getSetting("LqFCurrent")) - fTransferRate;
if (dStaticFuel < 0) dStaticFuel = 0;
selectedObject.setSetting("LqFCurrent", dStaticFuel);
}
if (SelectedResource.resourceName == "Oxidizer")
{
dStaticFuel = ((float)selectedObject.getSetting("OxFCurrent")) - fTransferRate;
if (dStaticFuel < 0) dStaticFuel = 0;
selectedObject.setSetting("OxFCurrent", dStaticFuel);
}
}
示例9: loadStaticPersistence
void loadStaticPersistence(StaticObject obj)
{
// Debug.Log("KK: loadStaticPersistence");
var FacilityKey = obj.getSetting("RadialPosition");
// Debug.Log("KK: FacilityKey is " + FacilityKey.ToString());
string saveConfigPath = string.Format("{0}saves/{1}/KKFacilities.cfg", KSPUtil.ApplicationRootPath, HighLogic.SaveFolder);
ConfigNode rootNode = new ConfigNode();
if (!File.Exists(saveConfigPath))
{
ConfigNode GameNode = rootNode.AddNode("GAME");
ConfigNode ScenarioNode = GameNode.AddNode("SCENARIO");
ScenarioNode.AddValue("Name", "KKStatics");
rootNode.Save(saveConfigPath);
}
rootNode = ConfigNode.Load(saveConfigPath);
ConfigNode rootrootNode = rootNode.GetNode("GAME");
Boolean bMatch = false;
foreach (ConfigNode ins in rootrootNode.GetNodes("SCENARIO"))
{
if (ins.GetValue("Name") == "KKStatics")
{
// Debug.Log("KK: Found SCENARIO named KKStatics");
foreach (ConfigNode insins in ins.GetNodes("KKStatic"))
{
// Debug.Log("KK: Found a KKStatic");
string sRadPos = insins.GetValue("RadialPosition");
if (sRadPos == FacilityKey.ToString())
{
// Debug.Log("KK: Got a KKStatic key match");
obj.setSetting("LqFCurrent", float.Parse(insins.GetValue("LqFCurrent")));
obj.setSetting("OxFCurrent", float.Parse(insins.GetValue("OxFCurrent")));
obj.setSetting("MoFCurrent", float.Parse(insins.GetValue("MoFCurrent")));
bMatch = true;
break;
}
// else
// Debug.Log("KK: No KKStatic key match");
}
break;
}
}
if (!bMatch)
{
// Debug.Log("KK: KKStatic not yet persistent for this save. Initialising KKStatic");
obj.setSetting("LqFCurrent", 0.00f);
obj.setSetting("OxFCurrent", 0.00f);
obj.setSetting("MoFCurrent", 0.00f);
saveStaticPersistence(obj);
}
}
示例10: createLaunchSite
// Add a launchsite to the KK launchsite and custom space centre database
// Please note there's some near hackery here to get KSP to recognise additional launchsites and space centres
public static void createLaunchSite(StaticObject obj)
{
if (obj.settings.ContainsKey("LaunchSiteName") && obj.gameObject.transform.Find((string) obj.getSetting("LaunchPadTransform")) != null)
{
obj.gameObject.transform.name = (string) obj.getSetting("LaunchSiteName");
obj.gameObject.name = (string) obj.getSetting("LaunchSiteName");
CelestialBody CelBody = (CelestialBody)obj.getSetting("CelestialBody");
var objectpos = CelBody.transform.InverseTransformPoint(obj.gameObject.transform.position);
var dObjectLat = NavUtils.GetLatitude(objectpos);
var dObjectLon = NavUtils.GetLongitude(objectpos);
var disObjectLat = dObjectLat * 180 / Math.PI;
var disObjectLon = dObjectLon * 180 / Math.PI;
if (disObjectLon < 0) disObjectLon = disObjectLon + 360;
obj.setSetting("RefLatitude", (float)disObjectLat);
obj.setSetting("RefLongitude", (float)disObjectLon);
foreach (FieldInfo fi in PSystemSetup.Instance.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
{
if (fi.FieldType.Name == "SpaceCenterFacility[]")
{
PSystemSetup.SpaceCenterFacility[] facilities = (PSystemSetup.SpaceCenterFacility[])fi.GetValue(PSystemSetup.Instance);
if (PSystemSetup.Instance.GetSpaceCenterFacility((string) obj.getSetting("LaunchSiteName")) == null)
{
PSystemSetup.SpaceCenterFacility newFacility = new PSystemSetup.SpaceCenterFacility();
newFacility.name = "FacilityName";
newFacility.facilityName = (string) obj.getSetting("LaunchSiteName");
newFacility.facilityPQS = ((CelestialBody) obj.getSetting("CelestialBody")).pqsController;
newFacility.facilityTransformName = obj.gameObject.name;
newFacility.pqsName = ((CelestialBody) obj.getSetting("CelestialBody")).pqsController.name;
PSystemSetup.SpaceCenterFacility.SpawnPoint spawnPoint = new PSystemSetup.SpaceCenterFacility.SpawnPoint();
spawnPoint.name = (string) obj.getSetting("LaunchSiteName");
spawnPoint.spawnTransformURL = (string) obj.getSetting("LaunchPadTransform");
newFacility.spawnPoints = new PSystemSetup.SpaceCenterFacility.SpawnPoint[1];
newFacility.spawnPoints[0] = spawnPoint;
PSystemSetup.SpaceCenterFacility[] newFacilities = new PSystemSetup.SpaceCenterFacility[facilities.Length + 1];
for (int i = 0; i < facilities.Length; ++i)
{
newFacilities[i] = facilities[i];
}
newFacilities[newFacilities.Length - 1] = newFacility;
fi.SetValue(PSystemSetup.Instance, newFacilities);
facilities = newFacilities;
Texture logo = null;
Texture icon = null;
if (obj.settings.ContainsKey("LaunchSiteLogo"))
{
string sLogoPath = (string)obj.getSetting("LaunchSiteLogo");
logo = GameDatabase.Instance.GetTexture(sLogoPath, false);
if (logo == null)
logo = GameDatabase.Instance.GetTexture(obj.model.path + "/" + obj.getSetting("LaunchSiteLogo"), false);
}
if (logo == null)
logo = defaultLaunchSiteLogo;
if(obj.settings.ContainsKey("LaunchSiteIcon"))
{
string sIconPath = (string)obj.getSetting("LaunchSiteIcon");
icon = GameDatabase.Instance.GetTexture(sIconPath, false);
if (icon == null)
icon = GameDatabase.Instance.GetTexture(obj.model.path + "/" + obj.getSetting("LaunchSiteIcon"), false);
}
// TODO This is still hard-code and needs to use an API properly
launchSites.Add(new LaunchSite(
(string)obj.getSetting("LaunchSiteName"),
(obj.settings.ContainsKey("LaunchSiteAuthor")) ? (string)obj.getSetting("LaunchSiteAuthor") : (string)obj.model.getSetting("author"),
(SiteType)obj.getSetting("LaunchSiteType"),
logo,
icon,
(string)obj.getSetting("LaunchSiteDescription"),
(string)obj.getSetting("Category"),
(float)obj.getSetting("OpenCost"),
(float)obj.getSetting("CloseValue"),
"Closed",
(float)obj.getSetting("RefLongitude"),
(float)obj.getSetting("RefLatitude"),
(float)obj.getSetting("RadiusOffset"),
(obj.settings.ContainsKey("LaunchSiteLength")) ?
(float)obj.getSetting("LaunchSiteLength") : (float)obj.model.getSetting("DefaultLaunchSiteLength"),
(obj.settings.ContainsKey("LaunchSiteWidth")) ?
(float)obj.getSetting("LaunchSiteWidth") : (float)obj.model.getSetting("DefaultLaunchSiteWidth"),
(float)obj.getSetting("LaunchRefund"),
(float)obj.getSetting("RecoveryFactor"),
(float)obj.getSetting("RecoveryRange"),
obj.gameObject,
newFacility,
"No log",
(string)obj.getSetting("LaunchSiteNation")
));
}
else
//.........这里部分代码省略.........
示例11: HangarCraft
public static void HangarCraft(Vessel vVessel, StaticObject soHangar, int iMax = 2)
{
string sSpace = GetHangarSpace(soHangar, iMax);
if (sSpace == "None")
{
MiscUtils.HUDMessage("This facility is full.", 10,
3);
}
else
{
string sVesselID = vVessel.id.ToString();
soHangar.setSetting(sSpace, sVesselID);
PersistenceUtils.saveStaticPersistence(soHangar);
// Hangar the vessel - hide it
foreach (Part p in vVessel.Parts)
{
if (p != null && p.gameObject != null)
p.gameObject.SetActive(false);
else
continue;
}
vVessel.MakeInactive();
vVessel.enabled = false;
vVessel.Unload();
}
}
示例12: spawnInstance
public StaticObject spawnInstance(StaticModel model, float fOffset, Vector3 vPosition, float fAngle)
{
StaticObject obj = new StaticObject();
obj.gameObject = GameDatabase.Instance.GetModel(model.path + "/" + model.getSetting("mesh"));
obj.setSetting("RadiusOffset", fOffset);
obj.setSetting("CelestialBody", KerbalKonstructs.instance.getCurrentBody());
obj.setSetting("Group", "Ungrouped");
obj.setSetting("RadialPosition", vPosition);
obj.setSetting("RotationAngle", fAngle);
obj.setSetting("Orientation", Vector3.up);
obj.setSetting("VisibilityRange", 25000f);
obj.model = model;
KerbalKonstructs.instance.getStaticDB().addStatic(obj);
enableColliders = false;
KerbalKonstructs.instance.spawnObject(obj, true);
return obj;
}
示例13: UnassignToBarracks
public static void UnassignToBarracks(StaticObject selectedFacility)
{
selectedFacility.setSetting("ProductionRateCurrent", (float)selectedFacility.getSetting("ProductionRateCurrent") + 1);
}
示例14: loadStaticPersistence
public static void loadStaticPersistence(StaticObject obj)
{
// Debug.Log("KK: loadStaticPersistence");
var FacilityKey = obj.getSetting("RadialPosition");
// Debug.Log("KK: FacilityKey is " + FacilityKey.ToString());
string saveConfigPath = string.Format("{0}saves/{1}/KKFacilities.cfg", KSPUtil.ApplicationRootPath, HighLogic.SaveFolder);
ConfigNode rootNode = new ConfigNode();
if (!File.Exists(saveConfigPath))
{
ConfigNode GameNode = rootNode.AddNode("GAME");
ConfigNode ScenarioNode = GameNode.AddNode("SCENARIO");
ScenarioNode.AddValue("Name", "KKStatics");
rootNode.Save(saveConfigPath);
}
rootNode = ConfigNode.Load(saveConfigPath);
ConfigNode rootrootNode = rootNode.GetNode("GAME");
Boolean bMatch = false;
foreach (ConfigNode ins in rootrootNode.GetNodes("SCENARIO"))
{
if (ins.GetValue("Name") == "KKStatics")
{
// Debug.Log("KK: Found SCENARIO named KKStatics");
foreach (ConfigNode insins in ins.GetNodes("KKStatic"))
{
// Debug.Log("KK: Found a KKStatic");
string sRadPos = insins.GetValue("RadialPosition");
if (sRadPos == FacilityKey.ToString())
{
foreach (string sAtt in pStringAttributes)
{
if (insins.GetValue(sAtt) != null)
obj.setSetting(sAtt, insins.GetValue(sAtt));
}
foreach (string sAtt2 in pFloatAttributes)
{
if (insins.GetValue(sAtt2) != null)
obj.setSetting(sAtt2, float.Parse(insins.GetValue(sAtt2)));
}
// Debug.Log("KK: Got a KKStatic key match");
bMatch = true;
break;
}
}
break;
}
}
if (!bMatch)
{
// Debug.Log("KK: KKStatic not yet persistent for this save. Initialising KKStatic");
// Model defaults initialisation
foreach (string sAtt5 in pDefaultAttributes)
{
string sDefault = "Default" + sAtt5;
if (obj.model.getSetting(sDefault) == null) continue;
obj.setSetting(sAtt5, obj.model.getSetting(sDefault));
}
foreach (string sAtt3 in pStringAttributes)
{
if (obj.getSetting(sAtt3) == null)
obj.setSetting(sAtt3, "None");
}
foreach (string sAtt4 in pFloatAttributes)
{
if (obj.getSetting(sAtt4) == null)
obj.setSetting(sAtt4, 0f);
}
// Fixed intialisation
obj.setSetting("StaffCurrent", 1f);
obj.setSetting("TargetID", "None");
obj.setSetting("OpenCloseState", "Closed");
saveStaticPersistence(obj);
}
}
示例15: spawnInstance
public StaticObject spawnInstance(StaticModel model)
{
StaticObject obj = new StaticObject();
obj.gameObject = GameDatabase.Instance.GetModel(model.path + "/" + model.getSetting("mesh"));
obj.setSetting("RadiusOffset", (float)FlightGlobals.ActiveVessel.altitude);
obj.setSetting("CelestialBody", KerbalKonstructs.instance.getCurrentBody());
obj.setSetting("Group", "Ungrouped");
obj.setSetting("RadialPosition", KerbalKonstructs.instance.getCurrentBody().transform.InverseTransformPoint(FlightGlobals.ActiveVessel.transform.position));
obj.setSetting("RotationAngle", 0f);
obj.setSetting("Orientation", Vector3.up);
obj.setSetting("VisibilityRange", 25000f);
string sPad = ((string)model.getSetting("DefaultLaunchPadTransform"));
if (sPad != null) obj.setSetting("LaunchPadTransform", sPad);
if (!KerbalKonstructs.instance.DevMode)
{
obj.setSetting("CustomInstance", "True");
}
obj.model = model;
KerbalKonstructs.instance.getStaticDB().addStatic(obj);
enableColliders = false;
obj.spawnObject(true, false);
return obj;
}