private void SpawnGate(Vector3 p1, Vector3 p2, WallChunkArchitect.Additions addition, float height) { if (BoltNetwork.isRunning) { PlaceWallChunk placeWallChunk = PlaceWallChunk.Create(GlobalTargets.OnlyServer); CoopWallChunkToken coopWallChunkToken = new CoopWallChunkToken(); coopWallChunkToken.P1 = p1; coopWallChunkToken.P2 = p2; coopWallChunkToken.PointsPositions = null; coopWallChunkToken.Additions = addition; coopWallChunkToken.Height = height; placeWallChunk.parent = ((!base.transform.parent) ? base.transform.GetComponentInParent <BoltEntity>() : base.transform.parent.GetComponentInParent <BoltEntity>()); placeWallChunk.token = coopWallChunkToken; placeWallChunk.prefab = Prefabs.Instance.WallDefensiveGateGhostPrefab.GetComponent <BoltEntity>().prefabId; placeWallChunk.support = null; placeWallChunk.Send(); } else { WallDefensiveGateArchitect wallDefensiveGateArchitect = UnityEngine.Object.Instantiate <WallDefensiveGateArchitect>(Prefabs.Instance.WallDefensiveGateGhostPrefab, p1, Quaternion.LookRotation(p2 - p1)); wallDefensiveGateArchitect.P1 = p1; wallDefensiveGateArchitect.P2 = p2; wallDefensiveGateArchitect.Addition = addition; wallDefensiveGateArchitect.transform.parent = base.transform.parent; } }
public void Start() { WallDefensiveChunkArchitect component = base.GetComponent <WallDefensiveChunkArchitect>(); WallDefensiveGateArchitect component2 = base.GetComponent <WallDefensiveGateArchitect>(); if (component && !component2) { if (!this.CheckCombineGate()) { this.SpawnGate(component.P1, component.P2, component.Addition, component.Height); base.GetComponentInChildren <Craft_Structure>().CancelBlueprintSafe(); } } else if (component2 && component2.Addition == WallChunkArchitect.Additions.Wall) { this.ToggleBackToWall(); } }
private void ToggleBackToWall() { WallDefensiveGateArchitect component = base.GetComponent <WallDefensiveGateArchitect>(); if (component.WasBuilt) { UnityEngine.Object.Destroy(this); } else { bool is2Sided = component.Is2Sided; Vector3 vector = (!is2Sided) ? component.P2 : Vector3.Lerp(component.P1, component.P2, 0.5f); if (BoltNetwork.isRunning) { PrefabId prefabId = Prefabs.Instance.WallDefensiveChunkGhostPrefab.GetComponent <BoltEntity>().prefabId; PlaceWallChunk placeWallChunk = PlaceWallChunk.Create(GlobalTargets.OnlyServer); CoopWallChunkToken coopWallChunkToken = new CoopWallChunkToken(); coopWallChunkToken.P1 = component.P1; coopWallChunkToken.P2 = vector; coopWallChunkToken.PointsPositions = null; coopWallChunkToken.Additions = WallChunkArchitect.Additions.Wall; coopWallChunkToken.Height = component.Height; placeWallChunk.parent = ((!base.transform.parent) ? null : base.transform.parent.GetComponentInParent <BoltEntity>()); placeWallChunk.token = coopWallChunkToken; placeWallChunk.prefab = prefabId; placeWallChunk.support = null; placeWallChunk.Send(); if (is2Sided) { PlaceWallChunk placeWallChunk2 = PlaceWallChunk.Create(GlobalTargets.OnlyServer); CoopWallChunkToken coopWallChunkToken2 = new CoopWallChunkToken(); coopWallChunkToken2.P1 = vector; coopWallChunkToken2.P2 = component.P2; coopWallChunkToken2.PointsPositions = null; coopWallChunkToken2.Additions = WallChunkArchitect.Additions.Wall; coopWallChunkToken2.Height = component.Height; placeWallChunk2.parent = ((!base.transform.parent) ? null : base.transform.parent.GetComponentInParent <BoltEntity>()); placeWallChunk2.token = coopWallChunkToken2; placeWallChunk2.prefab = prefabId; placeWallChunk2.support = null; placeWallChunk2.Send(); } } else { WallChunkArchitect wallChunkArchitect = UnityEngine.Object.Instantiate <WallDefensiveChunkArchitect>(Prefabs.Instance.WallDefensiveChunkGhostPrefab); if (base.transform.parent) { wallChunkArchitect.transform.parent = base.transform.parent; } wallChunkArchitect.transform.position = component.P1; wallChunkArchitect.transform.LookAt(vector); wallChunkArchitect.MultipointPositions = null; wallChunkArchitect.P1 = component.P1; wallChunkArchitect.P2 = vector; wallChunkArchitect.CurrentSupport = component.CurrentSupport; wallChunkArchitect.Height = component.Height; if (is2Sided) { WallChunkArchitect wallChunkArchitect2 = UnityEngine.Object.Instantiate <WallDefensiveChunkArchitect>(Prefabs.Instance.WallDefensiveChunkGhostPrefab); if (base.transform.parent) { wallChunkArchitect2.transform.parent = base.transform.parent; } wallChunkArchitect2.transform.position = vector; wallChunkArchitect2.transform.LookAt(component.P2); wallChunkArchitect2.MultipointPositions = null; wallChunkArchitect2.P1 = vector; wallChunkArchitect2.P2 = component.P2; wallChunkArchitect2.CurrentSupport = component.CurrentSupport; } } base.StartCoroutine(this.DelayedCancelGhost()); } }