Example #1
0
 private void HandlePlayerPropertyChanged(string property, PlayerEntity entity)
 {
     var client = GetClientForEntity(entity) as RemoteClient;
     if (client == null)
         return; // Note: would an exception be appropriate here?
     switch (property)
     {
         case "Position":
             if ((int)(entity.Position.X) >> 4 != (int)(entity.OldPosition.X) >> 4 ||
                 (int)(entity.Position.Z) >> 4 != (int)(entity.OldPosition.Z) >> 4)
             {
                 client.Log("Passed chunk boundary at {0}, {1}", (int)(entity.Position.X) >> 4, (int)(entity.Position.Z) >> 4);
                 Task.Factory.StartNew(client.UpdateChunks);
                 UpdateClientEntities(client);
             }
             break;
     }
 }
Example #2
0
 private IRemoteClient GetClientForEntity(PlayerEntity entity)
 {
     return Server.Clients.SingleOrDefault(c => c.Entity != null && c.Entity.EntityID == entity.EntityID);
 }