From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Sat, 4 Nov 2023 12:44:59 +0000 (+0000) Subject: microwave can be turned on with signal (#21138) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=bda8a9c82e145628f524bb2e7767c9651ad03a62;p=space-station-14.git microwave can be turned on with signal (#21138) * microwave can be turned on with signal * update prototype * mapinit * init for storage --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 538a069d16..56ea23e27e 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -1,4 +1,5 @@ using Content.Shared.Construction.Prototypes; +using Content.Shared.DeviceLinking; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.Prototypes; @@ -37,6 +38,9 @@ namespace Content.Server.Kitchen.Components [ViewVariables] public bool Broken; + [DataField, ViewVariables(VVAccess.ReadWrite)] + public ProtoId OnPort = "On"; + /// /// This is a fixed offset of 5. /// The cook times for all recipes should be divisible by 5,with a minimum of 1 second. diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 1c8dbfb4df..5cee960df8 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -1,9 +1,13 @@ using System.Linq; using Content.Server.Body.Systems; using Content.Server.Construction; +using Content.Server.DeviceLinking.Events; +using Content.Server.DeviceLinking.Systems; +using Content.Server.DeviceNetwork; using Content.Server.Hands.Systems; using Content.Server.Kitchen.Components; using Content.Server.Power.Components; +using Content.Server.Power.EntitySystems; using Content.Server.Temperature.Components; using Content.Server.Temperature.Systems; using Content.Shared.Body.Components; @@ -33,7 +37,9 @@ namespace Content.Server.Kitchen.EntitySystems { [Dependency] private readonly BodySystem _bodySystem = default!; [Dependency] private readonly ContainerSystem _container = default!; + [Dependency] private readonly DeviceLinkSystem _deviceLink = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; + [Dependency] private readonly PowerReceiverSystem _power = default!; [Dependency] private readonly RecipeManager _recipeManager = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; @@ -49,6 +55,7 @@ namespace Content.Server.Kitchen.EntitySystems base.Initialize(); SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnSolutionChange); SubscribeLocalEvent(OnInteractUsing, after: new[] { typeof(AnchorableSystem) }); SubscribeLocalEvent(OnBreak); @@ -57,6 +64,8 @@ namespace Content.Server.Kitchen.EntitySystems SubscribeLocalEvent(OnRefreshParts); SubscribeLocalEvent(OnUpgradeExamine); + SubscribeLocalEvent(OnSignalReceived); + SubscribeLocalEvent((u, c, m) => Wzhzhzh(u, c, m.Session.AttachedEntity)); SubscribeLocalEvent(OnEjectMessage); SubscribeLocalEvent(OnEjectIndex); @@ -172,9 +181,15 @@ namespace Content.Server.Kitchen.EntitySystems } } - private void OnInit(EntityUid uid, MicrowaveComponent component, ComponentInit ags) + private void OnInit(Entity ent, ref ComponentInit args) + { + // this really does have to be in ComponentInit + ent.Comp.Storage = _container.EnsureContainer(ent, "microwave_entity_container"); + } + + private void OnMapInit(Entity ent, ref MapInitEvent args) { - component.Storage = _container.EnsureContainer(uid, "microwave_entity_container"); + _deviceLink.EnsureSinkPorts(ent, ent.Comp.OnPort); } private void OnSuicide(EntityUid uid, MicrowaveComponent component, SuicideEvent args) @@ -277,6 +292,17 @@ namespace Content.Server.Kitchen.EntitySystems args.AddPercentageUpgrade("microwave-component-upgrade-cook-time", component.CookTimeMultiplier); } + private void OnSignalReceived(Entity ent, ref SignalReceivedEvent args) + { + if (args.Port != ent.Comp.OnPort) + return; + + if (ent.Comp.Broken || !_power.IsPowered(ent)) + return; + + Wzhzhzh(ent.Owner, ent.Comp, null); + } + public void UpdateUserInterfaceState(EntityUid uid, MicrowaveComponent component) { var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key); diff --git a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml index 48ac7c3393..0a1a6f431f 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml @@ -33,6 +33,14 @@ False: { visible: false } - type: ActivatableUI key: enum.MicrowaveUiKey.Key + - type: DeviceLinkSink + ports: + - On + - type: DeviceNetwork + deviceNetId: Wireless + receiveFrequencyId: BasicDevice + - type: WirelessNetworkConnection + range: 200 - type: UserInterface interfaces: - key: enum.MicrowaveUiKey.Key