2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2020-10-16 20:35:09 +02:00
|
|
|
using Robust.Shared.Map;
|
2021-03-08 04:09:59 +11:00
|
|
|
using Robust.Shared.Physics.Dynamics.Joints;
|
2020-10-16 20:35:09 +02:00
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Pulling.Components
|
2020-10-16 20:35:09 +02:00
|
|
|
{
|
2021-10-04 16:10:54 +01:00
|
|
|
// Before you try to add another type than SharedPullingStateManagementSystem, consider the can of worms you may be opening!
|
2021-07-12 01:32:10 -07:00
|
|
|
[NetworkedComponent()]
|
2022-06-07 15:26:28 +02:00
|
|
|
[Access(typeof(SharedPullingStateManagementSystem))]
|
2021-10-05 14:29:03 +11:00
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class SharedPullableComponent : Component
|
2020-10-16 20:35:09 +02:00
|
|
|
{
|
2020-11-26 13:48:10 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// The current entity pulling this component.
|
|
|
|
|
/// </summary>
|
2021-12-05 21:02:04 +01:00
|
|
|
public EntityUid? Puller { get; set; }
|
2022-07-29 14:13:43 +12:00
|
|
|
|
2020-11-26 13:48:10 +00:00
|
|
|
/// <summary>
|
2021-10-04 16:10:54 +01:00
|
|
|
/// The pull joint.
|
2020-11-26 13:48:10 +00:00
|
|
|
/// </summary>
|
2022-07-29 14:13:43 +12:00
|
|
|
public string? PullJointId { get; set; }
|
2020-10-16 20:35:09 +02:00
|
|
|
|
2022-02-03 18:40:22 +13:00
|
|
|
public bool BeingPulled => Puller != null;
|
2020-10-16 20:35:09 +02:00
|
|
|
|
2022-06-07 15:26:28 +02:00
|
|
|
[Access(typeof(SharedPullingStateManagementSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
|
2021-11-07 02:16:49 +00:00
|
|
|
public EntityCoordinates? MovingTo { get; set; }
|
2020-10-16 20:35:09 +02:00
|
|
|
|
2022-06-16 05:15:56 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// If the physics component has FixedRotation should we keep it upon being pulled
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Access(typeof(SharedPullingSystem), Other = AccessPermissions.ReadExecute)]
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("fixedRotation")]
|
|
|
|
|
public bool FixedRotationOnPull { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// What the pullable's fixedrotation was set to before being pulled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Access(typeof(SharedPullingSystem), Other = AccessPermissions.ReadExecute)]
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public bool PrevFixedRotation;
|
|
|
|
|
|
2021-10-04 16:10:54 +01:00
|
|
|
protected override void OnRemove()
|
|
|
|
|
{
|
2022-02-03 18:40:22 +13:00
|
|
|
if (Puller != null)
|
2021-10-04 16:10:54 +01:00
|
|
|
{
|
|
|
|
|
// This is absolute paranoia but it's also absolutely necessary. Too many puller state bugs. - 20kdc
|
|
|
|
|
Logger.ErrorS("c.go.c.pulling", "PULLING STATE CORRUPTION IMMINENT IN PULLABLE {0} - OnRemove called when Puller is set!", Owner);
|
|
|
|
|
}
|
2020-10-16 20:35:09 +02:00
|
|
|
base.OnRemove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class PullableComponentState : ComponentState
|
2020-10-16 20:35:09 +02:00
|
|
|
{
|
|
|
|
|
public readonly EntityUid? Puller;
|
|
|
|
|
|
2021-07-12 01:32:10 -07:00
|
|
|
public PullableComponentState(EntityUid? puller)
|
2020-10-16 20:35:09 +02:00
|
|
|
{
|
|
|
|
|
Puller = puller;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-17 00:37:05 +10:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Raised when a request is made to stop pulling an entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class StopPullingEvent : CancellableEntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
public EntityUid? User { get; }
|
|
|
|
|
|
|
|
|
|
public StopPullingEvent(EntityUid? uid = null)
|
|
|
|
|
{
|
|
|
|
|
User = uid;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-16 20:35:09 +02:00
|
|
|
}
|