示例#1
0
 /// <summary>
 /// Stops the controller from sticking to future entities, and removes it from all entities that have it and satisfy the match condition.
 /// </summary>
 /// <param name="controller"></param>
 public void RemoveController( GameController controller, Predicate<GameEntity> match )
 {
     foreach ( GameEntity entity in Entities )
     {
         if ( match( entity ) )
         {
             entity.RemoveController( controller );
         }
     }
     MasterControllers.Remove( controller );
 }
示例#2
0
 /// <summary>
 /// Stops sticking the given controller to future entities.
 /// </summary>
 /// <param name="controller">The controller to stop.</param>
 public void StopController( GameController controller )
 {
     MasterControllers.Remove( controller );
 }
示例#3
0
 /// <summary>
 /// Adds the controller to all entities in the game that satisfy the AddEntity condition.
 /// Doesn't add to newly spawned entities.
 /// </summary>
 /// <param name="controller">The controller to add.</param>
 public void PutController( GameController controller )
 {
     foreach ( GameEntity entity in Entities )
     {
         if ( controller.AddEntity( entity ) )
         {
             entity.AppendController( controller );
         }
     }
 }
示例#4
0
 /// <summary>
 /// Returns whether or not this GameController is a control of any entity on the board.
 /// </summary>
 /// <param name="controller">The controller to check.</param>
 /// <returns></returns>
 public bool HasController( GameController controller )
 {
     foreach ( GameEntity entity in Entities )
     {
         if ( entity.HasController( controller ) )
         {
             return true;
         }
     }
     return false;
 }
示例#5
0
 /// <summary>
 /// Removes the controller from the entity's controllers, if present.
 /// </summary>
 /// <param name="controller">The controller to remove.</param>
 /// <returns>True if the controller was removed, false if it doesn't exist.</returns>
 public bool RemoveController( GameController controller )
 {
     if ( Controllers.Contains( controller ) )
     {
         Controllers.Remove( controller );
         return true;
     }
     return false;
 }
示例#6
0
 /// <summary>
 /// Returns whether or not the given controller controls this entity.
 /// </summary>
 /// <param name="controller">The controller to check.</param>
 /// <returns></returns>
 public bool HasController( GameController controller )
 {
     return Controllers.Contains( controller );
 }
示例#7
0
 /// <summary>
 /// Adds the controller to the entity's controllers, if not already present.
 /// </summary>
 /// <param name="controller">The controller to add.</param>
 /// <returns>True if the controller was added, false if it already existed.</returns>
 public bool AppendController( GameController controller )
 {
     if ( Controllers.Contains( controller ) )
     {
         return false;
     }
     Controllers.Add( controller );
     return true;
 }