2021-02-27 04:12:09 +01:00
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.DragDrop;
|
2022-02-17 15:40:03 +13:00
|
|
|
using Content.Shared.Interaction;
|
2021-06-09 22:19:39 +02:00
|
|
|
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
|
|
|
|
2022-02-17 15:40:03 +13:00
|
|
|
return EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(eventArgs.Target, eventArgs.Dragged, buckleComponent.Range, predicate: Ignored);
|
2021-01-11 22:14:01 +11:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|