diff --git a/Content.Client/_NF/M_Emp/M_EmpGeneratorComponent.cs b/Content.Client/_NF/M_Emp/M_EmpComponent.cs similarity index 62% rename from Content.Client/_NF/M_Emp/M_EmpGeneratorComponent.cs rename to Content.Client/_NF/M_Emp/M_EmpComponent.cs index dd6d3dfa14d..18a740975cd 100644 --- a/Content.Client/_NF/M_Emp/M_EmpGeneratorComponent.cs +++ b/Content.Client/_NF/M_Emp/M_EmpComponent.cs @@ -1,5 +1,8 @@ using Content.Shared._NF.M_Emp; using Robust.Shared.GameStates; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; [NetworkedComponent, RegisterComponent] -public sealed class M_EmpGeneratorComponent : SharedM_EmpGeneratorComponent { } +public sealed class M_EmpGeneratorComponent : SharedM_EmpGeneratorComponent +{ +} diff --git a/Content.Server/_NF/M_Emp/M_EmpGeneratorComponent.cs b/Content.Server/_NF/M_Emp/M_EmpGeneratorComponent.cs index 76a4f9c6bff..65b6513e316 100644 --- a/Content.Server/_NF/M_Emp/M_EmpGeneratorComponent.cs +++ b/Content.Server/_NF/M_Emp/M_EmpGeneratorComponent.cs @@ -1,5 +1,4 @@ using Content.Shared.Radio; -using Content.Shared.Random; using Content.Shared._NF.M_Emp; using Robust.Shared.GameStates; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; @@ -45,22 +44,29 @@ public sealed class M_EmpGeneratorComponent : SharedM_EmpGeneratorComponent /// How long the generator Cooling Down /// [ViewVariables(VVAccess.ReadWrite)] + [DataField("baseCoolingDownTime")] + public TimeSpan BaseCoolingDownTime = TimeSpan.FromSeconds(60); + + /// + /// How long the generator actually has to cooldown after use + /// + [ViewVariables(VVAccess.ReadWrite)] [DataField("coolingDownTime")] public TimeSpan CoolingDownTime = TimeSpan.FromSeconds(60); /// - /// How long the generator has to cool down for after use + /// How long the generator has to recharge after use /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("baseCooldownTime")] - public TimeSpan BaseCooldownTime = TimeSpan.FromSeconds(60); + [DataField("baseRecharging")] + public TimeSpan BaseRecharging = TimeSpan.FromSeconds(60); /// - /// How long the generator actually has to cool down for after use + /// How long the generator actually has to recharge after use /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("cooldownTime")] - public TimeSpan CooldownTime = TimeSpan.FromSeconds(60); + [DataField("Recharging")] + public TimeSpan Recharging = TimeSpan.FromSeconds(60); [DataField("M_EmpChannel", customTypeSerializer: typeof(PrototypeIdSerializer))] public string M_EmpChannel = "Security"; diff --git a/Content.Server/_NF/M_Emp/M_EmpSystem.cs b/Content.Server/_NF/M_Emp/M_EmpSystem.cs index 6b93211be80..2c9a7a0bc37 100644 --- a/Content.Server/_NF/M_Emp/M_EmpSystem.cs +++ b/Content.Server/_NF/M_Emp/M_EmpSystem.cs @@ -11,12 +11,18 @@ using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Prototypes; -using Robust.Shared.Random; using Robust.Shared.Utility; using Content.Server.Chat.Managers; using Content.Server.Station.Systems; using Robust.Shared.Timing; using Content.Server.Emp; +using Content.Shared.DeviceLinking; +using Content.Server.DeviceLinking.Systems; + +// TO ANYONE LOOKING AT THIS CODE, IM SORRY +// This code was reused for the salvage magnet and is a mess right now as it is, it has no known issues with it as for now but its not cleaned as it sould be. +// If you know what you are doing, fix this please to look "usable" +// - Dvir01 namespace Content.Server._NF.M_Emp { @@ -34,6 +40,7 @@ public sealed partial class M_EmpSystem : EntitySystem [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; [Dependency] private readonly EmpSystem _emp = default!; + [Dependency] private readonly DeviceLinkSystem _linker = default!; // TODO: This is probably not compatible with multi-station private readonly Dictionary _M_EmpGridStates = new(); @@ -42,6 +49,7 @@ public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnInit); // TODO make this function later SubscribeLocalEvent(OnInteractHand); SubscribeLocalEvent(OnRefreshParts); SubscribeLocalEvent(OnUpgradeExamine); @@ -89,7 +97,7 @@ private void UpdateChargeStateAppearance(EntityUid uid, TimeSpan currentTime, M_ GeneratorStateType.Inactive => 5, GeneratorStateType.Engaged => timeLeft / (Convert.ToInt32(component.EngagedTime.TotalSeconds) / component.ChargeCapacity) + 1, GeneratorStateType.CoolingDown => 0, - GeneratorStateType.Recharging => component.ChargeCapacity - timeLeft / (Convert.ToInt32(component.CooldownTime.TotalSeconds) / component.ChargeCapacity) - 1, + GeneratorStateType.Recharging => component.ChargeCapacity - timeLeft / (Convert.ToInt32(component.Recharging.TotalSeconds) / component.ChargeCapacity) - 1, _ => component.ChargeRemaining }; @@ -135,13 +143,13 @@ private void OnRefreshParts(EntityUid uid, M_EmpGeneratorComponent component, Re { var rating = args.PartRatings[component.MachinePartDelay] - 1; var factor = MathF.Pow(component.PartRatingDelay, rating); - component.ActivatingTime = component.BaseActivatingTime * factor; - component.CooldownTime = component.BaseCooldownTime * factor; + component.CoolingDownTime = component.BaseCoolingDownTime * factor; + component.Recharging = component.BaseRecharging * factor; } private void OnUpgradeExamine(EntityUid uid, M_EmpGeneratorComponent component, UpgradeExamineEvent args) { - args.AddPercentageUpgrade("m_emp-system-generator-delay-upgrade", (float) (component.CooldownTime / component.BaseCooldownTime)); + args.AddPercentageUpgrade("m_emp-system-generator-delay-upgrade", (float) (component.Recharging / component.BaseRecharging)); } private void OnExamined(EntityUid uid, M_EmpGeneratorComponent component, ExaminedEvent args) @@ -196,6 +204,11 @@ private void OnInteractHand(EntityUid uid, M_EmpGeneratorComponent component, In UpdateAppearance(uid, component); } + private void OnInit(EntityUid uid, SharedM_EmpComponent component, ComponentInit args) + { + _linker.EnsureSinkPorts(uid, component.ReceiverPort); + } + private void StartGenerator(EntityUid uid, M_EmpGeneratorComponent component, EntityUid user) { switch (component.GeneratorState.StateType) @@ -216,10 +229,7 @@ private void StartGenerator(EntityUid uid, M_EmpGeneratorComponent component, En component.GeneratorState = new GeneratorState(GeneratorStateType.Activating, gridState.CurrentTime + component.ActivatingTime); RaiseLocalEvent(new M_EmpGeneratorActivatedEvent(uid)); - var station = _station.GetOwningStation(uid); - var stationName = station is null ? null : Name(station.Value); - - Report(uid, component.M_EmpChannel, "m_emp-system-report-activate-success", ("grid", stationName)); + //Report(uid, component.M_EmpChannel, "m_emp-system-report-activate-success"); Removed to lower spam break; case GeneratorStateType.Activating: @@ -241,7 +251,12 @@ private void ShowPopup(EntityUid uid, string messageKey, EntityUid user) private bool SpawnM_Emp(EntityUid uid, M_EmpGeneratorComponent component) { - Report(uid, component.M_EmpChannel, "m_emp-system-announcement-active", ("timeLeft", component.EngagedTime.TotalSeconds)); + var station = _station.GetOwningStation(uid); + var stationName = station is null ? null : Name(station.Value); + +#pragma warning disable CS8620 // TODO need to fix it later, this is not creating an actual error + Report(uid, component.M_EmpChannel, "m_emp-system-announcement-active", ("timeLeft", component.EngagedTime.TotalSeconds), ("grid", stationName)); +#pragma warning restore CS8620 // TODO need to fix it later, this is not creating an actual error var empRange = 100; var empEnergyConsumption = 50000; @@ -270,7 +285,7 @@ private void Transition(EntityUid uid, M_EmpGeneratorComponent generator, TimeSp } else { - generator.GeneratorState = new GeneratorState(GeneratorStateType.Recharging, currentTime + generator.CooldownTime); + generator.GeneratorState = new GeneratorState(GeneratorStateType.Recharging, currentTime + generator.Recharging); } break; case GeneratorStateType.Engaged: @@ -278,8 +293,8 @@ private void Transition(EntityUid uid, M_EmpGeneratorComponent generator, TimeSp generator.GeneratorState = new GeneratorState(GeneratorStateType.CoolingDown, currentTime + generator.CoolingDownTime); break; case GeneratorStateType.CoolingDown: - //Report(uid, generator.M_EmpChannel, "m_emp-system-announcement-recharging"); //Less chat spam - generator.GeneratorState = new GeneratorState(GeneratorStateType.Recharging, currentTime + generator.CooldownTime); + //Report(uid, generator.M_EmpChannel, "m_emp-system-announcement-recharging"); // Less chat spam + generator.GeneratorState = new GeneratorState(GeneratorStateType.Recharging, currentTime + generator.Recharging); break; case GeneratorStateType.Recharging: generator.GeneratorState = GeneratorState.Inactive; diff --git a/Content.Shared/_NF/M_Emp/SharedM_EmpComponent.cs b/Content.Shared/_NF/M_Emp/SharedM_EmpComponent.cs new file mode 100644 index 00000000000..0f93204cb61 --- /dev/null +++ b/Content.Shared/_NF/M_Emp/SharedM_EmpComponent.cs @@ -0,0 +1,13 @@ +using Content.Shared._NF.M_Emp; +using Robust.Shared.GameStates; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; +using Content.Shared.MachineLinking; + +namespace Content.Shared._NF.M_Emp; + +[NetworkedComponent, RegisterComponent] +public sealed class SharedM_EmpComponent : Component +{ + [DataField("receiverPort", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] + public string ReceiverPort = "M_Emp"; +} diff --git a/Resources/Locale/en-US/_NF/machine-linking/receiver_ports.ftl b/Resources/Locale/en-US/_NF/machine-linking/receiver_ports.ftl new file mode 100644 index 00000000000..90da17cdf23 --- /dev/null +++ b/Resources/Locale/en-US/_NF/machine-linking/receiver_ports.ftl @@ -0,0 +1,2 @@ +signal-port-name-m_emp = M_EMP +signal-port-description-m_emp = Activate the device. \ No newline at end of file diff --git a/Resources/Locale/en-US/m_emp/m_emp-system.ftl b/Resources/Locale/en-US/m_emp/m_emp.ftl similarity index 92% rename from Resources/Locale/en-US/m_emp/m_emp-system.ftl rename to Resources/Locale/en-US/m_emp/m_emp.ftl index 0142a0646ff..4949388230a 100644 --- a/Resources/Locale/en-US/m_emp/m_emp-system.ftl +++ b/Resources/Locale/en-US/m_emp/m_emp.ftl @@ -1,11 +1,11 @@ m_emp-system-announcement-source = M_EMP Generator System -m_emp-system-announcement-active = Activated. Estimated EMP: {$timeLeft} seconds. +m_emp-system-announcement-active = Engaging on {$grid}. EMP: {$timeLeft} seconds. m_emp-system-announcement-cooling-down = EMP effect is no longer active. Estimated Recharging: {$timeLeft} seconds. m_emp-system-announcement-recharging = Recharging. m_emp-system-report-already-active = The M_EMP Generator is already active. m_emp-system-report-cooling-down = The M_EMP Generator is cooling down. -m_emp-system-report-activate-success = The M_EMP Generator engaging on {$grid}! +m_emp-system-report-activate-success = The M_EMP Generator engaging! m_emp-system-generator-examined-inactive = The M_EMP Generator is inactive. m_emp-system-generator-examined-starting = The M_EMP Generator is starting up. diff --git a/Resources/Prototypes/_NF/DeviceLinking/sink_ports.yml b/Resources/Prototypes/_NF/DeviceLinking/sink_ports.yml new file mode 100644 index 00000000000..7523787a58c --- /dev/null +++ b/Resources/Prototypes/_NF/DeviceLinking/sink_ports.yml @@ -0,0 +1,4 @@ +- type: sinkPort + id: M_Emp + name: signal-port-name-m_emp + description: signal-port-description-m_emp \ No newline at end of file diff --git a/Resources/Prototypes/_NF/DeviceLinking/source_ports.yml b/Resources/Prototypes/_NF/DeviceLinking/source_ports.yml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Resources/Prototypes/_NF/Entities/Structures/Machines/m_emp.yml b/Resources/Prototypes/_NF/Entities/Structures/Machines/m_emp.yml index e3def20ab61..b073361de92 100644 --- a/Resources/Prototypes/_NF/Entities/Structures/Machines/m_emp.yml +++ b/Resources/Prototypes/_NF/Entities/Structures/Machines/m_emp.yml @@ -59,6 +59,14 @@ - Security - type: M_EmpGenerator - type: ApcPowerReceiver - powerLoad: 100 # TODO change this to a HV power draw that really hits the grid hard WHEN active + powerLoad: 2500 # TODO change this to a HV power draw that really hits the grid hard WHEN active - type: Machine - board: M_EmpMachineCircuitboard \ No newline at end of file + board: M_EmpMachineCircuitboard + - type: DeviceNetwork + deviceNetId: Wireless + receiveFrequencyId: BasicDevice + - type: WirelessNetworkConnection + range: 200 + - type: DeviceLinkSink + ports: + - M_Emp \ No newline at end of file diff --git a/Resources/Prototypes/_NF/MachineLinking/transmitter_ports.yml b/Resources/Prototypes/_NF/MachineLinking/transmitter_ports.yml new file mode 100644 index 00000000000..e69de29bb2d