Gun stuff (#132)
* Guns can now be fully automatic. Take that BYOND. * Improve delay handling * Bullet spread * Fix firing guns on pickup
This commit is contained in:
committed by
GitHub
parent
69946c79d8
commit
7ca90d11b3
@@ -82,7 +82,9 @@
|
||||
<Compile Include="GameObjects\Components\Power\ApcBoundUserInterface.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\PowerCellVisualizer2D.cs" />
|
||||
<Compile Include="GameObjects\Components\Storage\ClientStorageComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Weapons\Ranged\ClientRangedWeaponComponent.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\ClientNotifySystem.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\RangedWeaponSystem.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\VerbSystem.cs" />
|
||||
<Compile Include="GameTicking\ClientGameTicker.cs" />
|
||||
<Compile Include="Graphics\Overlays\CircleMaskOverlay.cs" />
|
||||
@@ -145,4 +147,4 @@
|
||||
<Compile Include="Construction\ConstructionPlacementHijack.cs" />
|
||||
<Compile Include="GameObjects\Components\IconSmoothing\IconSmoothComponent.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -5,12 +5,14 @@ using Content.Client.GameObjects.Components.Construction;
|
||||
using Content.Client.GameObjects.Components.Power;
|
||||
using Content.Client.GameObjects.Components.SmoothWalling;
|
||||
using Content.Client.GameObjects.Components.Storage;
|
||||
using Content.Client.GameObjects.Components.Weapons.Ranged;
|
||||
using Content.Client.GameTicking;
|
||||
using Content.Client.Input;
|
||||
using Content.Client.Interfaces;
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using Content.Client.Interfaces.Parallax;
|
||||
using Content.Client.Parallax;
|
||||
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
||||
using Content.Shared.Interfaces;
|
||||
using SS14.Client;
|
||||
using SS14.Client.Interfaces;
|
||||
@@ -52,6 +54,7 @@ namespace Content.Client
|
||||
factory.RegisterIgnore("Welder");
|
||||
factory.RegisterIgnore("Wrench");
|
||||
factory.RegisterIgnore("Crowbar");
|
||||
factory.Register<ClientRangedWeaponComponent>();
|
||||
factory.RegisterIgnore("HitscanWeapon");
|
||||
factory.RegisterIgnore("ProjectileWeapon");
|
||||
factory.RegisterIgnore("Projectile");
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Content.Client.GameObjects
|
||||
|
||||
[ViewVariables] private ISpriteComponent _sprite;
|
||||
|
||||
[ViewVariables] public IEntity ActiveHand => GetEntity(ActiveIndex);
|
||||
|
||||
public override void OnAdd()
|
||||
{
|
||||
base.OnAdd();
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
||||
using SS14.Shared.Interfaces.Timing;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Log;
|
||||
using SS14.Shared.Map;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Weapons.Ranged
|
||||
{
|
||||
public sealed class ClientRangedWeaponComponent : SharedRangedWeaponComponent
|
||||
{
|
||||
private TimeSpan _lastFireTime;
|
||||
private int _tick;
|
||||
|
||||
public void TryFire(GridLocalCoordinates worldPos)
|
||||
{
|
||||
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
var span = curTime - _lastFireTime;
|
||||
if (span.TotalSeconds < 1 / FireRate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Debug("Delay: {0}", span.TotalSeconds);
|
||||
_lastFireTime = curTime;
|
||||
SendNetworkMessage(new FireMessage(worldPos, _tick++));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using Content.Client.GameObjects.Components.Weapons.Ranged;
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using Content.Shared.Input;
|
||||
using SS14.Client.GameObjects.EntitySystems;
|
||||
using SS14.Client.Interfaces.Graphics.ClientEye;
|
||||
using SS14.Client.Interfaces.Input;
|
||||
using SS14.Client.Player;
|
||||
using SS14.Shared.GameObjects.Systems;
|
||||
using SS14.Shared.Input;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
namespace Content.Client.GameObjects.EntitySystems
|
||||
{
|
||||
public class RangedWeaponSystem : EntitySystem
|
||||
{
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPlayerManager _playerManager;
|
||||
[Dependency] private readonly IEyeManager _eyeManager;
|
||||
[Dependency] private readonly IInputManager _inputManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
private InputSystem _inputSystem;
|
||||
private bool _isFirstShot;
|
||||
private bool _blocked;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
_inputSystem = EntitySystemManager.GetEntitySystem<InputSystem>();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var canFireSemi = _isFirstShot;
|
||||
var state = _inputSystem.CmdStates.GetState(ContentKeyFunctions.UseItemInHand);
|
||||
if (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)
|
||||
{
|
||||
weapon.TryFire(worldPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace Content.Client.Interfaces.GameObjects
|
||||
{
|
||||
IEntity GetEntity(string index);
|
||||
string ActiveIndex { get; }
|
||||
IEntity ActiveHand { get; }
|
||||
|
||||
void SendChangeHand(string index);
|
||||
void AttackByInHand(string index);
|
||||
|
||||
Reference in New Issue
Block a user