public override void Attached() { this.chunks = (from x in base.GetComponentsInChildren <TreeCutChunk>() orderby int.Parse(x.transform.parent.gameObject.name) select x).ToArray <TreeCutChunk>(); base.state.AddCallback("TreeId", delegate { CoopTreeId coopTreeId = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId x) => x.Id == base.state.TreeId); if (coopTreeId) { LOD_Trees component = coopTreeId.GetComponent <LOD_Trees>(); if (component) { component.enabled = false; component.DontSpawn = true; if (component.CurrentView) { component.Pool.Despawn(component.CurrentView.transform); component.CurrentView = null; component.CurrentLodTransform = null; } } } }); base.state.AddCallback("Damage", delegate { if (base.entity.isOwner && base.state.Damage == 16f) { base.entity.DestroyDelayed(10f); BoltEntity boltEntity = BoltNetwork.Instantiate(this.CoopTree.NetworkFallPrefab, base.entity.transform.position, base.entity.transform.rotation); boltEntity.GetState <ITreeFallState>().CutTree = base.entity; boltEntity.GetComponent <Rigidbody>().AddForce(new Vector3(UnityEngine.Random.value * 0.01f, 0f, UnityEngine.Random.value * 0.01f), ForceMode.VelocityChange); } }); }
public override void OnEvent(HitTree evnt) { if (!this.ValidateSender(evnt, SenderTypes.Any)) { return; } CoopTreeId coopTreeId = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId x) => x.Id == evnt.TreeId); if (coopTreeId) { TreeHealth currentView = coopTreeId.GetComponent <LOD_Trees>().CurrentView; if (currentView) { Transform transform = currentView.transform.Find(evnt.ChunkParent); if (transform) { Transform transform2 = transform.Find("TreeDmg" + evnt.ChunkParent); if (transform2) { transform2.SendMessage("ActivateFake", evnt.ChunkId); } } } } }
public override IEnumerator OnDeserialized() { if (BoltNetwork.isRunning) { while (!base.entity.isAttached) { yield return(null); } } if (!BoltNetwork.isRunning || base.entity.isAttached) { yield return(null); if (this._treeId >= 0) { CoopTreeId tid = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId i) => i.Id == this.$this._treeId); if (!tid) { yield return(YieldPresets.WaitThreeSeconds); tid = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId i) => i.Id == this.$this._treeId); } if (tid) { LOD_Trees component = tid.GetComponent <LOD_Trees>(); component.AddTreeCutDownTarget(base.gameObject); } } if (this._treeId2 >= 0) { CoopTreeId tid2 = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId i) => i.Id == this.$this._treeId2); if (!tid2) { yield return(YieldPresets.WaitThreeSeconds); tid2 = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId i) => i.Id == this.$this._treeId2); } if (tid2) { LOD_Trees component2 = tid2.GetComponent <LOD_Trees>(); component2.AddTreeCutDownTarget(base.gameObject); } } } yield break; }
private void OnDestroy() { if (this._tsl) { UnityEngine.Object.Destroy(this._tsl); this._tsl = null; } if (CoopPlayerCallbacks.AllTrees != null) { CoopTreeId coopTreeId = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId i) => i.Id == this._treeId); if (coopTreeId) { LOD_Trees component = coopTreeId.GetComponent <LOD_Trees>(); if (component) { component.RemoveTreeCutDownTarget(base.gameObject); } } } }
public virtual IEnumerator OnDeserialized() { if (BoltNetwork.isRunning) { while (!base.entity.isAttached) { yield return(null); } } if (this._treeId >= 0 && !this._tsl && (!BoltNetwork.isRunning || base.entity.isAttached)) { yield return(null); if (!this._tsl) { if (BoltNetwork.isRunning && base.entity.isAttached && base.entity.isOwner && base.entity.StateIs <ITreeHouseState>()) { base.entity.GetState <ITreeHouseState>().TreeId = this._treeId; } CoopTreeId tid = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId i) => i.Id == this.$this._treeId); if (!tid) { yield return(YieldPresets.WaitThreeSeconds); tid = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId i) => i.Id == this.$this._treeId); } if (tid && !this._tsl) { LOD_Trees component = tid.GetComponent <LOD_Trees>(); component.AddTreeCutDownTarget(base.gameObject); if (this._cutLeaves) { this._tsl = component.gameObject.AddComponent <TreeStructureLod>(); this._tsl._lod = component; } } } } yield break; }