public void OnPlayerUpdate(Player player) { // is player in area? if (IsInside(player.Position)) { // if not on list, add them and update listeners if (!PlayersInArea.Contains(player)) { PlayersInArea.Add(player); PlayerEnteredArea.Invoke(player, new AreaEventArgs { AreaBeingWatched = this }); } } else { // if on list, remove them and update listeners if (PlayersInArea.Contains(player)) { PlayersInArea.Remove(player); PlayerLeftArea.Invoke(player, new AreaEventArgs { AreaBeingWatched = this }); } } }
//[Header("Player Status")] //[SerializeField] protected bool PlayerInRange; //[SerializeField] protected bool PlayerHeldInteractKeyUponEntering = false; //public override void Awake() //{ // base.Awake(); //} //public override void Start() //{ // base.Start(); //} //public virtual void Update() //{ // if(PlayerInRange) // { // if(PlayerHeldInteractKeyUponEntering == false) // { // if (inputDelegate(defaultKeyToInteract)) // { // PlayerInteracted(); // } // } // if(Input.GetKeyUp(defaultKeyToInteract)) // { // if (PlayerHeldInteractKeyUponEntering == false) // PlayerStoppedInteraction(); // PlayerHeldInteractKeyUponEntering = false; // } // } //} //public override void PlayerInteracted() //{ // base.PlayerInteracted(); //} public virtual void OnTriggerEnter(Collider other) { if (other.gameObject == player) { PlayerEnteredArea?.Invoke(); //PlayerInRange = true; //if (inputDelegate(defaultKeyToInteract)) //{ // PlayerHeldInteractKeyUponEntering = true; //} } }