Example #1
0
 /// <summary>
 /// Remove an actor from the squad.
 /// </summary>
 /// <param name="actor">An actor.</param>
 public static void RemoveFromSquad(Actor actor)
 {
     SceneManager.MoveGameObjectToScene(actor.gameObject, SceneManager.GetActiveScene());
     _units.RemoveAll(x => x.Actor.Guid == actor.Guid);
     DeleteSelector(actor);
     PortraitManager.DeleteActorPortrait(actor);
     UserInputs.Instance.Unsubscribe(actor.Guid.ToString(), SelectActor);
 }
Example #2
0
    /// <summary>
    /// Add an actor from the squad.
    /// </summary>
    /// <param name="actor">An actor.</param>
    public static void AddToSquad(Actor actor)
    {
        int index = _units.FindIndex(x => x.Actor.Guid == actor.Guid);

        if (index == -1)
        {
            Object.DontDestroyOnLoad(actor);
            _units.Add(new Unit(actor, CreateSelector(actor)));
        }
        else
        {
            throw new UnityException("This actor has already been added to the Squad, something is wrong.");
        }

        PortraitManager.InstantiateActorPortrait(actor);
        UserInputs.Instance.Subscribe(actor.Guid.ToString(), SelectActor, true);
    }