コード例 #1
0
 private void SetPlayerNumberOnPlayerControlsPanel(VoosActor actor, Behaviors.BehaviorUse use, int playerNumber)
 {
     use = use.DeepClone();
     use.SetPropertyValue(PLAYER_NUMBER_PROP_NAME, playerNumber);
     Behaviors.Brain brain = actor.GetBehaviorSystem().GetBrain(actor.GetBrainName());
     if (brain == null)
     {
         Debug.LogErrorFormat("Could not set player# on actor {0} ({1}). No brain.", actor.GetName(), actor.GetDisplayName());
         return;
     }
     brain.SetUse(use);
     actor.GetBehaviorSystem().PutBrain(actor.GetBrainName(), brain);
 }
コード例 #2
0
 private static Behaviors.BehaviorUse TryGetPlayerControlsPanel(VoosActor actor)
 {
     Behaviors.Brain brain = actor.GetBehaviorSystem().GetBrain(actor.GetBrainName());
     if (brain == null)
     {
         return(null);
     }
     foreach (Behaviors.BehaviorUse use in actor.GetBehaviorSystem().GetBrain(actor.GetBrainName()).GetUses())
     {
         if (use.behaviorUri == PLAYER_CONTROLS_PANEL_URI)
         {
             return(use);
         }
     }
     return(null);
 }
コード例 #3
0
 private void DeletePlayerControlsPanel(VoosActor actor)
 {
     Debug.Assert(actor.IsLocallyOwned(), "Actor should be locally owned");
     Behaviors.BehaviorUse playerControlsPanel = TryGetPlayerControlsPanel(actor);
     if (playerControlsPanel == null)
     {
         return;
     }
     Behaviors.Brain brain = actor.GetBehaviorSystem().GetBrain(actor.GetBrainName());
     if (brain == null)
     {
         Debug.LogErrorFormat("Could not set player# on actor {0} ({1}). No brain.", actor.GetName(), actor.GetDisplayName());
         return;
     }
     // PLAYER_CONTROLS_PANEL_HAS_NO_DECKS_ASSUMPTION
     // WARNING: this is a naive delete that doesn't recursively look for behavior uses mentioned
     // in any decks used by the Player Controls panel, so if in the future we do add decks to it,
     // we need to update this logic to remove the panel properly.
     brain.DeleteUse(playerControlsPanel.id);
     actor.GetBehaviorSystem().PutBrain(actor.GetBrainName(), brain);
 }