Exemple #1
0
    public void OnDestroyTree(GameObject tree, bool isChoping)
    {
        var destroyedTree = new TreeEventArgs {
            Tree = tree, IsChoping = isChoping
        };

        DestroyTree?.Invoke(this, destroyedTree);
    }
Exemple #2
0
 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();
             }
         }
     }
 }
Exemple #3
0
    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;
        }
    }
 public static void Execute()
 {
     if (BoltNetwork.isRunning)
     {
         // Destroy all trees
         foreach (var tree in UnityEngine.Object.FindObjectsOfType <TreeHealth>())
         {
             var entity = tree.LodTree.GetComponent <BoltEntity>();
             //if (entity.isAttached)
             {
                 try
                 {
                     var destroyTree = DestroyTree.Create(GlobalTargets.OnlyServer);
                     destroyTree.Tree = entity;
                     PacketQueue.Add(destroyTree);
                 }
                 catch (Exception)
                 {
                     // ignored
                 }
             }
         }
     }
 }
Exemple #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);
        }
 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;
     }
 }