private IEnumerator JudgeElectrifiedEnumerator() { var wait = new WaitForSeconds(m_intervalTime); while (true) { if (JudgeElectrification()) { if (m_isElectrified == 0) { var args = new CircuitElementEventArgs(); OnElectrified(args); } } else { if (m_isElectrified > 0) { var args = new CircuitElementEventArgs(); OnUnElectrified(args); } } yield return(wait); } }
protected virtual void OnElectrified(CircuitElementEventArgs e) { if (m_isElectrified == 0) { m_isElectrified = 1; ResetCurrent(); if (m_electrified != null) { m_electrified.Invoke(); } if (m_electrifiedEventHandle != null) { m_electrifiedEventHandle(this, e); } } }
protected virtual void OnUnElectrified(CircuitElementEventArgs e) { if (m_isElectrified > 0) { m_isElectrified = 0; m_current = 0f; if (m_unelectrified != null) { m_unelectrified.Invoke(); } if (m_unelectrifiedEventHandle != null) { m_unelectrifiedEventHandle(this, e); } } }