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:
DrSmugleaf
2020-07-27 00:54:32 +02:00
committed by GitHub
parent b9e1f9283d
commit 0a82aba88e
26 changed files with 450 additions and 15 deletions

View File

@@ -52,7 +52,9 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
.Bind(ContentKeyFunctions.ActivateItemInHand, InputCmdHandler.FromDelegate(HandleActivateItem))
.Bind(ContentKeyFunctions.ThrowItemInHand, new PointerInputCmdHandler(HandleThrowItem))
.Bind(ContentKeyFunctions.SmartEquipBackpack, InputCmdHandler.FromDelegate(HandleSmartEquipBackpack))
.Bind(ContentKeyFunctions.SmartEquipBelt, InputCmdHandler.FromDelegate(HandleSmartEquipBelt)).Register<HandsSystem>();
.Bind(ContentKeyFunctions.SmartEquipBelt, InputCmdHandler.FromDelegate(HandleSmartEquipBelt))
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
.Register<HandsSystem>();
}
/// <inheritdoc />
@@ -199,13 +201,16 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
if (plyEnt == null || !plyEnt.IsValid())
return;
if (!plyEnt.TryGetComponent(out HandsComponent handsComp) || !plyEnt.TryGetComponent(out InventoryComponent inventoryComp))
if (!plyEnt.TryGetComponent(out HandsComponent handsComp) ||
!plyEnt.TryGetComponent(out InventoryComponent inventoryComp))
return;
if (!inventoryComp.TryGetSlotItem(equipementSlot, out ItemComponent equipmentItem)
|| !equipmentItem.Owner.TryGetComponent<ServerStorageComponent>(out var storageComponent))
{
_notifyManager.PopupMessage(plyEnt, plyEnt, Loc.GetString("You have no {0} to take something out of!", EquipmentSlotDefines.SlotNames[equipementSlot].ToLower()));
_notifyManager.PopupMessage(plyEnt, plyEnt,
Loc.GetString("You have no {0} to take something out of!",
EquipmentSlotDefines.SlotNames[equipementSlot].ToLower()));
return;
}
@@ -219,7 +224,9 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{
if (storageComponent.StoredEntities.Count == 0)
{
_notifyManager.PopupMessage(plyEnt, plyEnt, Loc.GetString("There's nothing in your {0} to take out!", EquipmentSlotDefines.SlotNames[equipementSlot].ToLower()));
_notifyManager.PopupMessage(plyEnt, plyEnt,
Loc.GetString("There's nothing in your {0} to take out!",
EquipmentSlotDefines.SlotNames[equipementSlot].ToLower()));
}
else
{
@@ -229,5 +236,20 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
}
}
}
private bool HandleMovePulledObject(ICommonSession session, GridCoordinates coords, EntityUid uid)
{
var playerEntity = session.AttachedEntity;
if (playerEntity == null ||
!playerEntity.TryGetComponent<HandsComponent>(out var hands))
{
return false;
}
hands.MovePulledObject(playerEntity.Transform.GridPosition, coords);
return false;
}
}
}