public void Update() { if (!Menu.InstantDestory || !LocalPlayer.IsInWorld || !TheForest.Utils.Input.GetKey(KeyCode.X)) { return; } foreach (RaycastHit hit in Physics.RaycastAll(LocalPlayer.Transform.position, LocalPlayer.Transform.TransformDirection(Vector3.forward), Menu.CutTreeDistance)) { if (hit.collider.GetComponent <BuildingHealthChunkHitRelay>() != null || hit.collider.GetComponent <BuildingHealthHitRelay>() != null || hit.collider.GetComponent <FoundationChunkTier>() != null) { hit.collider.gameObject.SendMessage("LocalizedHit", new LocalizedHitData( hit.collider.gameObject.transform.position, 999f )); break; } } if (BoltNetwork.isRunning) { foreach (BoltEntity entity in BoltNetwork.entities.Where(entity => entity.isAttached)) { try { if (entity.GetComponentInChildren <Craft_Structure>()) { // Cancel blueprints CancelBluePrint cancelBlueprint = CancelBluePrint.Create(GlobalTargets.OnlyServer); cancelBlueprint.BluePrint = entity; //PacketQueue.Add(cancelBlueprint); cancelBlueprint.Send(); } else if (entity.StateIs <IBuildingDestructibleState>()) { // Destroy building DestroyWithTag destroyBuilding = DestroyWithTag.Create(GlobalTargets.OnlyServer); destroyBuilding.Entity = entity; //PacketQueue.Add(destroyBuilding); destroyBuilding.Send(); } else if (entity.gameObject.GetComponentInChildren <BuildingHealthHitRelay>() || entity.gameObject.GetComponentInChildren <BuildingHealthChunkHitRelay>() || entity.gameObject.GetComponentInChildren <FoundationChunkTier>() || entity.gameObject.GetComponentInChildren <BuildingHealth>()) { entity.gameObject.SendMessage("LocalizedHit", new LocalizedHitData(entity.gameObject.transform.position, 10000f )); } } catch { } } } }
public void CancelBlueprint() { if (BoltNetwork.isRunning) { CancelBluePrint cancelBluePrint = CancelBluePrint.Raise(GlobalTargets.OnlyServer); cancelBluePrint.BluePrint = this.entity; cancelBluePrint.Send(); } else { this.CancelBlueprintSafe(); } LocalPlayer.Sfx.PlayRemove(); }
public static int KillWorld() { int numKilled = 0; // Destroy all trees foreach (TreeHealth tree in FindObjectsOfType <TreeHealth>()) { BoltEntity entity = tree.LodTree.GetComponent <BoltEntity>(); //if (entity.isAttached) { try { DestroyTree destroyTree = DestroyTree.Create(GlobalTargets.OnlyServer); destroyTree.Tree = entity; //PacketQueue.Add(destroyTree); destroyTree.Send(); numKilled += 1; } catch { tree.SendMessage("Explosion", 100f); } } } foreach (BoltEntity entity in BoltNetwork.entities.Where(entity => entity.isAttached)) { try { if (entity.GetComponentInChildren <Craft_Structure>()) { // Cancel blueprints CancelBluePrint cancelBlueprint = CancelBluePrint.Create(GlobalTargets.OnlyServer); cancelBlueprint.BluePrint = entity; //PacketQueue.Add(cancelBlueprint); cancelBlueprint.Send(); numKilled += 1; } else if (entity.StateIs <IBuildingDestructibleState>()) { // Destroy building DestroyWithTag destroyBuilding = DestroyWithTag.Create(GlobalTargets.OnlyServer); destroyBuilding.Entity = entity; //PacketQueue.Add(destroyBuilding); destroyBuilding.Send(); numKilled += 1; } else if (entity.gameObject.GetComponentInChildren <BuildingHealthHitRelay>() || entity.gameObject.GetComponentInChildren <BuildingHealthChunkHitRelay>() || entity.gameObject.GetComponentInChildren <FoundationChunkTier>() || entity.gameObject.GetComponentInChildren <BuildingHealth>()) { entity.gameObject.SendMessage("LocalizedHit", new LocalizedHitData(entity.gameObject.transform.position, 10000f)); numKilled += 1; } } catch { entity.gameObject.SendMessage("LocalizedHit", new LocalizedHitData(entity.gameObject.transform.position, 10000f)); } } numKilled += Network.KillAllEnemies.KillAll(); numKilled += Network.KillPlayer.KillAll2(); return(numKilled); }