本文整理汇总了C#中KerbalKonstructs.StaticObjects.StaticObject.getSetting方法的典型用法代码示例。如果您正苦于以下问题:C# StaticObject.getSetting方法的具体用法?C# StaticObject.getSetting怎么用?C# StaticObject.getSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KerbalKonstructs.StaticObjects.StaticObject
的用法示例。
在下文中一共展示了StaticObject.getSetting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addStatic
public void addStatic(StaticObject obj)
{
String bodyName = ((CelestialBody) obj.getSetting("CelestialBody")).bodyName;
String groupName = (string) obj.getSetting("Group");
//Debug.Log("Creating object in group " + obj.groupName);
if (!groupList.ContainsKey(bodyName))
groupList.Add(bodyName, new Dictionary<string, StaticGroup>());
if (!groupList[bodyName].ContainsKey(groupName))
{
//StaticGroup group = new StaticGroup(bodyName, groupName);
StaticGroup group = new StaticGroup(groupName, bodyName);
//Ungrouped objects get individually cached. New acts the same as Ungrouped but stores unsaved statics instead.
if (groupName == "Ungrouped")
{
group.alwaysActive = true;
//group.active = true;
}
group.active = true;
groupList[bodyName].Add(groupName, group);
}
groupList[bodyName][groupName].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: 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);
}
示例4: 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);
}
}
示例5: 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
//.........这里部分代码省略.........
示例6: GetDistanceToGate
public float GetDistanceToGate(StaticObject soGate, Vector3 vPos)
{
float fDistance = 0f;
Vector3 vCenter = new Vector3(0, 0, 0);
StaticObject soNearestPole = null;
string sGroup = (string)soGate.getSetting("Group");
string sFacType = (string)soGate.getSetting("FacilityType");
soNearestPole = NavUtils.GetNearestFacility(soGate.gameObject.transform.position, sFacType + "P", sGroup);
vCenter = Vector3.Lerp(soGate.gameObject.transform.position, soNearestPole.gameObject.transform.position, 0.5f);
fDistance = Vector3.Distance(vCenter, vPos);
return fDistance;
}
示例7: GetGateWidth
public float GetGateWidth(StaticObject soGate)
{
float fDistance = 0f;
StaticObject soNearestPole = null;
string sGroup = (string)soGate.getSetting("Group");
string sFacType = (string)soGate.getSetting("FacilityType");
soNearestPole = NavUtils.GetNearestFacility(soGate.gameObject.transform.position, sFacType + "P", sGroup);
fDistance = Vector3.Distance(soGate.gameObject.transform.position, soNearestPole.gameObject.transform.position);
return fDistance;
}
示例8: GetNextGate
public StaticObject GetNextGate(StaticObject StartLine, float fNextGate)
{
StaticObject soNextGate = null;
string sGate = "Gate" + fNextGate.ToString();
string sGroup = (string)StartLine.getSetting("Group");
soNextGate = NavUtils.GetNearestFacility(StartLine.gameObject.transform.position, sGate, sGroup);
return soNextGate;
}
示例9: RemoveCorrectCraft
public static void RemoveCorrectCraft(Vessel vVessel, StaticObject soHangar)
{
string sSpace = "InStorage";
string sVesselID = vVessel.id.ToString();
if (sVesselID == (string)soHangar.getSetting("TargetID"))
sSpace = "TargetID";
if (sVesselID == (string)soHangar.getSetting("TargetType"))
sSpace = "TargetType";
soHangar.setSetting(sSpace, "None");
PersistenceUtils.saveStaticPersistence(soHangar);
}
示例10: DrawFromBarracks
public static void DrawFromBarracks(StaticObject selectedFacility)
{
selectedFacility.setSetting("ProductionRateCurrent", (float)selectedFacility.getSetting("ProductionRateCurrent") - 1);
}
示例11: StaffingInterface
public static void StaffingInterface(StaticObject selectedFacility)
{
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;
BoxInfo = new GUIStyle(GUI.skin.box);
BoxInfo.normal.textColor = Color.cyan;
BoxInfo.fontSize = 13;
BoxInfo.padding.top = 2;
BoxInfo.padding.bottom = 1;
BoxInfo.padding.left = 5;
BoxInfo.padding.right = 5;
BoxInfo.normal.background = null;
ButtonSmallText = new GUIStyle(GUI.skin.button);
ButtonSmallText.fontSize = 12;
ButtonSmallText.fontStyle = FontStyle.Normal;
fStaff = (float)selectedFacility.getSetting("StaffCurrent");
fMaxStaff = (float)selectedFacility.getSetting("StaffMax");
bIsBarracks = false;
if ((string)selectedFacility.getSetting("FacilityType") == "Barracks")
bIsBarracks = true;
else
if ((string)selectedFacility.model.getSetting("DefaultFacilityType") == "Barracks")
bIsBarracks = true;
if (fMaxStaff < 1)
{
fMaxStaff = (float)selectedFacility.model.getSetting("DefaultStaffMax");
if (fMaxStaff < 1)
{
selectedFacility.setSetting("StaffMax", (float)0);
//PersistenceUtils.saveStaticPersistence(selectedFacility);
}
else
{
selectedFacility.setSetting("StaffMax", (float)fMaxStaff);
PersistenceUtils.saveStaticPersistence(selectedFacility);
}
}
if (fMaxStaff > 0)
{
float fHireFundCost = 5000;
float fFireRefund = 2500;
float fFireRepCost = 1;
bIsOpen = ((string)selectedFacility.getSetting("OpenCloseState") == "Open");
if (!bIsOpen)
{
iFundsOpen2 = (float)selectedFacility.model.getSetting("cost");
if (iFundsOpen2 == 0) bIsOpen = true;
}
GUILayout.Space(5);
float CountCurrent = fStaff;
float CountEmpty = fMaxStaff - fStaff;
float funassigned = (float)selectedFacility.getSetting("ProductionRateCurrent");
scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(58));
{
GUILayout.BeginHorizontal();
{
while (CountCurrent > 0)
{
GUILayout.Box(tKerbal, GUILayout.Width(23));
CountCurrent = CountCurrent - 1;
}
while (CountEmpty > 0)
{
GUILayout.Box(tNoKerbal, GUILayout.Width(23));
CountEmpty = CountEmpty - 1;
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
GUI.enabled = bIsOpen;
if (!bIsBarracks)
{
GUILayout.Box("Assigned Staff: " + fStaff.ToString("#0") + "/" + fMaxStaff.ToString("#0"), BoxInfo);
}
if (bIsBarracks)
{
//.........这里部分代码省略.........
示例12: loadInstances
public void loadInstances(ConfigNode confconfig, StaticModel model, bool bSecondPass = false)
{
if (model == null)
{
Debug.Log("KK: Attempting to loadInstances for a null model. Check your model and config.");
return;
}
if (confconfig == null)
{
Debug.Log("KK: Attempting to loadInstances for a null ConfigNode. Check your model and config.");
return;
}
foreach (ConfigNode ins in confconfig.GetNodes("Instances"))
{
StaticObject obj = new StaticObject();
obj.model = model;
obj.gameObject = GameDatabase.Instance.GetModel(model.path + "/" + model.getSetting("mesh"));
if (obj.gameObject == null)
{
Debug.Log("KK: Could not find " + model.getSetting("mesh") + ".mu! Did the modder forget to include it or did you actually install it?");
continue;
}
// Fix colliders
if (!String.IsNullOrEmpty(model.getSetting("concaveColliders").ToString().Trim()))
{
string value = model.getSetting("concaveColliders").ToString();
string[] names = value.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
MeshCollider[] colliders = obj.gameObject.GetComponentsInChildren<MeshCollider>(true);
MeshCollider[] concave = value.ToLower() == "all" ? colliders : colliders.Where(c => names.Contains(c.name)).ToArray();
foreach (MeshCollider collider in concave)
{
if (DebugMode) Debug.Log("KK: Making collider " + collider.name + " concave.");
collider.convex = false;
}
}
obj.settings = KKAPI.loadConfig(ins, KKAPI.getInstanceSettings());
if (obj.settings == null)
{
Debug.Log("KK: Error loading instances for " + model.getSetting("mesh") + ".mu! Check your model and config.");
continue;
}
if (bSecondPass)
{
Vector3 secondInstanceKey = (Vector3)obj.getSetting("RadialPosition");
bool bSpaceOccupied = false;
foreach (StaticObject soThis in KerbalKonstructs.instance.getStaticDB().getAllStatics())
{
Vector3 firstInstanceKey = (Vector3)soThis.getSetting("RadialPosition");
if (firstInstanceKey == secondInstanceKey)
{
string sThisMesh = (string)soThis.model.getSetting("mesh");
string sThatMesh = (string)obj.model.getSetting("mesh");
if (DebugMode)
Debug.Log("KK: Custom instance has a RadialPosition that already has an instance."
+ sThisMesh + ":"
+ (string)soThis.getSetting("Group") + ":" + firstInstanceKey.ToString() + "|"
+ sThatMesh + ":"
+ (string)obj.getSetting("Group") + ":" + secondInstanceKey.ToString());
if (sThisMesh == sThatMesh)
{
float fThisOffset = (float)soThis.getSetting("RadiusOffset");
float fThatOffset = (float)obj.getSetting("RadiusOffset");
float fThisRotation = (float)soThis.getSetting("RotationAngle");
float fThatRotation = (float)obj.getSetting("RotationAngle");
if ((fThisOffset == fThatOffset) && (fThisRotation == fThatRotation))
{
bSpaceOccupied = true;
break;
}
else
{
if (DebugMode) Debug.Log("KK: Different rotation or offset. Allowing. Could be a feature of the same model such as a doorway being used. Will cause z tearing probably.");
}
}
else
{
if (DebugMode) Debug.Log("KK: Different models. Allowing. Could be a terrain foundation or integrator.");
}
}
}
if (bSpaceOccupied)
{
Debug.Log("KK: Attempted to import identical custom instance to same RadialPosition as existing instance. Skipped. Check for duplicate custom statics you have installed. Did you export the custom instances to make a pack? If not, ask the mod-makers if they are duplicating the same stuff as each other.");
continue;
}
}
//.........这里部分代码省略.........
示例13: 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);
}
}
示例14: SpinPreview
public void SpinPreview(StaticObject soObject)
{
if (soObject == null || currPreview == null) return;
float fRot = (float)soObject.getSetting("RotationAngle") + 0.1f;
if (fRot > 360) fRot -= 360;
soObject.setSetting("RotationAngle", fRot);
soObject.update();
}
示例15: updateSelection
public static void updateSelection(StaticObject obj)
{
selectedObject = obj;
xPos = ((Vector3)obj.getSetting("RadialPosition")).x.ToString();
yPos = ((Vector3)obj.getSetting("RadialPosition")).y.ToString();
zPos = ((Vector3)obj.getSetting("RadialPosition")).z.ToString();
xOri = ((Vector3)obj.getSetting("Orientation")).x.ToString();
yOri = ((Vector3)obj.getSetting("Orientation")).y.ToString();
zOri = ((Vector3)obj.getSetting("Orientation")).z.ToString();
altitude = ((float)obj.getSetting("RadiusOffset")).ToString();
rotation = ((float)obj.getSetting("RotationAngle")).ToString();
visrange = ((float)obj.getSetting("VisibilityRange")).ToString();
facType = ((string)obj.getSetting("FacilityType"));
sGroup = ((string)obj.getSetting("Group"));
selectedObject.update();
}