2020-12-18 20:12:53 +01:00
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.DragDrop;
|
|
|
|
|
using Content.Shared.Interaction;
|
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 12:23:18 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-06-25 15:52:24 +02:00
|
|
|
using Robust.Shared.Serialization;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2021-01-11 22:14:01 +11:00
|
|
|
using Robust.Shared.ViewVariables;
|
2020-06-25 15:52:24 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Buckle.Components
|
2020-06-25 15:52:24 +02:00
|
|
|
{
|
2021-07-12 01:32:10 -07:00
|
|
|
[NetworkedComponent()]
|
2021-10-24 23:43:49 -07:00
|
|
|
public abstract class SharedBuckleComponent : Component, IDraggable
|
2020-06-25 15:52:24 +02:00
|
|
|
{
|
2021-01-11 22:14:01 +11:00
|
|
|
/// <summary>
|
2021-02-12 13:04:19 +01:00
|
|
|
/// The range from which this entity can buckle to a <see cref="SharedStrapComponent"/>.
|
2021-01-11 22:14:01 +11:00
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("range")]
|
|
|
|
|
public float Range { get; protected set; } = SharedInteractionSystem.InteractionRange / 1.4f;
|
2021-01-11 22:14:01 +11:00
|
|
|
|
2020-07-17 10:43:10 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// True if the entity is buckled, false otherwise.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract bool Buckled { get; }
|
2021-02-12 13:04:19 +01:00
|
|
|
|
2020-12-18 20:12:53 +01:00
|
|
|
public EntityUid? LastEntityBuckledTo { get; set; }
|
2020-07-02 23:36:06 +02:00
|
|
|
|
2020-12-18 20:12:53 +01:00
|
|
|
public bool DontCollide { get; set; }
|
2020-10-14 15:24:07 +02:00
|
|
|
|
2021-12-03 11:15:41 -08:00
|
|
|
public abstract bool TryBuckle(EntityUid user, EntityUid to);
|
2020-12-18 20:12:53 +01:00
|
|
|
|
2021-05-22 21:06:40 -07:00
|
|
|
bool IDraggable.CanDrop(CanDropEvent args)
|
2020-10-14 15:24:07 +02:00
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
return IoCManager.Resolve<IEntityManager>().HasComponent<SharedStrapComponent>(args.Target);
|
2020-10-14 15:24:07 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-22 21:06:40 -07:00
|
|
|
bool IDraggable.Drop(DragDropEvent args)
|
2020-10-14 15:24:07 +02:00
|
|
|
{
|
2020-10-17 19:53:52 +11:00
|
|
|
return TryBuckle(args.User, args.Target);
|
2020-10-14 15:24:07 +02:00
|
|
|
}
|
2020-07-17 10:43:10 +02:00
|
|
|
}
|
2020-07-02 23:36:06 +02:00
|
|
|
|
2020-07-17 10:43:10 +02:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class BuckleComponentState : ComponentState
|
|
|
|
|
{
|
2021-07-12 01:32:10 -07:00
|
|
|
public BuckleComponentState(bool buckled, int? drawDepth, EntityUid? lastEntityBuckledTo, bool dontCollide)
|
2020-07-02 23:36:06 +02:00
|
|
|
{
|
2020-07-17 10:43:10 +02:00
|
|
|
Buckled = buckled;
|
|
|
|
|
DrawDepth = drawDepth;
|
2020-12-18 20:12:53 +01:00
|
|
|
LastEntityBuckledTo = lastEntityBuckledTo;
|
|
|
|
|
DontCollide = dontCollide;
|
2020-07-02 23:36:06 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-17 10:43:10 +02:00
|
|
|
public bool Buckled { get; }
|
2020-12-18 20:12:53 +01:00
|
|
|
public EntityUid? LastEntityBuckledTo { get; }
|
|
|
|
|
public bool DontCollide { get; }
|
2020-07-17 10:43:10 +02:00
|
|
|
public int? DrawDepth;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-15 20:04:33 -07:00
|
|
|
public sealed class BuckleChangeEvent : EntityEventArgs
|
2020-07-26 12:12:53 +02:00
|
|
|
{
|
2022-02-15 20:04:33 -07:00
|
|
|
public EntityUid Strap;
|
|
|
|
|
public bool Buckling;
|
2020-07-26 12:12:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-15 20:04:33 -07:00
|
|
|
public enum BuckleVisuals
|
2020-07-26 12:12:53 +02:00
|
|
|
{
|
2022-02-15 20:04:33 -07:00
|
|
|
Buckled
|
2020-07-26 12:12:53 +02:00
|
|
|
}
|
2020-06-25 15:52:24 +02:00
|
|
|
}
|