public void AnchorDestroyed(StructureAnchor anchor) { if (base.gameObject) { UnityEngine.Object.Destroy(base.gameObject); } }
public static StructureAnchor GetAnchorFromHash(long anchorHash) { if (BridgeAnchorHelper.AnchorHashes == null) { StructureAnchor[] array = UnityEngine.Object.FindObjectsOfType <StructureAnchor>(); BridgeAnchorHelper.AnchorHashes = new Dictionary <long, StructureAnchor>(array.Length); for (int i = 0; i < array.Length; i++) { StructureAnchor structureAnchor = array[i]; BridgeAnchorHelper.AnchorHashes[structureAnchor.ToHash()] = structureAnchor; } } StructureAnchor result; if (!BridgeAnchorHelper.AnchorHashes.TryGetValue(anchorHash, out result)) { result = null; } return(result); }
public int GetAnchorIndex(StructureAnchor anchor) { return(this._anchors.IndexOf(anchor)); }
private void RevertFirstAnchorSnapping() { if (LocalPlayer.Create.BuildingPlacer) { base.GetComponent<Renderer>().material = LocalPlayer.Create.BuildingPlacer.RedMat; base.transform.parent = LocalPlayer.Create.BuildingPlacer.transform; base.transform.localPosition = this._placerOffset; base.transform.localRotation = Quaternion.identity; Scene.HudGui.LockPositionIcon.SetActive(false); if (this._tmpAnchor) { this._tmpAnchor._hookedInStructure = null; } this._tmpAnchor = null; } }
private void OnTriggerEnter(Collider other) { if (LocalPlayer.Create.BuildingPlacer && !this._wasPlaced && !this._wasBuilt) { StructureAnchor component = other.GetComponent<StructureAnchor>(); if (component && component != this._anchor1 && component != this._anchor2 && this._tmpAnchor != component && component._hookedInStructure == null && (!this._anchor1 || !this._anchor1.transform.root.Equals(other.transform.root))) { if (base.transform.parent == null) { this.RevertFirstAnchorSnapping(); } if (base.GetComponent<Renderer>()) { base.GetComponent<Renderer>().sharedMaterial = LocalPlayer.Create.BuildingPlacer.ClearMat; } this._placerOffset = base.transform.localPosition; base.transform.parent = null; base.transform.position = other.transform.position; base.transform.rotation = other.transform.rotation; Scene.HudGui.LockPositionIcon.SetActive(true); this._tmpAnchor = component; this._tmpAnchor._hookedInStructure = this; } } }
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, true); FoundationArchitect.CreateWindSFX(base.transform); this._logPool = null; } else if (this._wasPlaced) { this.CreateStructure(false, false); this._logPool = new Stack<Transform>(); base.StartCoroutine(this.OnPlaced(true)); } } } }
private void CheckUnlockAnchor() { if (TheForest.Utils.Input.GetButtonDown("AltFire")) { if (this._anchor2) { base.GetComponent<Collider>().enabled = false; base.GetComponent<Collider>().enabled = true; this._anchor2._hookedInStructure = null; this._anchor2 = null; } else if (this._anchor1) { base.GetComponent<Collider>().enabled = false; base.GetComponent<Collider>().enabled = true; base.GetComponent<Renderer>().enabled = true; base.GetComponent<Renderer>().material = LocalPlayer.Create.BuildingPlacer.RedMat; Scene.HudGui.UnlockPositionIcon.SetActive(false); this._anchor1._hookedInStructure = null; this._anchor1 = null; } } }
private void CheckLockAnchor() { if (this._tmpAnchor != null && TheForest.Utils.Input.GetButtonDown("Fire1")) { if (!this._anchor1) { this._anchor1 = this._tmpAnchor; this._anchor1._hookedInStructure = this; Scene.HudGui.UnlockPositionIcon.SetActive(true); } else if (!this._anchor2) { this._anchor2 = this._tmpAnchor; this._anchor2._hookedInStructure = this; if (BoltNetwork.isRunning) { base.transform.position = this._anchor1.transform.position; base.transform.LookAt(this._anchor2.transform.position); } if (this._bridgeRoot) { UnityEngine.Object.Destroy(this._bridgeRoot.gameObject); } this._bridgeRoot = this.CreateBridge(this._anchor1.transform.position, this._anchor2.transform.position); } Scene.HudGui.LockPositionIcon.SetActive(false); this._tmpAnchor = null; } }
void IAnchorableStructure.AnchorDestroyed(StructureAnchor anchor) { BuildingHealth component = base.GetComponent<BuildingHealth>(); if (component) { component.Collapse(anchor.transform.position); } else if (base.gameObject) { UnityEngine.Object.Destroy(base.gameObject); } }
public int GetAnchorIndex(StructureAnchor anchor) { return this._anchors.IndexOf(anchor); }
private void OnTriggerEnter(Collider other) { if (base.enabled) { StructureAnchor component = other.GetComponent<StructureAnchor>(); if (component && component != this._anchor1 && component._hookedInStructure == null) { RaycastHit raycastHit; if (!Physics.Raycast(component.transform.position + component.transform.forward, Vector3.down, out raycastHit, this._minHeight, this._floorLayers)) { base.transform.parent = null; base.transform.position = other.transform.position; base.transform.rotation = other.transform.rotation; this._anchor1 = component; } UnityEngine.Debug.Log(raycastHit); } } }
private void Update() { if (!base.transform.parent && Vector3.Distance(LocalPlayer.Create.BuildingPlacer.transform.position, base.transform.position) > 3.75f) { base.transform.parent = LocalPlayer.Create.BuildingPlacer.transform; base.transform.localPosition = Vector3.zero; base.transform.localRotation = Quaternion.identity; if (this._anchor1._hookedInStructure == this) { this._anchor1._hookedInStructure = null; } this._anchor1 = null; } bool flag = this._anchor1; if (LocalPlayer.Create.BuildingPlacer.Clear != flag || Scene.HudGui.PlaceWallIcon.activeSelf != flag) { Scene.HudGui.PlaceWallIcon.SetActive(flag); LocalPlayer.Create.BuildingPlacer.Clear = flag; } if (this._renderer) { this._renderer.sharedMaterial = ((!flag) ? LocalPlayer.Create.BuildingPlacer.RedMat : LocalPlayer.Create.BuildingPlacer.ClearMat); } }