// God how I wish you could easily make functional functions in C#. public PRifleD FRunUpdate(PRifleD copiedData) { switch (mState) { case STATE.FIRING: copiedData = RUN_FiringState(copiedData); break; case STATE.COOLING_DOWN: copiedData = RUN_CooldownState(copiedData); break; } return(copiedData); }
PRifleD RUN_FiringState(PRifleD copiedData) { if (copiedData.mPlasmaD.mHeat >= 100f) { mState = STATE.COOLING_DOWN; copiedData.mPlasmaD.mOverheatTmStmp = Time.time; Debug.Log("Weapon Overheated, cooling down"); } return(copiedData); }
PRifleD RUN_CooldownState(PRifleD copiedData) { copiedData.mPlasmaD.mHeat -= copiedData.mPlasmaD._cooldownRate * Time.deltaTime; if (Time.time - copiedData.mPlasmaD.mOverheatTmStmp > copiedData.mPlasmaD._cooldownTime) { mState = STATE.FIRING; Debug.Log("Cooldown Over"); } return(copiedData); }