// Called if actor trigger is attached // TODO: if i need to add multiple triggers of same type then try with Multiple dictionaries // Ex. Dictionary<System.Type,List<ActorTriggerBase>> public virtual void ActorTriggerAttached(ActorTriggerBase triggerBase) { if (m_AllActorTriggerBaseAttached.ContainsKey(triggerBase.GetType()) != true) { m_AllActorTriggerBaseAttached.Add(triggerBase.GetType(), triggerBase); triggerBase.Enabled = true; } else { triggerBase.gameObject.SetActive(false); Debug.LogError("Already 'ActorTriggerBase' of type '" + triggerBase.GetType() + "' attached to game object '" + gameObject.name + "'"); Debug.Break(); } }
// Called when actor trigger is detached public virtual void ActorTriggerDetached(ActorTriggerBase triggerBase) { if (m_AllActorTriggerBaseAttached.ContainsKey(triggerBase.GetType()) == true) { if (m_AllActorTriggerBaseAttached.ContainsValue(triggerBase) == true) { triggerBase.Enabled = false; if (m_AllActorTriggerBaseAttached.Remove(triggerBase.GetType()) == false) { triggerBase.gameObject.SetActive(false); Debug.LogError("Unable to remove 'ActorTriggerBase' of type '" + triggerBase.GetType() + "' attached to game object '" + gameObject.name + "'"); Debug.Break(); } } } }