Merge branch 'master' into 20-06-24-movement-prediction

This commit is contained in:
Pieter-Jan Briers
2020-06-24 04:04:43 +02:00
2259 changed files with 16436 additions and 11772 deletions

View File

@@ -1,5 +1,7 @@
using Content.Client.GameObjects.Components.Weapons.Ranged;
using System;
using Content.Client.GameObjects.Components.Weapons.Ranged;
using Content.Client.Interfaces.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.Input;
@@ -26,8 +28,8 @@ namespace Content.Client.GameObjects.EntitySystems
private InputSystem _inputSystem;
private CombatModeSystem _combatModeSystem;
private bool _isFirstShot;
private bool _blocked;
private int _shotCounter;
public override void Initialize()
{
@@ -46,18 +48,15 @@ namespace Content.Client.GameObjects.EntitySystems
{
return;
}
var canFireSemi = _isFirstShot;
var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use);
if (!_combatModeSystem.IsInCombatMode() || state != BoundKeyState.Down)
{
_isFirstShot = true;
_shotCounter = 0;
_blocked = false;
return;
}
_isFirstShot = false;
var entity = _playerManager.LocalPlayer.ControlledEntity;
if (entity == null || !entity.TryGetComponent(out IHandsComponent hands))
{
@@ -71,6 +70,25 @@ namespace Content.Client.GameObjects.EntitySystems
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;
@@ -81,10 +99,7 @@ namespace Content.Client.GameObjects.EntitySystems
if (!_mapManager.TryFindGridAt(worldPos, out var grid))
grid = _mapManager.GetDefaultGrid(worldPos.MapId);
if (weapon.Automatic || canFireSemi)
{
weapon.SyncFirePos(grid.MapToGrid(worldPos));
}
weapon.SyncFirePos(grid.MapToGrid(worldPos));
}
}
}