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()); } }
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; }