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:
@@ -206,24 +206,25 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
new PointerInputCmdHandler(HandleActivateItemInWorld));
|
||||
}
|
||||
|
||||
public void HandleActivateItemInWorld(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
private bool HandleActivateItemInWorld(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
{
|
||||
if (!EntityManager.TryGetEntity(uid, out var used))
|
||||
return;
|
||||
return false;
|
||||
|
||||
var playerEnt = ((IPlayerSession) session).AttachedEntity;
|
||||
|
||||
if (playerEnt == null || !playerEnt.IsValid())
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!playerEnt.Transform.GridPosition.InRange(_mapManager, used.Transform.GridPosition, InteractionRange))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
InteractionActivate(playerEnt, used);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void InteractionActivate(IEntity user, IEntity used)
|
||||
@@ -243,27 +244,27 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
activateComp.Activate(new ActivateEventArgs {User = user});
|
||||
}
|
||||
|
||||
private void HandleUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
private bool HandleUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
{
|
||||
// client sanitization
|
||||
if (!_mapManager.GridExists(coords.GridID))
|
||||
{
|
||||
Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uid.IsClientSide())
|
||||
{
|
||||
Logger.WarningS("system.interaction",
|
||||
$"Client sent interaction with client-side entity. Session={session}, Uid={uid}");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
var userEntity = ((IPlayerSession) session).AttachedEntity;
|
||||
|
||||
if (userEntity == null || !userEntity.IsValid())
|
||||
{
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userEntity.TryGetComponent(out CombatModeComponent combatMode) && combatMode.IsInCombatMode)
|
||||
@@ -274,6 +275,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
UserInteraction(userEntity, coords, uid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UserInteraction(IEntity player, GridCoordinates coordinates, EntityUid clickedUid)
|
||||
|
||||
@@ -97,18 +97,18 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
handsComp.SwapHands();
|
||||
}
|
||||
|
||||
private void HandleDrop(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
private bool HandleDrop(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
{
|
||||
var ent = ((IPlayerSession) session).AttachedEntity;
|
||||
|
||||
if (ent == null || !ent.IsValid())
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ent.TryGetComponent(out HandsComponent handsComp))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coords.InRange(_mapManager, ent.Transform.GridPosition, InteractionSystem.InteractionRange))
|
||||
@@ -119,6 +119,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
handsComp.Drop(handsComp.ActiveIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void HandleActivateItem(ICommonSession session)
|
||||
@@ -129,23 +131,23 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
handsComp.ActivateItem();
|
||||
}
|
||||
|
||||
private void HandleThrowItem(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
private bool HandleThrowItem(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
{
|
||||
var plyEnt = ((IPlayerSession)session).AttachedEntity;
|
||||
|
||||
if (plyEnt == null || !plyEnt.IsValid())
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (!plyEnt.TryGetComponent(out HandsComponent handsComp))
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (!handsComp.CanDrop(handsComp.ActiveIndex))
|
||||
return;
|
||||
return false;
|
||||
|
||||
var throwEnt = handsComp.GetHand(handsComp.ActiveIndex).Owner;
|
||||
|
||||
if (!handsComp.ThrowItem())
|
||||
return;
|
||||
return false;
|
||||
|
||||
// pop off an item, or throw the single item in hand.
|
||||
if (!throwEnt.TryGetComponent(out StackComponent stackComp) || stackComp.Count < 2)
|
||||
@@ -163,7 +165,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
|
||||
if (!throwEnt.TryGetComponent(out CollidableComponent colComp))
|
||||
return;
|
||||
return true;
|
||||
|
||||
colComp.CollisionEnabled = true;
|
||||
// I can now collide with player, so that i can do damage.
|
||||
@@ -203,7 +205,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
lHomoDir.Normalize();
|
||||
transform.LocalRotation = new Angle(lHomoDir.Xy);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user