private void Build() { if (this._type != BuildingTypes.None) { EventRegistry.Player.Publish(TfEvent.BuiltStructure, this._type); this._type = BuildingTypes.None; } if (BoltNetwork.isClient) { if (base.enabled) { base.enabled = false; this.AllOff(false); } return; } if (!this._ghost) { this._ghost = base.transform.parent.gameObject; } GameObject gameObject; if (BoltNetwork.isServer) { if (base.entity.attachToken != null) { if (base.entity.attachToken is CoopWallChunkToken) { (base.entity.attachToken as CoopWallChunkToken).Additions = base.entity.GetComponent <WallChunkArchitect>().Addition; } gameObject = BoltNetwork.Instantiate(this.Built, base.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; } else { gameObject = BoltNetwork.Instantiate(this.Built, base.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; BoltEntity component = gameObject.GetComponent <BoltEntity>(); if (component && component.isAttached && component.StateIs <IMultiHolderState>()) { component.GetState <IMultiHolderState>().IsReal = true; } BoltEntity component2 = gameObject.GetComponent <BoltEntity>(); if (component2 && component.isAttached && component2.StateIs <IRaftState>()) { component2.GetState <IRaftState>().IsReal = true; } } } else { gameObject = UnityEngine.Object.Instantiate <GameObject>(this.Built, this._ghost.transform.position, this._ghost.transform.rotation); } TreeStructure component3 = this._ghost.GetComponent <TreeStructure>(); if (component3) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component3.TreeId; } ropeSetGroundHeight component4 = gameObject.GetComponent <ropeSetGroundHeight>(); if (component4) { gameObject.SendMessage("setGroundTriggerHeight", SendMessageOptions.DontRequireReceiver); } if (this._ghost.transform.parent != null) { gameObject.transform.parent = this._ghost.transform.parent; DynamicBuilding componentInParent = gameObject.GetComponentInParent <DynamicBuilding>(); if (componentInParent != null) { IgnoreCollisionInChildren componentInChildren = componentInParent.GetComponentInChildren <IgnoreCollisionInChildren>(); if (componentInChildren != null) { componentInChildren.startDisableChildren(); } } } this.OnBuilt(gameObject); this.OnBuilt = null; base.enabled = false; this._initialized = false; if (this._ghost) { base.StartCoroutine(this.DelayedDestroy()); } else { this.AllOff(true); } if (this._playTwinkle && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(gameObject, true); } else if (SteamDSConfig.isDedicatedServer) { FmodOneShot fmodOneShot = FmodOneShot.Create(GlobalTargets.Others, ReliabilityModes.Unreliable); fmodOneShot.EventPath = CoopAudioEventDb.FindId("event:/ui/ingame/ui_complete"); fmodOneShot.Position = gameObject.transform.position; fmodOneShot.Send(); } }
private void Build() { if (this._type != Create.BuildingTypes.None) { EventRegistry.Player.Publish(TfEvent.BuiltStructure, this._type); this._type = Create.BuildingTypes.None; } if (BoltNetwork.isClient) { if (base.enabled) { base.enabled = false; this.AllOff(); } return; } if (!this._ghost) { this._ghost = base.transform.parent.gameObject; } GameObject gameObject; if (BoltNetwork.isServer) { if (this.entity.attachToken != null) { if (this.entity.attachToken is CoopWallChunkToken) { (this.entity.attachToken as CoopWallChunkToken).Additions = this.entity.GetComponent <WallChunkArchitect>().Addition; } gameObject = BoltNetwork.Instantiate(this.Built, this.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; } else { gameObject = BoltNetwork.Instantiate(this.Built, this.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; BoltEntity component = gameObject.GetComponent <BoltEntity>(); if (component && component.isAttached && component.StateIs <IMultiHolderState>()) { component.GetState <IMultiHolderState>().IsReal = true; } BoltEntity component2 = gameObject.GetComponent <BoltEntity>(); if (component2 && component.isAttached && component2.StateIs <IRaftState>()) { component2.GetState <IRaftState>().IsReal = true; } } } else { gameObject = (GameObject)UnityEngine.Object.Instantiate(this.Built, this._ghost.transform.position, this._ghost.transform.rotation); } TreeStructure component3 = this._ghost.GetComponent <TreeStructure>(); if (component3) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component3.TreeId; } ropeSetGroundHeight component4 = gameObject.GetComponent <ropeSetGroundHeight>(); if (component4) { gameObject.SendMessage("setGroundTriggerHeight", SendMessageOptions.DontRequireReceiver); } if (this._ghost.transform.parent != null) { gameObject.transform.parent = this._ghost.transform.parent; } this.OnBuilt(gameObject); this.OnBuilt = null; base.enabled = false; this._initialized = false; if (this._ghost) { base.StartCoroutine(this.DelayedDestroy()); } else { this.AllOff(); } if (this._playTwinkle && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(gameObject, true); } }