private void OnDeserialized() { if (!this._initialized) { if (!this._gate1 || !this._gate2) { this._initialized = true; UnityEngine.Object.Destroy(base.gameObject); } else if (this._wasBuilt) { this._initialized = true; this.CreateStructure(false); FoundationArchitect.CreateWindSFX(base.transform); this._ropePool = null; } else if (this._wasPlaced) { this._initialized = true; this._gate2.SetActive(true); this.CreateStructure(false); this._ropePool = new Stack <Transform>(); base.StartCoroutine(this.OnPlaced(true)); } } }
private void OnDeserialized() { if (!this._initialized) { this._initialized = true; this._multiPointsPositions.RemoveRange(this._multiPointsPositionsCount, this._multiPointsPositions.Count - this._multiPointsPositionsCount); if (this._wasBuilt) { if (this._mode == FoundationArchitect.Modes.Auto) { this.RecalcPointsFromAutoBounds(); } this.CreateStructure(false); FoundationArchitect.CreateWindSFX(this._foundationRoot.transform); this._foundationRoot.transform.parent = base.transform; this._logPool = null; this._newPool = null; this._edgesGo = null; } else if (this._wasPlaced || this._mode == FoundationArchitect.Modes.Auto) { if (this._mode == FoundationArchitect.Modes.Auto) { this.RecalcPointsFromAutoBounds(); } this.CreateStructure(false); base.StartCoroutine(this.OnPlaced()); } } }
private void OnDeserialized() { if (!this._initialized) { this._initialized = true; if (this._wasBuilt) { this.CreateStructure(false); FoundationArchitect.CreateWindSFX(this._craneRoot.transform); this._craneRoot.transform.parent = base.transform; this._logPool = null; this._newPool = null; if (this._groundTrigger) { this._groundTrigger.position = new Vector3(this._groundTrigger.position.x, this._bottomY + 2.5f, this._groundTrigger.position.z); CapsuleCollider component = this._groundTrigger.GetComponent <CapsuleCollider>(); component.height = base.transform.position.y - this._bottomY - 4f; component.center = new Vector3(0f, component.height / 2f, 0f); } } else { this.CreateStructure(false); base.StartCoroutine(this.OnPlaced()); } } }
private IEnumerator OnPlaced() { base.enabled = false; yield return(null); Transform ghost; if (this._snappedGo.activeSelf) { ghost = this._snappedGo.transform.GetChild(0); } else { ghost = this._freeGo.transform.GetChild(0); } if (!BoltNetwork.isRunning) { if (LocalPlayer.Create.BuildingPlacer.LastHit != null && LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>()) { ghost.parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>().transform; } else if (LocalPlayer.Create.ParentEntity) { DynamicBuilding component = LocalPlayer.Create.ParentEntity.GetComponent <DynamicBuilding>(); ghost.transform.parent = ((!component || !component._parentOverride) ? LocalPlayer.Create.ParentEntity.transform : component._parentOverride); } else { ghost.parent = null; } ghost.SendMessage("OnPlaced", SendMessageOptions.DontRequireReceiver); GameObject gameObject = ghost.Find("Trigger").gameObject; gameObject.SetActive(true); if ((this._snappedGo.activeSelf && this._initializeSnapped) || (this._freeGo.activeSelf && this._initializeAirborne)) { gameObject.GetComponent <Craft_Structure>().Initialize(); } UnityEngine.Object.Destroy(base.gameObject); } else { PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer); if (LocalPlayer.Create.BuildingPlacer.LastHit != null) { placeConstruction.Parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>(); } placeConstruction.PrefabId = ghost.GetComponent <BoltEntity>().prefabId; placeConstruction.Position = ghost.position; placeConstruction.Rotation = ghost.rotation; FoundationArchitect component2 = ghost.GetComponent <FoundationArchitect>(); if (component2) { placeConstruction.AboveGround = component2._aboveGround; } placeConstruction.Send(); UnityEngine.Object.Destroy(base.gameObject, 0.05f); } yield break; }
public void Clone(FoundationArchitect other) { this._mode = other._mode; this._logPrefab = other._logPrefab; this._logRenderer = other._logRenderer; this._maxLogScale = other._maxLogScale; this._maxHeightPercentWithoutDiagonal = other._maxHeightPercentWithoutDiagonal; this._floorLayers = other._floorLayers; this._craftStructure = other._craftStructure; this._logItemId = other._logItemId; this._aboveGround = other._aboveGround; }
private void OnBuilt(GameObject built) { FoundationArchitect foundationArchitect = built.GetComponent <FoundationArchitect>(); if (!foundationArchitect) { foundationArchitect = built.AddComponent <FoundationArchitect>(); foundationArchitect.Clone(this); foundationArchitect._logPrefab = Prefabs.Instance.LogBuiltPrefab; } foundationArchitect._multiPointsPositions = this._multiPointsPositions; foundationArchitect._wasBuilt = true; foundationArchitect.OnSerializing(); foundationArchitect._aboveGround = this._aboveGround; Craft_Structure craftStructure = this._craftStructure; craftStructure.OnBuilt = (Action <GameObject>)Delegate.Remove(craftStructure.OnBuilt, new Action <GameObject>(this.OnBuilt)); }
private void OnDeserialized() { if (!this._initialized) { this._initialized = true; if (!this._anchor1) { this._anchor1 = BridgeAnchorHelper.GetAnchorFromHash(this._anchor1Hash); } if (!this._anchor2) { this._anchor2 = BridgeAnchorHelper.GetAnchorFromHash(this._anchor2Hash); } if (!this._anchor1 || !this._anchor2) { UnityEngine.Object.Destroy(base.gameObject); } else { this._anchor1._hookedInStructure = this; this._anchor2._hookedInStructure = this; if (this._wasBuilt) { this.CreateStructure(false); FoundationArchitect.CreateWindSFX(base.transform); this._logPool = null; } else if (this._wasPlaced) { this.CreateStructure(false); this._logPool = new Stack <Transform>(); base.StartCoroutine(this.OnPlaced(true)); } } } }
public Transform SpawnStructure() { Transform transform = new GameObject("StairsRoot").transform; transform.position = this.GetWorldPoint(0); Stack <Transform> stack = new Stack <Transform>(); if (this._logPool == null) { this._logPool = new Stack <Transform>(); } bool flag = true; int i = 1; int num = 1; int num2 = -1; while (i < this._multiPointsPositions.Count) { Vector3 worldPoint = this.GetWorldPoint(i); Vector3 worldPoint2 = this.GetWorldPoint(i - num); bool flag2 = worldPoint.y > worldPoint2.y; int num3 = -1; Vector3 vector; Vector3 a; if (flag2 || num2 - (i - num) == 0) { vector = worldPoint; a = worldPoint2; num2 = i; } else { vector = worldPoint2; a = worldPoint; num2 = i - num; num3 = ((i + num >= this._multiPointsPositions.Count) ? -1 : ((worldPoint.y <= this.GetWorldPoint(i + num).y) ? (i + num) : i)); } Vector3 forward = a - vector; Vector3 rhs = new Vector3(forward.x, 0f, forward.z); Vector3 vector2 = Vector3.Cross(Vector3.up, rhs); int num4 = Mathf.CeilToInt(rhs.magnitude / this._logWidth); Vector3 vector3 = rhs.normalized * this._logWidth; Quaternion rotation = Quaternion.LookRotation(vector2); bool flag3 = i + num == this._multiPointsPositions.Count; bool flag4 = flag; flag = (flag3 && rhs.magnitude < this._logLength); Transform transform2 = new GameObject("StairEdge" + i).transform; transform2.parent = transform; float d = (!flag4) ? 2.5f : 0f; float d2 = (!flag) ? 2.5f : 0.5f; Vector3 vector4 = vector; forward = a - vector3 * d - (vector4 + vector3 * d2); transform2.rotation = Quaternion.LookRotation(forward); transform2.position = vector4 + vector3 * d2; this.SpawnVerticalStilt(vector, transform2); if (!flag) { vector4 -= vector3 * 2.5f; for (int j = 0; j < 5; j++) { Debug.DrawLine(vector4 - vector2, vector4 + vector2, Color.cyan); Transform transform3 = this.NewLog(vector4, rotation); transform3.parent = transform2; stack.Push(transform3); vector4 += vector3; if (this._wasBuilt && j == 2) { transform3.rotation = rotation; transform3.tag = "UnderfootWood"; BoxCollider boxCollider = transform3.gameObject.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(this._logWidth * 5.5f, this._logHeight, this._logLength); boxCollider.center = new Vector3(-0.42f, -0.34f, 0f); transform3.gameObject.AddComponent <gridObjectBlocker>(); transform3.gameObject.AddComponent <BuildingHealthHitRelay>(); } } num4 -= 3; } if (!flag4) { num4 -= 3; } Transform transform4 = UnityEngine.Object.Instantiate <Transform>(this._stiltPrefab); transform4.parent = transform2; transform4.localPosition = new Vector3(0f, -0.75f, 0f); transform4.localEulerAngles = new Vector3(-90f, 0f, 0f); transform4.localScale = new Vector3(1f, Mathf.Abs(forward.magnitude) / 4.68f, 1f); if (!this._wasBuilt && !this._wasPlaced) { transform4.GetComponentInChildren <Renderer>().sharedMaterial = Create.CurrentGhostMat; } else { transform4.gameObject.SetActive(true); } Vector3 b = new Vector3(0f, forward.y / (float)num4, 0f); for (int k = 0; k < num4; k++) { Debug.DrawLine(vector4 - vector2, vector4 + vector2, Color.cyan); Transform transform5 = this.NewLog(vector4, rotation); transform5.parent = transform2; stack.Push(transform5); vector4 += vector3; vector4 += b; } if (num3 > i) { vector4 += vector3 * -0.65f; for (int l = 0; l < 5; l++) { Debug.DrawLine(vector4 - vector2, vector4 + vector2, Color.cyan); Transform transform6 = this.NewLog(vector4, rotation); transform6.parent = transform2; stack.Push(transform6); if (l == 2) { this.SpawnVerticalStilt(vector4, transform2); if (this._wasBuilt) { transform6.rotation = rotation; transform6.tag = "UnderfootWood"; BoxCollider boxCollider2 = transform6.gameObject.AddComponent <BoxCollider>(); boxCollider2.size = new Vector3(this._logWidth * 5.5f, this._logHeight, this._logLength); boxCollider2.center = new Vector3(-0.42f, -0.34f, 0f); transform6.gameObject.AddComponent <gridObjectBlocker>(); } } vector4 += vector3; } } if (this._wasBuilt) { BoxCollider boxCollider3 = transform2.gameObject.AddComponent <BoxCollider>(); boxCollider3.size = new Vector3(this._logLength, this._logHeight, forward.magnitude); boxCollider3.center = new Vector3(0f, -0.34f, boxCollider3.size.z / 2f); transform2.tag = "UnderfootWood"; transform2.gameObject.AddComponent <BuildingHealthHitRelay>(); transform2.gameObject.layer = 21; getStructureStrength getStructureStrength = transform2.gameObject.AddComponent <getStructureStrength>(); getStructureStrength._strength = getStructureStrength.strength.normal; getStructureStrength._type = getStructureStrength.structureType.floor; transform2.gameObject.AddComponent <gridObjectBlocker>(); FoundationArchitect.CreateWindSFX(transform4); } i += num; } if (!this._wasPlaced && !this._wasBuilt) { this._logPool = stack; } return(transform); }
private Transform SpawnStairs() { Transform transform = new GameObject("StairsRoot").transform; transform.position = this._multiPointsPositions.First <Vector3>(); Stack <Transform> stack = new Stack <Transform>(); int num; int num2; bool flag; if (this._multiPointsPositions[0].y < this._multiPointsPositions[1].y) { num = this._multiPointsPositions.Count - 2; num2 = -1; flag = false; } else { num = 1; num2 = 1; flag = true; } while (num >= 0 && num < this._multiPointsPositions.Count) { Vector3 vector = this._multiPointsPositions[num - num2]; Vector3 a = this._multiPointsPositions[num]; Vector3 vector2 = vector; Vector3 forward = a - vector; Vector3 rhs = new Vector3(forward.x, 0f, forward.z); Vector3 vector3 = Vector3.Cross(Vector3.up, rhs); int num3 = Mathf.CeilToInt(rhs.magnitude / this._logWidth); Vector3 vector4 = rhs.normalized * this._logWidth; Quaternion rotation = Quaternion.LookRotation(vector3); bool flag2 = flag && rhs.magnitude < this._logLength; flag = false; Transform transform2 = new GameObject("StairEdge" + num).transform; transform2.parent = transform; float d = (!flag2) ? 2.5f : 0.5f; forward = a - (vector2 + vector4 * d); transform2.rotation = Quaternion.LookRotation(forward); transform2.position = vector2 + vector4 * d; Vector3 pointFloorPosition = this.GetPointFloorPosition(vector2 + Vector3.down); Transform transform3 = UnityEngine.Object.Instantiate <Transform>(this._stiltPrefab, vector2, Quaternion.identity); transform3.parent = transform2; transform3.localScale = new Vector3(1f, Mathf.Abs(vector2.y - pointFloorPosition.y) / 4.5f, 1f); if (!this._wasBuilt && !this._wasPlaced) { transform3.GetComponentInChildren <Renderer>().sharedMaterial = this._logMat; } if (!flag2) { vector2 -= vector4 * 2.5f; for (int i = 0; i < 5; i++) { Debug.DrawLine(vector2 - vector3, vector2 + vector3, Color.cyan); Transform transform4 = this.NewLog(vector2, rotation); transform4.parent = transform2; stack.Push(transform4); vector2 += vector4; if (this._wasBuilt && i == 2) { transform4.rotation = rotation; transform4.tag = "UnderfootWood"; BoxCollider boxCollider = transform4.gameObject.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(this._logWidth * 5.5f, this._logHeight, this._logLength); boxCollider.center = new Vector3(-0.42f, -0.34f, 0f); transform4.gameObject.AddComponent <gridObjectBlocker>(); } } num3 -= 3; } Transform transform5 = UnityEngine.Object.Instantiate <Transform>(this._stiltPrefab); transform5.parent = transform2; transform5.localPosition = new Vector3(0f, -0.75f, 0f); transform5.localEulerAngles = new Vector3(-90f, 0f, 0f); transform5.localScale = new Vector3(1f, Mathf.Abs(forward.magnitude) / 4.68f, 1f); if (!this._wasBuilt && !this._wasPlaced) { transform5.GetComponentInChildren <Renderer>().sharedMaterial = this._logMat; } Vector3 b = new Vector3(0f, forward.y / (float)num3, 0f); for (int j = 0; j < num3; j++) { Debug.DrawLine(vector2 - vector3, vector2 + vector3, Color.cyan); Transform transform6 = this.NewLog(vector2, rotation); transform6.parent = transform2; stack.Push(transform6); vector2 += vector4; vector2 += b; } if (this._wasBuilt) { BoxCollider boxCollider2 = transform2.gameObject.AddComponent <BoxCollider>(); boxCollider2.size = new Vector3(this._logLength, this._logHeight, forward.magnitude); boxCollider2.center = new Vector3(0f, -0.34f, boxCollider2.size.z / 2f); transform2.tag = "UnderfootWood"; transform2.gameObject.AddComponent <BuildingHealthHitRelay>(); transform2.gameObject.layer = 21; getStructureStrength getStructureStrength = transform2.gameObject.AddComponent <getStructureStrength>(); getStructureStrength._strength = getStructureStrength.strength.normal; getStructureStrength._type = getStructureStrength.structureType.floor; transform2.gameObject.AddComponent <gridObjectBlocker>(); FoundationArchitect.CreateWindSFX(transform5); } num += num2; } if (!this._wasPlaced && !this._wasBuilt) { this._logPool = stack; } return(transform); }
private void OnPlaced() { base.enabled = false; Transform child; if (this._inWaterGo.activeSelf) { child = this._inWaterGo.transform.GetChild(0); } else { child = this._outWaterGo.transform.GetChild(0); } if (!BoltNetwork.isRunning) { if (LocalPlayer.Create.BuildingPlacer.LastHit != null && LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>()) { child.parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>().transform; } else if (LocalPlayer.Create.ParentEntity) { DynamicBuilding component = LocalPlayer.Create.ParentEntity.GetComponent <DynamicBuilding>(); child.transform.parent = ((!component || !component._parentOverride) ? LocalPlayer.Create.ParentEntity.transform : component._parentOverride); } else { child.parent = null; } child.SendMessage("OnPlaced", SendMessageOptions.DontRequireReceiver); GameObject gameObject = child.Find("Trigger").gameObject; gameObject.SetActive(true); if ((this._inWaterGo.activeSelf && this._initializeOutWater) || (this._outWaterGo.activeSelf && this._initializeInWater)) { gameObject.GetComponent <Craft_Structure>().Initialize(); } UnityEngine.Object.Destroy(base.gameObject); } else { CoopConstructionEx component2 = child.GetComponent <CoopConstructionEx>(); if (component2) { BoltEntity component3 = child.GetComponent <BoltEntity>(); BoltEntity boltEntity = LocalPlayer.Create.GetParentEntity(child.gameObject) ?? LocalPlayer.Create.ParentEntity; component2.SendMessage("OnSerializing"); CoopConstructionExToken coopConstructionExToken = LocalPlayer.Create.GetCoopConstructionExToken(component2, boltEntity); PlaceFoundationEx placeFoundationEx = PlaceFoundationEx.Create(GlobalTargets.OnlyServer); placeFoundationEx.Parent = boltEntity; placeFoundationEx.Position = child.transform.position; placeFoundationEx.Prefab = component3.prefabId; placeFoundationEx.Token = coopConstructionExToken; placeFoundationEx.Send(); } else { PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer); if (LocalPlayer.Create.BuildingPlacer.LastHit != null) { placeConstruction.Parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>(); } placeConstruction.PrefabId = child.GetComponent <BoltEntity>().prefabId; placeConstruction.Position = child.position; placeConstruction.Rotation = child.rotation; FoundationArchitect component4 = child.GetComponent <FoundationArchitect>(); if (component4) { placeConstruction.AboveGround = component4._aboveGround; } placeConstruction.Send(); } UnityEngine.Object.Destroy(base.gameObject, 0.05f); } }
public Transform SpawnStructure() { Transform transform = new GameObject("CoasterRoot").transform; transform.position = this.GetWorldPoint(0); Stack <Transform> stack = new Stack <Transform>(); if (this._logPool == null) { this._logPool = new Stack <Transform>(); } int i = 1; int num = 1; while (i < this._multiPointsPositions.Count) { Vector3 worldPoint = this.GetWorldPoint(i); Vector3 worldPoint2 = this.GetWorldPoint(i - num); Vector3 vector = worldPoint2; Vector3 a = worldPoint; Vector3 forward = a - vector; int num2 = Mathf.CeilToInt(forward.magnitude / this._logWidth); Vector3 b = forward.normalized * this._logWidth; Transform transform2 = new GameObject("CoasterEdge" + i).transform; transform2.parent = transform; Vector3 vector2 = vector; forward = a - vector2; transform2.rotation = Quaternion.LookRotation(forward); transform2.position = vector2; this.SpawnVerticalStilt(vector, transform2); Transform transform3 = UnityEngine.Object.Instantiate <Transform>(this._stiltPrefab); transform3.parent = transform2; transform3.localPosition = new Vector3(0f, -0.75f, 0f); transform3.localEulerAngles = new Vector3(-90f, 0f, 0f); transform3.localScale = new Vector3(1f, Mathf.Abs(forward.magnitude) / 4.68f, 1f); if (!this._wasBuilt && !this._wasPlaced) { Create.ApplyGhostMaterial(transform3, false); } else { transform3.gameObject.SetActive(true); } for (int j = 0; j < num2; j++) { Transform transform4 = this.NewLog(vector2, transform2.rotation * Quaternion.Euler(0f, 90f, 0f)); transform4.parent = transform2; stack.Push(transform4); vector2 += b; } if (this._wasBuilt) { for (int k = 0; k < this._colliderSource.Length; k++) { GameObject gameObject = new GameObject(string.Format("Collider_{0:000}", k)); gameObject.transform.parent = transform2; gameObject.transform.localPosition = this._colliderSource[k].transform.localPosition; gameObject.transform.localScale = this._colliderSource[k].transform.localScale; gameObject.transform.localRotation = this._colliderSource[k].transform.localRotation; BoxCollider boxCollider = gameObject.AddComponent <BoxCollider>(); boxCollider.sharedMaterial = this._colliderSource[k].sharedMaterial; gameObject.tag = this._colliderSource[k].gameObject.tag; gameObject.layer = this._colliderSource[k].gameObject.layer; float num3 = forward.magnitude + 0.5f; boxCollider.size = new Vector3(this._colliderSource[k].size.x, this._colliderSource[k].size.y, num3); gameObject.transform.localPosition += new Vector3(0f, 0f, num3 / 2f); } transform2.tag = "UnderfootWood"; transform2.gameObject.AddComponent <BuildingHealthHitRelay>(); transform2.gameObject.layer = 21; getStructureStrength getStructureStrength = transform2.gameObject.AddComponent <getStructureStrength>(); getStructureStrength._strength = getStructureStrength.strength.normal; getStructureStrength._type = getStructureStrength.structureType.wall; gridObjectBlocker gridObjectBlocker = transform2.gameObject.AddComponent <gridObjectBlocker>(); gridObjectBlocker.GatherChildColliders = true; FoundationArchitect.CreateWindSFX(transform3); } i += num; } if (!this._wasPlaced && !this._wasBuilt) { this._logPool = stack; } return(transform); }