public override void Update(float frameTime) { base.Update(frameTime); if (!_gameTiming.IsFirstTimePredicted) { return; } var canFireSemi = _isFirstShot; var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use); if (!_combatModeSystem.IsInCombatMode() || state != BoundKeyState.Down) { _isFirstShot = true; _blocked = false; return; } _isFirstShot = false; var entity = _playerManager.LocalPlayer.ControlledEntity; if (entity == null || !entity.TryGetComponent(out IHandsComponent hands)) { return; } var held = hands.ActiveHand; if (held == null || !held.TryGetComponent(out ClientRangedWeaponComponent weapon)) { _blocked = true; return; } if (_blocked) { return; } var worldPos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition); if (!_mapManager.TryFindGridAt(worldPos, out var grid)) { grid = _mapManager.GetDefaultGrid(worldPos.MapId); } if (weapon.Automatic || canFireSemi) { weapon.SyncFirePos(grid.MapToGrid(worldPos)); } }
public override void Update(float frameTime) { base.Update(frameTime); if (!_gameTiming.IsFirstTimePredicted) { return; } var canFireSemi = _isFirstShot; var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use); if (!_combatModeSystem.IsInCombatMode() || state != BoundKeyState.Down) { _isFirstShot = true; _blocked = false; return; } _isFirstShot = false; var entity = _playerManager.LocalPlayer.ControlledEntity; if (entity == null || !entity.TryGetComponent(out IHandsComponent hands)) { return; } var held = hands.ActiveHand; if (held == null || !held.TryGetComponent(out ClientRangedWeaponComponent weapon)) { _blocked = true; return; } if (_blocked) { return; } var worldPos = _eyeManager.ScreenToWorld(_inputManager.MouseScreenPosition); if (weapon.Automatic || canFireSemi) { Logger.Debug(IoCManager.Resolve <IGameTiming>().CurTick.ToString()); weapon.SyncFirePos(worldPos); } }
public override void Update(float frameTime) { base.Update(frameTime); if (!_gameTiming.IsFirstTimePredicted) { return; } var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use); if (!_combatModeSystem.IsInCombatMode() || state != BoundKeyState.Down) { _shotCounter = 0; _blocked = false; return; } var entity = _playerManager.LocalPlayer.ControlledEntity; if (entity == null || !entity.TryGetComponent(out HandsComponent hands)) { return; } var held = hands.ActiveHand; if (held == null || !held.TryGetComponent(out ClientRangedWeaponComponent weapon)) { _blocked = true; return; } switch (weapon.FireRateSelector) { case FireRateSelector.Safety: _blocked = true; return; case FireRateSelector.Single: if (_shotCounter >= 1) { _blocked = true; return; } break; case FireRateSelector.Automatic: break; default: throw new ArgumentOutOfRangeException(); } if (_blocked) { return; } var worldPos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition); if (!_mapManager.TryFindGridAt(worldPos, out var grid)) { weapon.SyncFirePos(GridId.Invalid, worldPos.Position); } else { weapon.SyncFirePos(grid.Index, grid.MapToGrid(worldPos).Position); } }