using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PossessionManager : Singleton<PossessionManager>
{
    public GameObject _possessed;
    public GameObject possessed
    {
        get => _possessed;
        set
        {
            if (_possessed == value) return;
            if (_possessed)
            {
                Event.Of<DepossessEvent>.ExecuteAll(_possessed, new DepossessEvent()
                {
                    depossessed = _possessed,
                    newPossessed = value
                });
            }
            if (value)
            {
                Event.Of<PossessEvent>.ExecuteAll(value, new PossessEvent()
                {
                    possessed = value,
                    oldPossessed = _possessed
                });
            }
            _possessed = value;
        }
    }
}
