Add pulling (#1409)
* Initial framework for pulling. * Make it possible to pull items via (temporary) keybind Ctrl+Click, make items follow the player correctly. * Make other objects pullable, implement functionality for moving an object being pulled, make only one object able to be pulled at a time. * Make sure that MoveTo won't allow collisions with the player * Update everything to work with the new physics engine * Update Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs Co-authored-by: ComicIronic <comicironic@gmail.com> * Physics update and convert to direct type casts * Add notnull checks * Add pull keybinds to the tutorial window * Move PullController to shared * Fix pulled items getting left behind * Fix moving pulled objects into walls * Remove flooring of coordinates when moving pulled objects * Add missing null check in PutInHand * Change pulling keybind to control and throwing to alt * Change PhysicsComponent references to IPhysicsComponent * Add trying to pull a pulled entity disabling the pull * Add pulled status effect * Fix merge conflicts * Merge fixes * Make players pullable * Fix being able to pull yourself * Change pull moving to use a velocity * Update pulled and pulling icons to not be buckle A tragedy * Make pulled and pulling icons more consistent * Remove empty not pulled and not pulling images * Pulled icon update * Pulled icon update * Add clicking pulling status effect to stop the pull * Fix spacewalking when pulling * Merge conflict fixes * Add a pull verb * Fix nullable error * Add pulling through the entity drop down menu Co-authored-by: Jackson Lewis <inquisitivepenguin@protonmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Server.GameObjects.Components.Timing;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||
using Content.Server.Utility;
|
||||
@@ -9,11 +11,13 @@ using Content.Shared.GameObjects.EntitySystemMessages;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.Physics;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -48,6 +52,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
new PointerInputCmdHandler(HandleWideAttack))
|
||||
.Bind(ContentKeyFunctions.ActivateItemInWorld,
|
||||
new PointerInputCmdHandler(HandleActivateItemInWorld))
|
||||
.Bind(ContentKeyFunctions.TryPullObject, new PointerInputCmdHandler(HandleTryPullObject))
|
||||
.Register<InteractionSystem>();
|
||||
}
|
||||
|
||||
@@ -221,6 +226,72 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool HandleTryPullObject(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
{
|
||||
// client sanitization
|
||||
if (!_mapManager.GridExists(coords.GridID))
|
||||
{
|
||||
Logger.InfoS("system.interaction", $"Invalid Coordinates for pulling: client={session}, coords={coords}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uid.IsClientSide())
|
||||
{
|
||||
Logger.WarningS("system.interaction",
|
||||
$"Client sent pull interaction with client-side entity. Session={session}, Uid={uid}");
|
||||
return false;
|
||||
}
|
||||
|
||||
var player = session.AttachedEntity;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
Logger.WarningS("system.interaction",
|
||||
$"Client sent pulling interaction with no attached entity. Session={session}, Uid={uid}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EntityManager.TryGetEntity(uid, out var pulledObject))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player == pulledObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pulledObject.TryGetComponent<PullableComponent>(out var pull))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.TryGetComponent<HandsComponent>(out var hands))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var dist = player.Transform.GridPosition.Position - pulledObject.Transform.GridPosition.Position;
|
||||
if (dist.LengthSquared > InteractionRangeSquared)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var physics = pull.Owner.GetComponent<IPhysicsComponent>();
|
||||
var controller = physics.EnsureController<PullController>();
|
||||
|
||||
if (controller.GettingPulled)
|
||||
{
|
||||
hands.StopPull();
|
||||
}
|
||||
else
|
||||
{
|
||||
hands.StartPull(pull);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UserInteraction(IEntity player, GridCoordinates coordinates, EntityUid clickedUid)
|
||||
{
|
||||
// Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null
|
||||
|
||||
Reference in New Issue
Block a user