using Content.Shared.Radio; using Content.Shared.Random; 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 partial class SalvageMagnetComponent : SharedSalvageMagnetComponent { /// /// Maximum distance from the offset position that will be used as a salvage's spawnpoint. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("offsetRadiusMax")] public float OffsetRadiusMax = 32; /// /// The entity attached to the magnet /// [ViewVariables(VVAccess.ReadOnly)] [DataField("attachedEntity")] public EntityUid? AttachedEntity; /// /// 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("baseAttachingTime")] public TimeSpan BaseAttachingTime = TimeSpan.FromSeconds(30); /// /// How long it actually takes for the magnet to pull in the debris /// [ViewVariables(VVAccess.ReadWrite)] [DataField("attachingTime")] public TimeSpan AttachingTime = TimeSpan.FromSeconds(30); /// /// How long the magnet can hold the debris until it starts losing the lock /// [ViewVariables(VVAccess.ReadWrite)] [DataField("holdTime")] public TimeSpan HoldTime = TimeSpan.FromSeconds(240); /// /// How long the magnet can hold the debris while losing the lock /// [ViewVariables(VVAccess.ReadWrite)] [DataField("detachingTime")] public TimeSpan DetachingTime = TimeSpan.FromSeconds(30); /// /// How long the magnet has to cool down for after use /// [ViewVariables(VVAccess.ReadWrite)] [DataField("baseCooldownTime")] public TimeSpan BaseCooldownTime = TimeSpan.FromSeconds(60); /// /// How long the magnet actually has to cool down for after use /// [ViewVariables(VVAccess.ReadWrite)] [DataField("cooldownTime")] public TimeSpan CooldownTime = TimeSpan.FromSeconds(60); [DataField("salvageChannel", customTypeSerializer: typeof(PrototypeIdSerializer))] public string SalvageChannel = "Supply"; /// /// Current how much charge the magnet currently has /// [DataField("chargeRemaining")] public int ChargeRemaining = 5; /// /// How much capacity the magnet can hold /// [DataField("chargeCapacity")] public int ChargeCapacity = 5; /// /// Used as a guard to prevent spamming the appearance system /// [DataField("previousCharge")] public int PreviousCharge = 5; /// /// The chance that a random procgen asteroid will be /// generated rather than a static salvage prototype. /// [DataField("asteroidChance"), ViewVariables(VVAccess.ReadWrite)] public float AsteroidChance = 0.6f; /// /// A weighted random prototype corresponding to /// what asteroid entities will be generated. /// [DataField("asteroidPool", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] public string AsteroidPool = "RandomAsteroidPool"; } [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, } }