Wide attacks on space, remove UseOrAttack.
This commit is contained in:
@@ -25,8 +25,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public sealed class CombatModeSystem : SharedCombatModeSystem
|
||||
{
|
||||
private const float AttackTimeThreshold = 0.15f;
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IGameHud _gameHud;
|
||||
[Dependency] private readonly IPlayerManager _playerManager;
|
||||
@@ -37,9 +35,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
private InputSystem _inputSystem;
|
||||
|
||||
public bool UseOrAttackIsDown { get; private set; }
|
||||
private float _timeHeld;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -48,10 +43,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
_gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged;
|
||||
|
||||
_inputSystem = EntitySystemManager.GetEntitySystem<InputSystem>();
|
||||
_inputSystem.BindMap.BindFunction(ContentKeyFunctions.UseOrAttack, new InputHandler(this));
|
||||
_inputSystem.BindMap.BindFunction(ContentKeyFunctions.ToggleCombatMode,
|
||||
InputCmdHandler.FromDelegate(CombatModeToggled));
|
||||
_overlayManager.AddOverlay(new CombatModeOverlay(this));
|
||||
}
|
||||
|
||||
private void CombatModeToggled(ICommonSession session)
|
||||
@@ -60,20 +53,10 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
{
|
||||
EntityManager.RaisePredictiveEvent(
|
||||
new CombatModeSystemMessages.SetCombatModeActiveMessage(!IsInCombatMode()));
|
||||
|
||||
// Just in case.
|
||||
UseOrAttackIsDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
_overlayManager.RemoveOverlay(nameof(CombatModeOverlay));
|
||||
}
|
||||
|
||||
private bool IsInCombatMode()
|
||||
public bool IsInCombatMode()
|
||||
{
|
||||
var entity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
if (entity == null || !entity.TryGetComponent(out CombatModeComponent combatMode))
|
||||
@@ -92,104 +75,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
private void OnCombatModeChanged(bool obj)
|
||||
{
|
||||
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetCombatModeActiveMessage(obj));
|
||||
|
||||
// Just in case.
|
||||
UseOrAttackIsDown = false;
|
||||
}
|
||||
|
||||
private bool HandleInputMessage(ICommonSession session, InputCmdMessage message)
|
||||
{
|
||||
if (!(message is FullInputCmdMessage msg))
|
||||
return false;
|
||||
|
||||
void SendMsg(BoundKeyFunction function, BoundKeyState state)
|
||||
{
|
||||
var functionId = _inputManager.NetworkBindMap.KeyFunctionID(function);
|
||||
|
||||
var sendMsg = new FullInputCmdMessage(msg.Tick, functionId, state,
|
||||
msg.Coordinates, msg.ScreenCoordinates, msg.Uid);
|
||||
_inputSystem.HandleInputCommand(session, function, sendMsg);
|
||||
}
|
||||
|
||||
// If we are not in combat mode, relay it as a regular Use instead.
|
||||
if (!IsInCombatMode())
|
||||
{
|
||||
SendMsg(EngineKeyFunctions.Use, msg.State);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.State == BoundKeyState.Down)
|
||||
{
|
||||
UseOrAttackIsDown = true;
|
||||
_timeHeld = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Up.
|
||||
if (UseOrAttackIsDown && _timeHeld >= AttackTimeThreshold)
|
||||
{
|
||||
// Attack.
|
||||
SendMsg(ContentKeyFunctions.Attack, BoundKeyState.Down);
|
||||
SendMsg(ContentKeyFunctions.Attack, BoundKeyState.Up);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use.
|
||||
SendMsg(EngineKeyFunctions.Use, BoundKeyState.Down);
|
||||
SendMsg(EngineKeyFunctions.Use, BoundKeyState.Up);
|
||||
}
|
||||
|
||||
UseOrAttackIsDown = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void FrameUpdate(float frameTime)
|
||||
{
|
||||
if (UseOrAttackIsDown)
|
||||
{
|
||||
_timeHeld += frameTime;
|
||||
}
|
||||
}
|
||||
|
||||
// Custom input handler type so we get the ENTIRE InputCmdMessage.
|
||||
private sealed class InputHandler : InputCmdHandler
|
||||
{
|
||||
private readonly CombatModeSystem _combatModeSystem;
|
||||
|
||||
public InputHandler(CombatModeSystem combatModeSystem)
|
||||
{
|
||||
_combatModeSystem = combatModeSystem;
|
||||
}
|
||||
|
||||
public override bool HandleCmdMessage(ICommonSession session, InputCmdMessage message)
|
||||
{
|
||||
return _combatModeSystem.HandleInputMessage(session, message);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class CombatModeOverlay : Overlay
|
||||
{
|
||||
private readonly CombatModeSystem _system;
|
||||
|
||||
public CombatModeOverlay(CombatModeSystem system) : base(nameof(CombatModeOverlay))
|
||||
{
|
||||
_system = system;
|
||||
}
|
||||
|
||||
protected override void Draw(DrawingHandleBase handle)
|
||||
{
|
||||
var screenHandle = (DrawingHandleScreen) handle;
|
||||
|
||||
var mousePos = IoCManager.Resolve<IInputManager>().MouseScreenPosition;
|
||||
|
||||
if (_system.UseOrAttackIsDown && _system._timeHeld > AttackTimeThreshold)
|
||||
{
|
||||
var tex = ResC.GetTexture($"/Textures/Objects/Tools/toolbox_r.png");
|
||||
|
||||
screenHandle.DrawTextureRect(tex, UIBox2.FromDimensions(mousePos, tex.Size * 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
base.Update(frameTime);
|
||||
|
||||
var canFireSemi = _isFirstShot;
|
||||
var state = _inputSystem.CmdStates.GetState(ContentKeyFunctions.Attack);
|
||||
if (!_combatModeSystem.UseOrAttackIsDown && state != BoundKeyState.Down)
|
||||
var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use);
|
||||
if (!_combatModeSystem.IsInCombatMode() && state != BoundKeyState.Down)
|
||||
{
|
||||
_isFirstShot = true;
|
||||
_blocked = false;
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Content.Client.Input
|
||||
common.AddFunction(ContentKeyFunctions.FocusChat);
|
||||
common.AddFunction(ContentKeyFunctions.ExamineEntity);
|
||||
common.AddFunction(ContentKeyFunctions.OpenTutorial);
|
||||
common.AddFunction(ContentKeyFunctions.UseOrAttack);
|
||||
common.AddFunction(ContentKeyFunctions.TakeScreenshot);
|
||||
common.AddFunction(ContentKeyFunctions.TakeScreenshotNoUI);
|
||||
|
||||
@@ -31,7 +30,7 @@ namespace Content.Client.Input
|
||||
human.AddFunction(ContentKeyFunctions.OpenInventoryMenu);
|
||||
human.AddFunction(ContentKeyFunctions.MouseMiddle);
|
||||
human.AddFunction(ContentKeyFunctions.ToggleCombatMode);
|
||||
human.AddFunction(ContentKeyFunctions.Attack);
|
||||
human.AddFunction(ContentKeyFunctions.WideAttack);
|
||||
|
||||
var ghost = contexts.New("ghost", "common");
|
||||
ghost.AddFunction(EngineKeyFunctions.MoveUp);
|
||||
|
||||
@@ -73,6 +73,8 @@ Open inventory: [color=#a4885c]{7}[/color]
|
||||
Open character window: [color=#a4885c]{8}[/color]
|
||||
Open crafting window: [color=#a4885c]{9}[/color]
|
||||
Focus chat: [color=#a4885c]{10}[/color]
|
||||
Use hand/object in hand: [color=#a4885c]{22}[/color]
|
||||
Do wide attack: [color=#a4885c]{23}[/color]
|
||||
Use targeted entity: [color=#a4885c]{11}[/color]
|
||||
Throw held item: [color=#a4885c]{12}[/color]
|
||||
Examine entity: [color=#a4885c]{13}[/color]
|
||||
@@ -102,16 +104,18 @@ Toggle sandbox window: [color=#a4885c]{21}[/color]",
|
||||
Key(ShowDebugMonitors),
|
||||
Key(OpenEntitySpawnWindow),
|
||||
Key(OpenTileSpawnWindow),
|
||||
Key(OpenSandboxWindow)));
|
||||
|
||||
//Gameplay
|
||||
VBox.AddChild(new Label { FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow)) });
|
||||
AddFormattedText(SandboxSpawnerContents);
|
||||
Key(OpenSandboxWindow),
|
||||
Key(Use),
|
||||
Key(WideAttack)));
|
||||
|
||||
//Gameplay
|
||||
VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nGameplay" });
|
||||
AddFormattedText(GameplayContents);
|
||||
|
||||
//Gameplay
|
||||
VBox.AddChild(new Label { FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow)) });
|
||||
AddFormattedText(SandboxSpawnerContents);
|
||||
|
||||
//Feedback
|
||||
VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nFeedback" });
|
||||
AddFormattedText(FeedbackContents);
|
||||
|
||||
@@ -302,8 +302,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
var inputSys = EntitySystemManager.GetEntitySystem<InputSystem>();
|
||||
inputSys.BindMap.BindFunction(EngineKeyFunctions.Use,
|
||||
new PointerInputCmdHandler(HandleUseItemInHand));
|
||||
inputSys.BindMap.BindFunction(ContentKeyFunctions.Attack,
|
||||
new PointerInputCmdHandler(HandleAttack));
|
||||
inputSys.BindMap.BindFunction(ContentKeyFunctions.WideAttack,
|
||||
new PointerInputCmdHandler(HandleWideAttack));
|
||||
inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld,
|
||||
new PointerInputCmdHandler(HandleActivateItemInWorld));
|
||||
}
|
||||
@@ -362,7 +362,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
activateComp.Activate(new ActivateEventArgs {User = user});
|
||||
}
|
||||
|
||||
private bool HandleAttack(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
private bool HandleWideAttack(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
{
|
||||
// client sanitization
|
||||
if (!_mapManager.GridExists(coords.GridID))
|
||||
|
||||
@@ -5,8 +5,7 @@ namespace Content.Shared.Input
|
||||
[KeyFunctions]
|
||||
public static class ContentKeyFunctions
|
||||
{
|
||||
public static readonly BoundKeyFunction UseOrAttack = "UseOrAttack";
|
||||
public static readonly BoundKeyFunction Attack = "Attack";
|
||||
public static readonly BoundKeyFunction WideAttack = "WideAttack";
|
||||
public static readonly BoundKeyFunction ActivateItemInHand = "ActivateItemInHand";
|
||||
public static readonly BoundKeyFunction ActivateItemInWorld = "ActivateItemInWorld"; // default action on world entity
|
||||
public static readonly BoundKeyFunction Drop = "Drop";
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
version: 1 # Not used right now, whatever.
|
||||
binds:
|
||||
- function: UseOrAttack
|
||||
- function: Use
|
||||
type: state
|
||||
key: MouseLeft
|
||||
canFocus: true
|
||||
- function: WideAttack
|
||||
type: state
|
||||
key: Space
|
||||
- function: ShowDebugMonitors
|
||||
type: Toggle
|
||||
key: F3
|
||||
|
||||
Reference in New Issue
Block a user