void OnTriggerStay(Collider other) { GameObject intruder = other.gameObject; Flammable flammable = intruder.GetComponent <Flammable>(); PureEnergy pureEnergy = intruder.GetComponent <PureEnergy>(); if (flammable != null && flammable.state != Flammable.State.Burning) { source.Remove(intruder); } if (pureEnergy != null && pureEnergy.duration <= 0) { source.Remove(intruder); } if (flammable != null && flammable.state == Flammable.State.Burning && (!source.Remove(intruder))) { source.Add(intruder); } else if (flammable != null && flammable.state == Flammable.State.Burning) { source.Add(intruder); } if (source.Count == 0) { TurnOff(); } else { TurnOn(); } }
void OnTriggerEnter(Collider other) { GameObject intruder = other.gameObject; Flammable flammable = intruder.GetComponent <Flammable>(); PureEnergy pureEnergy = intruder.GetComponent <PureEnergy>(); if (flammable != null && flammable.state == Flammable.State.Burning) { source.Add(intruder); } if (pureEnergy != null && pureEnergy.duration > 0) { source.Add(intruder); } if (source.Count > 0) { TurnOn(); } }