public override void UnloadAmmo() { _nextAmmoHandlerState = new AmmoUnloadState(Module); }
public override void Update(TimeSpan time) { if (_timer.Elapsed == TimeSpan.Zero) { if (!CheckAmmo()) { var loadState = AmmoLoadState.CreateFromCurrentAmmo(Module); if (loadState == null) { Module.OnError(ErrorCodes.AmmoNotFound); SwitchTo(ModuleStateType.Idle); return; } Module._states.Push(loadState); return; } if (!CheckCore()) { Module.OnError(ErrorCodes.OutOfCore); SwitchTo(ModuleStateType.Idle); return; } try { Module.OnAction(); DecreaseCore(); } catch (Exception ex) { HandleException(ex); SwitchTo(ModuleStateType.Idle); return; } } _timer.Update(time); if (!_timer.Passed) { return; } ResetTimer(); var ammoLoadState = _nextAmmoHandlerState; if (ammoLoadState != null) { _nextAmmoHandlerState = null; if (Type == ModuleStateType.Oneshot) { Module._states.DirectClear(); Module._states.Push(new IdleState(Module)); } Module._states.Push(ammoLoadState); return; } if (Type == ModuleStateType.Oneshot) { SwitchTo(ModuleStateType.Idle); } }
public override void LoadAmmo(int ammoDefinition) { _nextAmmoHandlerState = new AmmoLoadState(Module, ammoDefinition); }