2021-02-27 04:12:09 +01:00
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.DragDrop;
|
|
|
|
|
using Content.Shared.Interaction.Helpers;
|
2020-06-25 15:52:24 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2021-12-03 14:17:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-06-25 15:52:24 +02:00
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Buckle.Components
|
2020-06-25 15:52:24 +02:00
|
|
|
{
|
|
|
|
|
public enum StrapPosition
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// (Default) Makes no change to the buckled mob
|
|
|
|
|
/// </summary>
|
|
|
|
|
None = 0,
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Makes the mob stand up
|
|
|
|
|
/// </summary>
|
|
|
|
|
Stand,
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Makes the mob lie down
|
|
|
|
|
/// </summary>
|
|
|
|
|
Down
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 01:32:10 -07:00
|
|
|
[NetworkedComponent()]
|
2021-01-11 22:14:01 +11:00
|
|
|
public abstract class SharedStrapComponent : Component, IDragDropOn
|
2020-06-25 15:52:24 +02:00
|
|
|
{
|
2021-05-22 21:06:40 -07:00
|
|
|
bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs)
|
2021-01-11 22:14:01 +11:00
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Dragged, out SharedBuckleComponent? buckleComponent)) return false;
|
2021-12-04 12:47:09 +01:00
|
|
|
bool Ignored(EntityUid entity) => entity == eventArgs.User || entity == eventArgs.Dragged || entity == eventArgs.Target;
|
2021-01-11 22:14:01 +11:00
|
|
|
|
|
|
|
|
return eventArgs.Target.InRangeUnobstructed(eventArgs.Dragged, buckleComponent.Range, predicate: Ignored);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-22 21:06:40 -07:00
|
|
|
public abstract bool DragDropOn(DragDropEvent eventArgs);
|
2020-07-07 00:04:30 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-26 12:12:53 +02:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class StrapComponentState : ComponentState
|
|
|
|
|
{
|
2021-07-12 01:32:10 -07:00
|
|
|
public StrapComponentState(StrapPosition position)
|
2020-07-26 12:12:53 +02:00
|
|
|
{
|
|
|
|
|
Position = position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The change in position that this strap makes to the strapped mob
|
|
|
|
|
/// </summary>
|
|
|
|
|
public StrapPosition Position { get; }
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 00:04:30 +02:00
|
|
|
[Serializable, NetSerializable]
|
2021-12-29 15:57:20 +11:00
|
|
|
public enum StrapVisuals : byte
|
2020-07-07 00:04:30 +02:00
|
|
|
{
|
2021-12-29 15:57:20 +11:00
|
|
|
RotationAngle,
|
|
|
|
|
BuckledState
|
2020-06-25 15:52:24 +02:00
|
|
|
}
|
2020-07-26 12:12:53 +02:00
|
|
|
|
2021-12-29 15:57:20 +11:00
|
|
|
// TODO : Convert this to an Entity Message. Careful, it will Break ShuttleControllerComponent (only place where it's used)
|
2020-07-26 12:12:53 +02:00
|
|
|
[Serializable, NetSerializable]
|
2021-10-27 18:10:40 +02:00
|
|
|
#pragma warning disable 618
|
2020-07-26 12:12:53 +02:00
|
|
|
public abstract class StrapChangeMessage : ComponentMessage
|
2021-10-27 18:10:40 +02:00
|
|
|
#pragma warning restore 618
|
2020-07-26 12:12:53 +02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a new instance of <see cref="StrapChangeMessage"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity">The entity that had its buckling status changed</param>
|
|
|
|
|
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
|
|
|
|
|
/// <param name="buckled">True if the entity was buckled, false otherwise</param>
|
2021-12-04 12:47:09 +01:00
|
|
|
protected StrapChangeMessage(EntityUid entity, EntityUid strap, bool buckled)
|
2020-07-26 12:12:53 +02:00
|
|
|
{
|
|
|
|
|
Entity = entity;
|
|
|
|
|
Strap = strap;
|
|
|
|
|
Buckled = buckled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The entity that had its buckling status changed
|
|
|
|
|
/// </summary>
|
2021-12-04 12:47:09 +01:00
|
|
|
public EntityUid Entity { get; }
|
2020-07-26 12:12:53 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The strap that the entity was buckled to or unbuckled from
|
|
|
|
|
/// </summary>
|
2021-12-04 12:47:09 +01:00
|
|
|
public EntityUid Strap { get; }
|
2020-07-26 12:12:53 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// True if the entity was buckled, false otherwise.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Buckled { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class StrapMessage : StrapChangeMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a new instance of <see cref="StrapMessage"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity">The entity that had its buckling status changed</param>
|
|
|
|
|
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
|
2021-12-04 12:47:09 +01:00
|
|
|
public StrapMessage(EntityUid entity, EntityUid strap) : base(entity, strap, true)
|
2020-07-26 12:12:53 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public class UnStrapMessage : StrapChangeMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a new instance of <see cref="UnStrapMessage"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity">The entity that had its buckling status changed</param>
|
|
|
|
|
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
|
2021-12-04 12:47:09 +01:00
|
|
|
public UnStrapMessage(EntityUid entity, EntityUid strap) : base(entity, strap, false)
|
2020-07-26 12:12:53 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-25 15:52:24 +02:00
|
|
|
}
|