* 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>
123 lines
3.1 KiB
C#
123 lines
3.1 KiB
C#
#nullable enable
|
|
using System;
|
|
using Content.Shared.Physics;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Components;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Shared.GameObjects.Components.Items
|
|
{
|
|
public abstract class SharedHandsComponent : Component, ISharedHandsComponent
|
|
{
|
|
public sealed override string Name => "Hands";
|
|
public sealed override uint? NetID => ContentNetIDs.HANDS;
|
|
|
|
[ViewVariables]
|
|
protected ICollidableComponent? PulledObject;
|
|
|
|
[ViewVariables]
|
|
protected bool IsPulling => PulledObject != null;
|
|
|
|
public virtual void StopPull()
|
|
{
|
|
if (PulledObject != null &&
|
|
PulledObject.TryGetController(out PullController controller))
|
|
{
|
|
controller.StopPull();
|
|
}
|
|
|
|
PulledObject = null;
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public sealed class SharedHand
|
|
{
|
|
public readonly int Index;
|
|
public readonly string Name;
|
|
public readonly EntityUid? EntityUid;
|
|
public readonly HandLocation Location;
|
|
|
|
public SharedHand(int index, string name, EntityUid? entityUid, HandLocation location)
|
|
{
|
|
Index = index;
|
|
Name = name;
|
|
EntityUid = entityUid;
|
|
Location = location;
|
|
}
|
|
}
|
|
|
|
// The IDs of the items get synced over the network.
|
|
[Serializable, NetSerializable]
|
|
public class HandsComponentState : ComponentState
|
|
{
|
|
public readonly SharedHand[] Hands;
|
|
public readonly string? ActiveIndex;
|
|
|
|
public HandsComponentState(SharedHand[] hands, string? activeIndex) : base(ContentNetIDs.HANDS)
|
|
{
|
|
Hands = hands;
|
|
ActiveIndex = activeIndex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// A message that calls the use interaction on an item in hand, presumed for now the interaction will occur only on the active hand.
|
|
/// </summary>
|
|
[Serializable, NetSerializable]
|
|
public class UseInHandMsg : ComponentMessage
|
|
{
|
|
public UseInHandMsg()
|
|
{
|
|
Directed = true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// A message that calls the activate interaction on the item in Index.
|
|
/// </summary>
|
|
[Serializable, NetSerializable]
|
|
public class ActivateInHandMsg : ComponentMessage
|
|
{
|
|
public string Index { get; }
|
|
|
|
public ActivateInHandMsg(string index)
|
|
{
|
|
Directed = true;
|
|
Index = index;
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public class ClientAttackByInHandMsg : ComponentMessage
|
|
{
|
|
public string Index { get; }
|
|
|
|
public ClientAttackByInHandMsg(string index)
|
|
{
|
|
Directed = true;
|
|
Index = index;
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public class ClientChangedHandMsg : ComponentMessage
|
|
{
|
|
public string Index { get; }
|
|
|
|
public ClientChangedHandMsg(string index)
|
|
{
|
|
Directed = true;
|
|
Index = index;
|
|
}
|
|
}
|
|
|
|
public enum HandLocation : byte
|
|
{
|
|
Left,
|
|
Middle,
|
|
Right
|
|
}
|
|
}
|