public static void AttachTrees() { if (BoltNetwork.isServer && CoopTreeGrid.AttachQueue != null) { int count = CoopTreeGrid.AttachQueue.Count; for (int i = 0; i < 100; i++) { if (CoopTreeGrid.AttachQueue.Count <= 0) { break; } BoltEntity boltEntity = CoopTreeGrid.AttachQueue.Dequeue(); if (!boltEntity.IsAttached()) { BoltNetwork.Attach(boltEntity.gameObject); boltEntity.Freeze(true); } else { i--; } } if (count > 0 && CoopTreeGrid.AttachQueue.Count == 0 && !CoopTreeGrid.AttachRoutineDone) { CoopTreeGrid.AttachRoutineDone = true; Scene.ActiveMB.StartCoroutine(CoopTreeGrid.AttacheRoutine()); } } }
private void Explosion(float dist) { if (!this.Exploded) { if (BoltNetwork.isRunning) { if (this.LodTree) { BoltEntity component = this.LodTree.GetComponent <BoltEntity>(); if (component.isAttached) { this.Exploded = true; if (component.isOwner) { if (component.canFreeze) { component.Freeze(false); } ITreeCutState state = component.GetState <ITreeCutState>(); if (state.State == 0) { state.State = 1; } state.Damage = 16; } else { DestroyTree destroyTree = DestroyTree.Create(GlobalTargets.OnlyServer); destroyTree.Tree = component; destroyTree.Send(); } } } } else { this.Exploded = true; if (this.SpawnedCutTree) { this.DoFallTreeExplosion(); } else { this.CutDownExplosion(); } } } }
public void UpdateNetworkIngredients() { if (BoltNetwork.isRunning) { BoltEntity componentInParent = base.GetComponentInParent <BoltEntity>(); if (componentInParent.isOwner && this._presentIngredients != null) { IConstructionState state = componentInParent.GetState <IConstructionState>(); for (int i = 0; i < this._presentIngredients.Length; i++) { state.Ingredients[i].Count = 0; state.Ingredients[i].Count = this._presentIngredients[i]._amount; } } componentInParent.Freeze(false); } }
public override void OnEvent(DestroyTree evnt) { BoltEntity tree = evnt.Tree; if (tree && tree.isAttached) { if (tree.canFreeze) { tree.Freeze(false); } ITreeCutState state = tree.GetState <ITreeCutState>(); if (state.State == 0) { state.State = 1; } state.Damage = 16; } }
private void InitAnim() { this.pickup = true; base.GetComponent <Collider>().enabled = false; if (!this.girlAnimator) { GameObject endgameBoss = Scene.SceneTracker.EndgameBoss; if (endgameBoss) { this.girlAnimator = endgameBoss.GetComponentInChildren <Animator>(); } } if (BoltNetwork.isRunning) { BoltEntity component = this.girlAnimator.transform.root.GetComponent <BoltEntity>(); if (component && component.isAttached) { component.Freeze(false); } } LocalPlayer.SpecialActions.SendMessage("setGirlAnimator", this.girlAnimator); LocalPlayer.SpecialActions.SendMessage("doGirlTransformRoutine", this.markTr); LocalPlayer.SpecialActions.SendMessage("setCurrentSequence", this.sequence); }
internal static void AttachTrees() { if (BoltNetwork.isServer && CoopTreeGrid.AttachQueue != null) { int count = CoopTreeGrid.AttachQueue.Count; for (int i = 0; i < 10; i++) { if (CoopTreeGrid.AttachQueue.Count <= 0) { break; } BoltEntity boltEntity = CoopTreeGrid.AttachQueue.Dequeue(); if (!boltEntity.IsAttached()) { BoltNetwork.Attach(boltEntity.gameObject); boltEntity.Freeze(true); } else { i--; } } if (count > 0 && CoopTreeGrid.AttachQueue.Count == 0) { BoltEntity[] array = UnityEngine.Object.FindObjectsOfType <BoltEntity>(); for (int j = 0; j < array.Length; j++) { BoltEntity entity = array[j]; if (!entity.IsAttached()) { BoltNetwork.Attach(entity); } } } } }
public static void AttachAdjacent(List <GameObject> positions) { if (CoopTreeGrid.Nodes == null) { return; } for (int i = 0; i < CoopTreeGrid.Nodes.Length; i++) { CoopTreeGrid.Nodes[i].NewHasPlayer = 0; } for (int j = 0; j < positions.Count; j++) { Vector3 position = positions[j].transform.position; int num = Mathf.Clamp(2048 + (int)position.x, 0, 4096); int num2 = Mathf.Clamp(2048 + (int)position.z, 0, 4096); int num3 = Mathf.Clamp(num / 64, 0, 63); int num4 = Mathf.Clamp(num2 / 64, 0, 63); for (int k = -2; k < 3; k++) { for (int l = -2; l < 3; l++) { int num5 = num4 + k; int num6 = num3 + l; if (num5 >= 0 && num5 < 64 && num6 >= 0 && num6 < 64) { CoopTreeGrid.Node[] nodes = CoopTreeGrid.Nodes; int num7 = num5 * 64 + num6; nodes[num7].NewHasPlayer = nodes[num7].NewHasPlayer + 1; } } } } for (int m = 0; m < CoopTreeGrid.Nodes.Length; m++) { CoopTreeGrid.Node node = CoopTreeGrid.Nodes[m]; bool flag = node.NewHasPlayer == 0; bool flag2 = CoopTreeGrid.NodeToSweepIndex(m) == CoopTreeGrid.SweepNodeIndex; if (node.NewHasPlayer > node.OldHasPlayer || (node.NewHasPlayer == 0 && node.NewHasPlayer != node.OldHasPlayer) || flag2) { if (flag && flag2) { flag = false; CoopTreeGrid.Nodes[m].NewHasPlayer = -1; } if (node.Trees != null) { for (int n = 0; n < node.Trees.Count; n++) { BoltEntity boltEntity = node.Trees[n]; if (boltEntity) { if (boltEntity.isAttached) { boltEntity.Freeze(flag); } } else { node.Trees.RemoveAt(n); n--; } } } if (node.Objects != null) { for (int num8 = 0; num8 < node.Objects.Count; num8++) { CoopGridObject coopGridObject = node.Objects[num8]; if (coopGridObject && coopGridObject.entity) { if (coopGridObject.entity.isAttached) { coopGridObject.entity.Freeze(flag); } } else { node.Objects.RemoveAt(num8); num8--; } } } } CoopTreeGrid.Nodes[m].OldHasPlayer = CoopTreeGrid.Nodes[m].NewHasPlayer; } int num9 = CoopTreeGrid.SweepToNodeIndex(CoopTreeGrid.SweepNodeIndex); if (num9 < CoopTreeGrid.Nodes.Length) { CoopTreeGrid.SweepNodeIndex++; } else if (num9 == CoopTreeGrid.Nodes.Length + 4) { CoopTreeGrid.SweepNodeIndex++; Debug.Log("Finished tree grid sweep"); } }
internal static void AttachAdjacent(List <GameObject> positions) { if (CoopTreeGrid.Nodes == null) { return; } for (int i = 0; i < CoopTreeGrid.Nodes.Length; i++) { CoopTreeGrid.Nodes[i].NewHasPlayer = 0; } for (int j = 0; j < positions.Count; j++) { Vector3 position = positions[j].transform.position; int num = Mathf.Clamp(2048 + (int)position.x, 0, 4096); int num2 = Mathf.Clamp(2048 + (int)position.z, 0, 4096); int num3 = Mathf.Clamp(num / 64, 0, 63); int num4 = Mathf.Clamp(num2 / 64, 0, 63); for (int k = -2; k < 3; k++) { for (int l = -2; l < 3; l++) { int num5 = num4 + k; int num6 = num3 + l; if (num5 >= 0 && num5 < 64 && num6 >= 0 && num6 < 64) { CoopTreeGrid.Node[] expr_F3_cp_0 = CoopTreeGrid.Nodes; int expr_F3_cp_1 = num5 * 64 + num6; expr_F3_cp_0[expr_F3_cp_1].NewHasPlayer = expr_F3_cp_0[expr_F3_cp_1].NewHasPlayer + 1; } } } } for (int m = 0; m < CoopTreeGrid.Nodes.Length; m++) { CoopTreeGrid.Node node = CoopTreeGrid.Nodes[m]; if (node.NewHasPlayer > node.OldHasPlayer || (node.NewHasPlayer == 0 && node.NewHasPlayer != node.OldHasPlayer)) { if (node.Trees != null) { for (int n = 0; n < node.Trees.Count; n++) { BoltEntity boltEntity = node.Trees[n]; if (boltEntity) { if (boltEntity.isAttached) { boltEntity.Freeze(node.NewHasPlayer == 0); } } else { node.Trees.RemoveAt(n); n--; } } } if (node.Objects != null) { for (int num7 = 0; num7 < node.Objects.Count; num7++) { CoopGridObject coopGridObject = node.Objects[num7]; if (coopGridObject) { if (coopGridObject.entity && coopGridObject.entity.isAttached) { coopGridObject.entity.Freeze(node.NewHasPlayer == 0); } } else { node.Objects.RemoveAt(num7); num7--; } } } } CoopTreeGrid.Nodes[m].OldHasPlayer = CoopTreeGrid.Nodes[m].NewHasPlayer; } }