예제 #1
0
 public void DamagedBy(Entity enemy)
 {
     if (KnownEntities.Contains(enemy))
     {
         KnownEntities.MoveElement(enemy, -2);
     }
 }
예제 #2
0
 public void AttackedBy(Entity enemy)
 {
     if (KnownEntities.Contains(enemy))
     {
         KnownEntities.MoveElement(enemy, -1);
     }
 }
예제 #3
0
 internal void TrackEntity(Entity entity)
 {
     if (!KnownEntities.Contains(entity.EntityId))
     {
         KnownEntities.Add(entity.EntityId);
         if (entity is PlayerEntity)
         {
             var player       = entity as PlayerEntity;
             var selectedItem = player.SelectedItem.Id;
             if (selectedItem == -1)
             {
                 selectedItem = 0;
             }
             SendPacket(new SpawnPlayerPacket(player.EntityId, UUID, player.Username, MathHelper.CreateAbsoluteInt(player.Position.X),
                                              MathHelper.CreateAbsoluteInt(player.Position.Y), MathHelper.CreateAbsoluteInt(player.Position.Z),
                                              MathHelper.CreateRotationByte(player.Yaw), MathHelper.CreateRotationByte(player.Pitch), selectedItem, player.Metadata));
             if (!player.SelectedItem.Empty)
             {
                 SendPacket(new EntityEquipmentPacket(entity.EntityId, EntityEquipmentPacket.EntityEquipmentSlot.HeldItem, player.SelectedItem));
             }
             // TODO: Send armor
         }
         else if (entity is ObjectEntity)
         {
             var objectEntity = entity as ObjectEntity;
             SendPacket(new SpawnObjectPacket(objectEntity.EntityId, objectEntity.EntityType, MathHelper.CreateAbsoluteInt(objectEntity.Position.X),
                                              MathHelper.CreateAbsoluteInt(objectEntity.Position.Y), MathHelper.CreateAbsoluteInt(objectEntity.Position.Z), MathHelper.CreateRotationByte(objectEntity.Yaw),
                                              MathHelper.CreateRotationByte(objectEntity.Pitch), objectEntity.Data, 0, 0, 0)); // TODO: Velocity stuff here
             if (objectEntity.SendMetadataToClients)
             {
                 SendPacket(new EntityMetadataPacket(objectEntity.EntityId, objectEntity.Metadata));
             }
         }
     }
 }
예제 #4
0
 internal void ForgetEntity(Entity entity)
 {
     if (KnownEntities.Contains(entity.EntityId))
     {
         KnownEntities.Remove(entity.EntityId);
     }
     SendPacket(new DestroyEntityPacket(new int[] { entity.EntityId }));
 }
예제 #5
0
 public void DamagedBy(Entity enemy)
 {
     if (!Attackers.Contains(enemy))
     {
         Attackers.Add(enemy);
     }
     if (KnownEntities.Contains(enemy))
     {
         KnownEntities.MoveElement(enemy, -2);
     }
 }