Add client pulling prediction (#2041)

* WIP changes

* Merge conflict fixes

* Bring pull controlelr to current year

* Sync and predict PullController on the client

* Clean imports

* Slow down pullers and make pulling tighter

* Stop pulls on pullable or puller component removals

* Make pulling not occur when moving towards the pulled entity
This commit is contained in:
DrSmugleaf
2020-10-16 20:35:09 +02:00
committed by GitHub
parent 0345fbbd22
commit b1fe4bad01
24 changed files with 734 additions and 341 deletions

View File

@@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Movement;
using Content.Server.GameObjects.Components.Pulling;
using Content.Server.GameObjects.Components.Timing;
using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Shared.GameObjects.Components.Inventory;
@@ -273,12 +274,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
return false;
}
if (!pulledObject.TryGetComponent<PullableComponent>(out var pull))
{
return false;
}
if (!player.TryGetComponent<HandsComponent>(out var hands))
if (!pulledObject.TryGetComponent(out PullableComponent pull))
{
return false;
}
@@ -289,24 +285,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
return false;
}
if (!pull.Owner.TryGetComponent(out IPhysicsComponent physics) ||
physics.Anchored)
{
return false;
}
var controller = physics.EnsureController<PullController>();
if (controller.GettingPulled)
{
hands.StopPull();
}
else
{
hands.StartPull(pull);
}
return false;
return pull.TogglePull(player);
}
private void UserInteraction(IEntity player, EntityCoordinates coordinates, EntityUid clickedUid)

View File

@@ -16,7 +16,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Input.Binding;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
@@ -47,8 +46,6 @@ namespace Content.Server.GameObjects.EntitySystems
.Bind(ContentKeyFunctions.ThrowItemInHand, new PointerInputCmdHandler(HandleThrowItem))
.Bind(ContentKeyFunctions.SmartEquipBackpack, InputCmdHandler.FromDelegate(HandleSmartEquipBackpack))
.Bind(ContentKeyFunctions.SmartEquipBelt, InputCmdHandler.FromDelegate(HandleSmartEquipBelt))
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
.Bind(ContentKeyFunctions.ReleasePulledObject, InputCmdHandler.FromDelegate(HandleReleasePulledObject))
.Register<HandsSystem>();
}
@@ -229,29 +226,5 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
}
private bool HandleMovePulledObject(ICommonSession session, EntityCoordinates coords, EntityUid uid)
{
var playerEntity = session.AttachedEntity;
if (playerEntity == null ||
!playerEntity.TryGetComponent<HandsComponent>(out var hands))
{
return false;
}
hands.MovePulledObject(playerEntity.Transform.Coordinates, coords);
return false;
}
private static void HandleReleasePulledObject(ICommonSession session)
{
if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
return;
handsComp.StopPull();
}
}
}