コード例 #1
0
ファイル: EntityManager.cs プロジェクト: pdelvo/Craft.Net
 /// <summary>
 /// Note: This will not correctly kill players. If you wish to kill
 /// a player, set its health to zero and EntityManager will automatically
 /// kill the player through the correct means.
 /// </summary>
 public void KillEntity(LivingEntity entity)
 {
     entity.DeathAnimationComplete += (sender, args) =>
         {
             if (entity.Health <= 0)
                 DespawnEntity(entity);
         };
     entity.Kill();
     foreach (var client in GetKnownClients(entity))
         client.SendPacket(new EntityStatusPacket(entity.Id, EntityStatus.Dead));
 }
コード例 #2
0
ファイル: EntityManager.cs プロジェクト: seaboy1234/Craft.Net
 /// <summary>
 /// Note: This will not correctly kill players. If you wish to kill
 /// a player, set its health to zero and EntityManager will automatically
 /// kill the player through the correct means.
 /// </summary>
 public void KillEntity(LivingEntity entity)
 {
     entity.DeathAnimationComplete += (sender, args) =>
     {
         if (entity.Health <= 0)
             DespawnEntity(entity);
     };
     if (entity is PlayerEntity)
     {
         var player = entity as PlayerEntity;
         SpawnInventoryEntities(player);
         server.OnPlayerDeath(new PlayerDeathEventArgs(player.LastDamageType, player, player.LastAttackingEntity));
     }
     entity.Kill();
     foreach (var client in GetKnownClients(entity))
         client.SendPacket(new EntityStatusPacket(entity.Id, EntityStatusPacket.EntityStatus.Dead));
 }