Updates various systems to the new InputCommandHandler delegate signature, implementing the new handled return value.
Modifies the construction system to use the newer InputHandler system, instead of the older ClickComponent system. Updates the engine submodule.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Construction;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Construction
|
||||
@@ -14,18 +12,5 @@ namespace Content.Client.GameObjects.Components.Construction
|
||||
[ViewVariables] public ConstructionPrototype Prototype { get; set; }
|
||||
[ViewVariables] public ConstructorComponent Master { get; set; }
|
||||
[ViewVariables] public int GhostID { get; set; }
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null,
|
||||
IComponent component = null)
|
||||
{
|
||||
base.HandleMessage(message, netChannel, component);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case ClientEntityClickMsg clickMsg:
|
||||
Master.TryStartConstruction(GhostID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Client.Construction;
|
||||
using Content.Client.Construction;
|
||||
using Content.Client.GameObjects.Components.Construction;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.Input;
|
||||
@@ -6,6 +6,7 @@ using Robust.Client.GameObjects.EntitySystems;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.GameObjects.EntitySystems
|
||||
@@ -15,6 +16,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IGameHud _gameHud;
|
||||
[Dependency] private readonly IPlayerManager _playerManager;
|
||||
[Dependency] private readonly IEntityManager _entityManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
public override void Initialize()
|
||||
@@ -24,14 +26,17 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
var inputSys = EntitySystemManager.GetEntitySystem<InputSystem>();
|
||||
inputSys.BindMap.BindFunction(ContentKeyFunctions.OpenCraftingMenu,
|
||||
new PointerInputCmdHandler(HandleOpenCraftingMenu));
|
||||
|
||||
inputSys.BindMap.BindFunction(EngineKeyFunctions.Use,
|
||||
new PointerInputCmdHandler(HandleUse));
|
||||
}
|
||||
|
||||
private void HandleOpenCraftingMenu(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
private bool HandleOpenCraftingMenu(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
if (_playerManager.LocalPlayer.ControlledEntity == null
|
||||
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out ConstructorComponent constructor))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var menu = constructor.ConstructionMenu;
|
||||
@@ -51,6 +56,23 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
{
|
||||
_setOpenValue(menu, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool HandleUse(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
if (!args.EntityUid.IsValid() || !args.EntityUid.IsClientSide())
|
||||
return false;
|
||||
|
||||
var entity = _entityManager.GetEntity(args.EntityUid);
|
||||
|
||||
if (!entity.TryGetComponent(out ConstructionGhostComponent ghostComp))
|
||||
return false;
|
||||
|
||||
ghostComp.Master.TryStartConstruction(ghostComp.GhostID);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private void _setOpenValue(ConstructionMenu menu, bool value)
|
||||
|
||||
@@ -51,21 +51,22 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
RegisterMessageType<ExamineSystemMessages.ExamineInfoResponseMessage>();
|
||||
}
|
||||
|
||||
private void HandleExamine(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
private bool HandleExamine(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
{
|
||||
if (!uid.IsValid() || !_entityManager.TryGetEntity(uid, out var examined))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var playerEntity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
|
||||
if (playerEntity == null || !CanExamine(playerEntity, examined))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
DoExamine(examined);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async void DoExamine(IEntity entity)
|
||||
|
||||
@@ -76,24 +76,24 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
_currentPopup.Open(box);
|
||||
}
|
||||
|
||||
private void OnOpenContextMenu(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
private bool OnOpenContextMenu(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
if (_currentPopup != null)
|
||||
{
|
||||
_closeContextMenu();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(_stateManager.CurrentState is GameScreen gameScreen))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var entities = gameScreen.GetEntitiesUnderPosition(args.Coordinates);
|
||||
|
||||
if (entities.Count == 0)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
_currentPopup = new VerbPopup();
|
||||
@@ -110,6 +110,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
var size = _currentPopup.List.CombinedMinimumSize;
|
||||
var box = UIBox2.FromDimensions(args.ScreenCoordinates.Position, size);
|
||||
_currentPopup.Open(box);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnContextButtonPressed(IEntity entity)
|
||||
|
||||
Reference in New Issue
Block a user