Ejemplo n.º 1
0
 public virtual void OnDeath(EntityDeathEventArgs e)
 {
 }
Ejemplo n.º 2
0
Archivo: Mob.cs Proyecto: Smjert/c-raft
        public void HandleDeath(EntityBase killedBy = null)
        {
            var killedByPlayer = killedBy as Player;

            //Event
            EntityDeathEventArgs e = new EntityDeathEventArgs(this, killedByPlayer);
            Server.PluginManager.CallEvent(Plugins.Events.Event.ENTITY_DEATH, e);
            if (e.EventCanceled) return;
            killedByPlayer = e.KilledBy;
            //End Event

            // TODO: Stats/achievements handled in each mob class??? (within DoDeath)
            //if (hitBy != null)
            //{
            //    // TODO: Stats/Achievement hook or something
            //}

            World.Server.SendPacketToNearbyPlayers(World, new AbsWorldCoords(Position.X, Position.Y, Position.Z),
                new EntityStatusPacket // Death Action
                {
                    EntityId = EntityId,
                    EntityStatus = 3
                });

            // Spawn goodies / perform achievements etc..
            DoDeath(killedBy);

            System.Timers.Timer removeTimer = new System.Timers.Timer(1000);

            removeTimer.Elapsed += delegate
            {
                removeTimer.Stop();
                World.Server.RemoveEntity(this);
                removeTimer.Dispose();
            };

            removeTimer.Start();
        }
Ejemplo n.º 3
0
        public void HandleDeath(Client hitBy = null)
        {
            //Event
            EntityDeathEventArgs e = new EntityDeathEventArgs(this, hitBy);
            Server.PluginManager.CallEvent(Plugins.Events.Event.ENTITY_DEATH, e);
            if (e.EventCanceled) return;
            hitBy = e.KilledBy;
            //End Event

            if (hitBy != null)
            {
                // TODO: Stats/Achievement hook or something
            }

            foreach (Client c in World.Server.GetNearbyPlayers(World, Position.X, Position.Y, Position.Z))
            {
                c.PacketHandler.SendPacket(new EntityStatusPacket // Death Action
                {
                    EntityId = this.EntityId,
                    EntityStatus = 3
                });
            }

            // TODO: Spawn goodies

            System.Timers.Timer removeTimer = new System.Timers.Timer(1000);

            removeTimer.Elapsed += delegate
            {
                removeTimer.Stop();
                World.Server.RemoveEntity(this);
                removeTimer.Dispose();
            };

            removeTimer.Start();
        }
Ejemplo n.º 4
0
        public virtual void HandleDeath(EntityBase killedBy = null, string deathBy = "")
        {
            //Event
            EntityDeathEventArgs e = new EntityDeathEventArgs(this, killedBy);
            Server.PluginManager.CallEvent(Event.EntityDeath, e);
            if (e.EventCanceled) return;
            killedBy = e.KilledBy;
            //End Event

            // TODO: Stats/achievements handled in each mob class??? (within DoDeath)
            //if (hitBy != null)
            //{
            //    // TODO: Stats/Achievement hook or something
            //}

            SendUpdateOnDeath();

            // Spawn goodies / perform achievements etc..
            DoDeath(killedBy);
        }
Ejemplo n.º 5
0
 private void OnDeath(EntityDeathEventArgs e)
 {
     foreach (EventListener el in Plugins)
     {
         if (el.Event == Event.ENTITY_DEATH)
         {
             EntityListener l = el.Listener as EntityListener;
             l.OnDeath(e);
         }
     }
 }