using Content.Shared.Radio; using Content.Shared.Salvage; using Robust.Shared.GameStates; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.Salvage { /// /// A salvage magnet. /// [NetworkedComponent, RegisterComponent] [Access(typeof(SalvageSystem))] public sealed class SalvageMagnetComponent : SharedSalvageMagnetComponent { /// /// Offset relative to magnet used as centre of the placement circle. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("offset")] public Vector2 Offset = Vector2.Zero; // TODO: Maybe specify a direction, and find the nearest edge of the magnets grid the salvage can fit at /// /// Minimum distance from the offset position that will be used as a salvage's spawnpoint. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("offsetRadiusMin")] public float OffsetRadiusMin = 0f; /// /// Maximum distance from the offset position that will be used as a salvage's spawnpoint. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("offsetRadiusMax")] public float OffsetRadiusMax = 0f; /// /// The entity attached to the magnet /// [ViewVariables(VVAccess.ReadOnly)] [DataField("attachedEntity")] public EntityUid? AttachedEntity = null; /// /// Current state of this magnet /// [ViewVariables(VVAccess.ReadOnly)] [DataField("magnetState")] public MagnetState MagnetState = MagnetState.Inactive; /// /// How long it takes for the magnet to pull in the debris /// [ViewVariables(VVAccess.ReadWrite)] [DataField("attachingTime")] public TimeSpan AttachingTime = TimeSpan.FromSeconds(10); /// /// How long the magnet can hold the debris until it starts losing the lock /// [ViewVariables(VVAccess.ReadWrite)] [DataField("holdTime")] public TimeSpan HoldTime = TimeSpan.FromSeconds(10); /// /// How long the magnet can hold the debris while losing the lock /// [ViewVariables(VVAccess.ReadWrite)] [DataField("detachingTime")] public TimeSpan DetachingTime = TimeSpan.FromSeconds(10); /// /// How long the magnet has to cool down after use /// [ViewVariables(VVAccess.ReadWrite)] [DataField("cooldownTime")] public TimeSpan CooldownTime = TimeSpan.FromSeconds(10); [DataField("salvageChannel", customTypeSerializer: typeof(PrototypeIdSerializer))] public string SalvageChannel = "Supply"; /// /// Current how much charge the magnet currently has /// public int ChargeRemaining = 5; /// /// How much capacity the magnet can hold /// public int ChargeCapacity = 5; /// /// Used as a guard to prevent spamming the appearance system /// public int PreviousCharge = 5; } [CopyByRef, DataRecord] public record struct MagnetState(MagnetStateType StateType, TimeSpan Until) { public static readonly MagnetState Inactive = new (MagnetStateType.Inactive, TimeSpan.Zero); }; public sealed class SalvageMagnetActivatedEvent : EntityEventArgs { public EntityUid Magnet; public SalvageMagnetActivatedEvent(EntityUid magnet) { Magnet = magnet; } } public enum MagnetStateType { Inactive, Attaching, Holding, Detaching, CoolingDown, } }