Esempio n. 1
0
        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
                    {
                    }
                }
            }
        }
Esempio n. 2
0
 public override void OnEvent(CancelBluePrint evnt)
 {
     if (evnt.BluePrint)
     {
         Craft_Structure componentInChildren = evnt.BluePrint.GetComponentInChildren <Craft_Structure>();
         if (componentInChildren)
         {
             componentInChildren.CancelBlueprintSafe();
         }
     }
 }
Esempio n. 3
0
 public void CancelBlueprint()
 {
     if (BoltNetwork.isRunning)
     {
         CancelBluePrint cancelBluePrint = CancelBluePrint.Raise(GlobalTargets.OnlyServer);
         cancelBluePrint.BluePrint = this.entity;
         cancelBluePrint.Send();
     }
     else
     {
         this.CancelBlueprintSafe();
     }
     LocalPlayer.Sfx.PlayRemove();
 }
Esempio n. 4
0
 public static void Execute()
 {
     if (BoltNetwork.isRunning)
     {
         foreach (var entity in BoltNetwork.entities.Where(entity => entity.isAttached))
         {
             try
             {
                 if (entity.GetComponentInChildren <Craft_Structure>())
                 {
                     // Cancel blueprints
                     var cancelBlueprint = CancelBluePrint.Create(GlobalTargets.OnlyServer);
                     cancelBlueprint.BluePrint = entity;
                     PacketQueue.Add(cancelBlueprint);
                 }
                 else if (entity.StateIs <IBuildingDestructibleState>())
                 {
                     // Destroy building
                     var destroyBuilding = DestroyBuilding.Create(GlobalTargets.OnlyServer);
                     destroyBuilding.BuildingEntity = entity;
                     PacketQueue.Add(destroyBuilding);
                 }
                 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 (Exception)
             {
                 // ignored
             }
         }
     }
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 public override void OnEvent(CancelBluePrint evnt)
 {
     if (evnt.BluePrint)
     {
         Craft_Structure componentInChildren = evnt.BluePrint.GetComponentInChildren<Craft_Structure>();
         if (componentInChildren)
         {
             componentInChildren.CancelBlueprintSafe();
         }
     }
 }