private IEnumerator LoadWeaponProcess() { Player.Entities[0].Tags.Add(EntityTags.PerformingCommand); yield return(LowerWeapon(false)); _state = State.Reloading; UIChargeCircle.ManualStart(_current.Ammo.Template.ReloadText); var reloadPerAmmo = _current.Ammo.ReloadSpeed / _current.Ammo.Amount.MaxValue; var totalAmmo = _current.Ammo.Amount.MaxValue - _current.Ammo.Amount.Value; int current = 0; while (true) { if (_current == null || _state != State.Reloading) { break; } current++; UIChargeCircle.ManualSetPercent((float)current / totalAmmo); if (!_current.Ammo.TryLoadOneAmmo(Player.Entities[0])) { break; } yield return(reloadPerAmmo); } UIChargeCircle.StopCharge(); if (_state == State.None || _state == State.Reloading) { yield return(RaiseWeapon()); } }
private IEnumerator LoadWeaponProcess() { yield return(LowerWeapon(false)); _state = State.Reloading; UIChargeCircle.StopCharge(); if (_state == State.None || _state == State.Reloading) { yield return(RaiseWeapon()); } }
public override void OnEnter(RuntimeStateNode lastNode) { base.OnEnter(lastNode); Graph.SetVariable(GraphVariables.Reloading, true); _ammo = Graph.Entity.Get <CurrentAction>().Value?.Ammo; if (_ammo == null) { return; } UIChargeCircle.ManualStart(_ammo.Config.ReloadText); _reloadPerAmmo = _ammo.ReloadSpeed / _ammo.Amount.MaxValue; _totalAmmo = _ammo.Amount.MaxValue - _ammo.Amount.Value; _current = 0; _reloadTimer = 0; }
public override bool TryComplete(float dt) { if (base.TryComplete(dt) || _ammo == null) { return(true); } if (!Graph.GetVariable <bool>(GraphVariables.Reloading)) { return(true); } if (_reloadTimer > 0) { _reloadTimer -= dt; return(false); } _current++; UIChargeCircle.ManualSetPercent((float)_current / _totalAmmo); _reloadTimer = _reloadPerAmmo; if (!World.Get <AmmoSystem>().TryLoadOneAmmo(Graph.Entity, _ammo)) { return(true); } return(false); }
public override void OnExit() { base.OnExit(); Graph.SetVariable(GraphVariables.Reloading, false); UIChargeCircle.StopCharge(); }