2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Interaction;
|
2021-10-07 13:01:27 +02:00
|
|
|
using Content.Shared.Tools;
|
2021-11-09 08:08:30 +01:00
|
|
|
using Robust.Shared.Analyzers;
|
2019-11-06 17:22:55 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2021-10-07 13:01:27 +02:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
2020-09-08 13:30:22 +02:00
|
|
|
using Robust.Shared.ViewVariables;
|
2019-11-06 17:22:55 +01:00
|
|
|
|
2021-06-19 19:41:26 -07:00
|
|
|
namespace Content.Server.Construction.Components
|
2019-11-06 17:22:55 +01:00
|
|
|
{
|
2021-05-16 22:33:21 +02:00
|
|
|
// TODO: Move this component's logic to an EntitySystem.
|
2021-11-09 08:08:30 +01:00
|
|
|
[RegisterComponent, Friend(typeof(AnchorableSystem))]
|
|
|
|
|
public class AnchorableComponent : Component
|
2019-11-06 17:22:55 +01:00
|
|
|
{
|
2020-04-29 13:43:07 +02:00
|
|
|
public override string Name => "Anchorable";
|
2019-11-06 17:22:55 +01:00
|
|
|
|
2021-10-07 13:01:27 +02:00
|
|
|
[DataField("tool", customTypeSerializer:typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
|
|
|
|
|
public string Tool { get; private set; } = "Anchoring";
|
2020-10-08 17:41:23 +02:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("snap")]
|
2021-11-09 08:08:30 +01:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-04-02 02:29:49 -07:00
|
|
|
public bool Snap { get; private set; } = true;
|
2019-11-06 17:22:55 +01:00
|
|
|
}
|
2021-04-13 13:18:20 +02:00
|
|
|
|
2021-05-16 22:33:21 +02:00
|
|
|
public abstract class BaseAnchoredAttemptEvent : CancellableEntityEventArgs
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public EntityUid User { get; }
|
|
|
|
|
public EntityUid Tool { get; }
|
2021-04-13 13:18:20 +02:00
|
|
|
|
2021-06-03 09:40:56 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Extra delay to add to the do_after.
|
|
|
|
|
/// Add to this, don't replace it.
|
|
|
|
|
/// Output parameter.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Delay { get; set; } = 0f;
|
|
|
|
|
|
2021-11-09 08:08:30 +01:00
|
|
|
protected BaseAnchoredAttemptEvent(EntityUid user, EntityUid tool)
|
2021-05-16 22:33:21 +02:00
|
|
|
{
|
|
|
|
|
User = user;
|
|
|
|
|
Tool = tool;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AnchorAttemptEvent : BaseAnchoredAttemptEvent
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public AnchorAttemptEvent(EntityUid user, EntityUid tool) : base(user, tool) { }
|
2021-05-16 22:33:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UnanchorAttemptEvent : BaseAnchoredAttemptEvent
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public UnanchorAttemptEvent(EntityUid user, EntityUid tool) : base(user, tool) { }
|
2021-05-16 22:33:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class BaseAnchoredEvent : EntityEventArgs
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public EntityUid User { get; }
|
|
|
|
|
public EntityUid Tool { get; }
|
2021-05-16 22:33:21 +02:00
|
|
|
|
2021-11-09 08:08:30 +01:00
|
|
|
protected BaseAnchoredEvent(EntityUid user, EntityUid tool)
|
2021-05-16 22:33:21 +02:00
|
|
|
{
|
|
|
|
|
User = user;
|
|
|
|
|
Tool = tool;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 09:35:49 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Raised just before the entity's body type is changed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class BeforeAnchoredEvent : BaseAnchoredEvent
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public BeforeAnchoredEvent(EntityUid user, EntityUid tool) : base(user, tool) { }
|
2021-06-03 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-16 22:33:21 +02:00
|
|
|
public class AnchoredEvent : BaseAnchoredEvent
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public AnchoredEvent(EntityUid user, EntityUid tool) : base(user, tool) { }
|
2021-05-16 22:33:21 +02:00
|
|
|
}
|
|
|
|
|
|
2021-06-03 09:35:49 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Raised just before the entity's body type is changed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class BeforeUnanchoredEvent : BaseAnchoredEvent
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public BeforeUnanchoredEvent(EntityUid user, EntityUid tool) : base(user, tool) { }
|
2021-06-03 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-16 22:33:21 +02:00
|
|
|
public class UnanchoredEvent : BaseAnchoredEvent
|
|
|
|
|
{
|
2021-11-09 08:08:30 +01:00
|
|
|
public UnanchoredEvent(EntityUid user, EntityUid tool) : base(user, tool) { }
|
2021-05-16 22:33:21 +02:00
|
|
|
}
|
2019-11-06 17:22:55 +01:00
|
|
|
}
|