public void SetCraftInputEnabled(bool enabled) { if (PlayerCraft && PlayerCraft.GetComponentInChildren <BalancerPlayerInput>()) { PlayerCraft.SetBalancerInputActive(enabled); } }
public static MultipartPhysBody SpawnCraftFromBlueprint(CraftBlueprint bp, Vector3 position, Vector3 rotation) { //Set up transform structure before adding any parts etc. Transform t = new GameObject(bp.craftName).transform; //Main craft t.position = position; t.eulerAngles = rotation; t.SetParent(GameplayManager.GameplayTransform); Transform body = new GameObject("Body").transform; //Body (part holder) body.SetParent(t); body.localPosition = body.localEulerAngles = Vector3.zero; //Set up components t.gameObject.AddComponent <Rigidbody>(); MultipartPhysBody craft = t.gameObject.AddComponent <MultipartPhysBody>(); //Set up parts List <PhysPart> spawnedParts = new List <PhysPart>(); foreach (PartBlueprint p in bp.parts) { PhysPart part = p.SpawnPart(body); spawnedParts.Add(part); } //Set up part connections foreach (ConnectionBlueprint c in bp.connections) { spawnedParts[c.fromIndex].connections.Add(new PartConnection(spawnedParts[c.toIndex], spawnedParts[c.fromIndex])); } //Disable input until it gets overriden by a system which is responsible for this (player spawning, AI spawning, etc.) craft.SetBalancerInputActive(false); return(craft); }