protected void FinishTrigger(EnergyTrigger trigger, NPNFError error) { if (trigger != null) { trigger.FinishTriggeredAction(this, trigger, error); } }
private void HandleUninitializedEnergy(EnergyTrigger trigger, Action <Energy, EnergyTrigger, NPNFError> callback) { NPNFError error = NPNFError.GetGameError(NPNFError.GameCode.ENERGY_NOT_INITIALIZED); if (callback != null) { callback(this, trigger, error); } FinishTrigger(trigger, error); }
private void TriggerHandler(EnergyTrigger trigger) { if (trigger.action == EnergyTrigger.Action.Debit) { Debit(trigger.amount, trigger); } else if (trigger.action == EnergyTrigger.Action.Credit) { Credit(trigger.amount, trigger); } }
private void Credit(int amount, EnergyTrigger trigger) { if (!IsInitialized) { HandleUninitializedEnergy(trigger, OnCreditError); return; } Model.Credit(energyName, amount, (EnergyStatus status, NPNFError error) => { if (error != null && OnCreditError != null) { OnCreditError(this, trigger, error); } FinishTrigger(trigger, error); }); }
protected abstract void DebitErrorHandler(Energy energy, EnergyTrigger trigger, NPNFError error);