本文整理汇总了C#中KerbalKonstructs.StaticObjects.StaticObject.spawnObject方法的典型用法代码示例。如果您正苦于以下问题:C# StaticObject.spawnObject方法的具体用法?C# StaticObject.spawnObject怎么用?C# StaticObject.spawnObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KerbalKonstructs.StaticObjects.StaticObject
的用法示例。
在下文中一共展示了StaticObject.spawnObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: loadInstances
//.........这里部分代码省略.........
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;
}
}
if (!obj.settings.ContainsKey("LaunchPadTransform") && obj.settings.ContainsKey("LaunchSiteName"))
{
if (model.settings.Keys.Contains("DefaultLaunchPadTransform"))
{
obj.settings.Add("LaunchPadTransform", model.getSetting("DefaultLaunchPadTransform"));
}
else
{
Debug.Log("KK: Launch site is missing a transform. Defaulting to " + obj.getSetting("LaunchSiteName") + "_spawn...");
if (obj.gameObject.transform.Find(obj.getSetting("LaunchSiteName") + "_spawn") != null)
{
obj.settings.Add("LaunchPadTransform", obj.getSetting("LaunchSiteName") + "_spawn");
}
else
{
Debug.Log("KK: FAILED: " + obj.getSetting("LaunchSiteName") + "_spawn does not exist! Attempting to use any transform with _spawn in the name.");
Transform lastResort = obj.gameObject.transform.Cast<Transform>().FirstOrDefault(trans => trans.name.EndsWith("_spawn"));
if (lastResort != null)
{
Debug.Log("KK: Using " + lastResort.name + " as launchpad transform");
obj.settings.Add("LaunchPadTransform", lastResort.name);
}
else
{
Debug.Log("KK: All attempts at finding a launchpad transform have failed (╯°□°)╯︵ ┻━┻ This static isn't configured for KK properly. Tell the modder.");
}
}
}
}
staticDB.addStatic(obj);
obj.spawnObject(false, false);
if (obj.settings.ContainsKey("LaunchPadTransform") && obj.settings.ContainsKey("LaunchSiteName"))
LaunchSiteManager.createLaunchSite(obj);
}
}
示例3: 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;
}