本文整理汇总了C#中KerbalKonstructs.StaticObjects.StaticObject类的典型用法代码示例。如果您正苦于以下问题:C# StaticObject类的具体用法?C# StaticObject怎么用?C# StaticObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StaticObject类属于KerbalKonstructs.StaticObjects命名空间,在下文中一共展示了StaticObject类的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: 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);
}
示例3: deleteObject
public void deleteObject(StaticObject obj)
{
if (selectedObject == obj)
{
deselectObject();
}
staticDB.deleteObject(obj);
}
示例4: 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();
}
}
}
}
}
示例5: drawManager
public void drawManager(StaticObject obj)
{
KKWindow = new GUIStyle(GUI.skin.window);
KKWindow.padding = new RectOffset(3, 3, 5, 5);
if (obj != null)
{
if (selectedObject != obj)
EditorGUI.updateSelection(obj);
}
managerRect = GUI.Window(0xB00B1E2, managerRect, drawBaseManagerWindow, "", KKWindow);
}
示例6: NearestBarracks
public static StaticObject NearestBarracks(StaticObject selectedFacility, bool bUnassigned = true)
{
StaticObject soNearest = null;
float fKerbals = 0f;
foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics())
{
//if ((string)obj.model.getSetting("DefaultFacilityType") == "None") continue;
if ((string)obj.getSetting("FacilityType") != "Barracks")
{
if ((string)obj.model.getSetting("DefaultFacilityType") != "Barracks") continue;
}
if (obj.pqsCity.sphere == FlightGlobals.currentMainBody.pqsController)
{
var dist = Vector3.Distance(selectedFacility.gameObject.transform.position, obj.gameObject.transform.position);
if (dist > 5000f) continue;
}
else
continue;
if (bUnassigned)
{
fKerbals = (float)obj.getSetting("ProductionRateCurrent");
if (fKerbals < 1) continue;
else
{
soNearest = obj;
break;
}
}
else
{
if ((float)obj.getSetting("StaffCurrent") == 1) continue;
if (((float)obj.getSetting("StaffCurrent") -1) == (float)obj.getSetting("ProductionRateCurrent"))
continue;
else
{
soNearest = obj;
break;
}
}
}
return soNearest;
}
示例7: StationHasLOS
public static float StationHasLOS(StaticObject soFacility, Vessel vVessel)
{
if (vVessel == null || soFacility == null)
{
Debug.Log("KK: StationHasLOS borked");
return 0f;
}
float fHasLOS = 0f;
Vector3d FacPos = soFacility.gameObject.transform.position;
Vector3d VesselPos = vVessel.gameObject.transform.position;
Vector3d vDirection = (VesselPos - FacPos);
float fAngle = Vector3.Angle(soFacility.gameObject.transform.up, vDirection);
fHasLOS = fAngle;
return fHasLOS;
}
示例8: 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);
}
}
示例9: 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;
}
示例10: GetHangarSpace
public static string GetHangarSpace(StaticObject soHangar, int iMax = 2)
{
string sSpace = "None";
if ((string)soHangar.getSetting("InStorage") == "None")
{
sSpace = "InStorage";
if (iMax < 2) return sSpace;
}
else
if ((string)soHangar.getSetting("TargetID") == "None")
{
sSpace = "TargetID";
if (iMax == 2) return sSpace;
}
else
if ((string)soHangar.getSetting("TargetType") == "None")
sSpace = "TargetType";
return sSpace;
}
示例11: DestroyPreviewInstance
public static void DestroyPreviewInstance(StaticObject soInstance)
{
if (soInstance != null)
{
if (currPreview != null)
{
if (currPreview == soInstance)
currPreview = null;
}
KerbalKonstructs.instance.deleteObject(soInstance);
}
else
{
if (currPreview != null)
{
KerbalKonstructs.instance.deleteObject(currPreview);
currPreview = null;
}
}
}
示例12: 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();
}
}
示例13: 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)
{
//.........这里部分代码省略.........
示例14: UnassignToBarracks
public static void UnassignToBarracks(StaticObject selectedFacility)
{
selectedFacility.setSetting("ProductionRateCurrent", (float)selectedFacility.getSetting("ProductionRateCurrent") + 1);
}
示例15: TotalBarracksPool
public static float TotalBarracksPool(StaticObject selectedFacility, bool bUnassigned = true)
{
float fKerbals = 0f;
foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics())
{
//if ((string)obj.model.getSetting("DefaultFacilityType") == "None") continue;
if ((string)obj.getSetting("FacilityType") != "Barracks")
{
if ((string)obj.model.getSetting("DefaultFacilityType") != "Barracks") continue;
}
var dist = Vector3.Distance(selectedFacility.gameObject.transform.position, obj.gameObject.transform.position);
if (dist > 5000f) continue;
if (bUnassigned)
{
fKerbals = fKerbals + (float)obj.getSetting("ProductionRateCurrent");
}
else
{
fKerbals = fKerbals + ((float)obj.getSetting("StaffCurrent") - (float)obj.getSetting("ProductionRateCurrent"));
}
}
return fKerbals;
}