Predicts pulling (#12029)
This commit is contained in:
@@ -28,7 +28,6 @@ namespace Content.Server.Interaction
|
|||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
[Dependency] private readonly PullingSystem _pullSystem = default!;
|
|
||||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||||
|
|
||||||
@@ -37,17 +36,6 @@ namespace Content.Server.Interaction
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeNetworkEvent<DragDropRequestEvent>(HandleDragDropRequestEvent);
|
SubscribeNetworkEvent<DragDropRequestEvent>(HandleDragDropRequestEvent);
|
||||||
|
|
||||||
CommandBinds.Builder
|
|
||||||
.Bind(ContentKeyFunctions.TryPullObject,
|
|
||||||
new PointerInputCmdHandler(HandleTryPullObject))
|
|
||||||
.Register<InteractionSystem>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Shutdown()
|
|
||||||
{
|
|
||||||
CommandBinds.Unregister<InteractionSystem>();
|
|
||||||
base.Shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
||||||
@@ -125,28 +113,5 @@ namespace Content.Server.Interaction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
|
||||||
{
|
|
||||||
if (!ValidateClientInput(session, coords, uid, out var userEntity))
|
|
||||||
{
|
|
||||||
Logger.InfoS("system.interaction", $"TryPullObject input validation failed");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userEntity.Value == uid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (Deleted(uid))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!InRangeUnobstructed(userEntity.Value, uid, popup: true))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!TryComp(uid, out SharedPullableComponent? pull))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return _pullSystem.TogglePull(userEntity.Value, pull);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ using Content.Shared.Item;
|
|||||||
using Content.Shared.Movement.Components;
|
using Content.Shared.Movement.Components;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Pulling;
|
||||||
|
using Content.Shared.Pulling.Components;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Content.Shared.Timing;
|
using Content.Shared.Timing;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
@@ -51,6 +53,7 @@ namespace Content.Shared.Interaction
|
|||||||
[Dependency] private readonly SharedVerbSystem _verbSystem = default!;
|
[Dependency] private readonly SharedVerbSystem _verbSystem = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||||
|
[Dependency] private readonly SharedPullingSystem _pullSystem = default!;
|
||||||
|
|
||||||
private const CollisionGroup InRangeUnobstructedMask
|
private const CollisionGroup InRangeUnobstructedMask
|
||||||
= CollisionGroup.Impassable | CollisionGroup.InteractImpassable;
|
= CollisionGroup.Impassable | CollisionGroup.InteractImpassable;
|
||||||
@@ -75,6 +78,8 @@ namespace Content.Shared.Interaction
|
|||||||
new PointerInputCmdHandler(HandleUseInteraction))
|
new PointerInputCmdHandler(HandleUseInteraction))
|
||||||
.Bind(ContentKeyFunctions.ActivateItemInWorld,
|
.Bind(ContentKeyFunctions.ActivateItemInWorld,
|
||||||
new PointerInputCmdHandler(HandleActivateItemInWorld))
|
new PointerInputCmdHandler(HandleActivateItemInWorld))
|
||||||
|
.Bind(ContentKeyFunctions.TryPullObject,
|
||||||
|
new PointerInputCmdHandler(HandleTryPullObject))
|
||||||
.Register<SharedInteractionSystem>();
|
.Register<SharedInteractionSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +120,30 @@ namespace Content.Shared.Interaction
|
|||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||||
|
{
|
||||||
|
if (!ValidateClientInput(session, coords, uid, out var userEntity))
|
||||||
|
{
|
||||||
|
Logger.InfoS("system.interaction", $"TryPullObject input validation failed");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//is this user trying to pull themself?
|
||||||
|
if (userEntity.Value == uid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Deleted(uid))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!InRangeUnobstructed(userEntity.Value, uid, popup: true))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!TryComp(uid, out SharedPullableComponent? pull))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_pullSystem.TogglePull(userEntity.Value, pull);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the event were a client uses an item in their inventory or in their hands, either by
|
/// Handles the event were a client uses an item in their inventory or in their hands, either by
|
||||||
|
|||||||
Reference in New Issue
Block a user