Beispiel #1
0
 /// <summary>
 /// Tries to move to a different cell on the grid. Note that this does NOT change the REAL
 /// position of the object. It will appear in the same position in the world. This method just
 /// changes which cell it is marked as occupying. If null is passed as newPosition, the object
 /// will be effectively 'removed' from the grid world. Moving to a non-null cell will 'place'
 /// the object back in the world.
 /// </summary>
 /// <param name="newPosition"></param>
 public void MoveToCell(CellPosition newPosition)
 {
     if (newPosition == position)
     {
         return;
     }
     if (position != null)
     {
         dwellsOn.RemoveDwellerFromCell(position, this);
     }
     position = newPosition;
     if (position != null)
     {
         dwellsOn.AddDwellerToCell(position, this);
     }
 }