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>
This commit is contained in:
deltanedas
2023-11-04 12:44:59 +00:00
committed by GitHub
parent 5a3476f8cc
commit bda8a9c82e
3 changed files with 40 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.Construction.Prototypes; using Content.Shared.Construction.Prototypes;
using Content.Shared.DeviceLinking;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -37,6 +38,9 @@ namespace Content.Server.Kitchen.Components
[ViewVariables] [ViewVariables]
public bool Broken; public bool Broken;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SinkPortPrototype> OnPort = "On";
/// <summary> /// <summary>
/// This is a fixed offset of 5. /// This is a fixed offset of 5.
/// The cook times for all recipes should be divisible by 5,with a minimum of 1 second. /// The cook times for all recipes should be divisible by 5,with a minimum of 1 second.

View File

@@ -1,9 +1,13 @@
using System.Linq; using System.Linq;
using Content.Server.Body.Systems; using Content.Server.Body.Systems;
using Content.Server.Construction; 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.Hands.Systems;
using Content.Server.Kitchen.Components; using Content.Server.Kitchen.Components;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Temperature.Components; using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems; using Content.Server.Temperature.Systems;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
@@ -33,7 +37,9 @@ namespace Content.Server.Kitchen.EntitySystems
{ {
[Dependency] private readonly BodySystem _bodySystem = default!; [Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly ContainerSystem _container = default!; [Dependency] private readonly ContainerSystem _container = default!;
[Dependency] private readonly DeviceLinkSystem _deviceLink = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly PowerReceiverSystem _power = default!;
[Dependency] private readonly RecipeManager _recipeManager = default!; [Dependency] private readonly RecipeManager _recipeManager = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
@@ -49,6 +55,7 @@ namespace Content.Server.Kitchen.EntitySystems
base.Initialize(); base.Initialize();
SubscribeLocalEvent<MicrowaveComponent, ComponentInit>(OnInit); SubscribeLocalEvent<MicrowaveComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<MicrowaveComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<MicrowaveComponent, SolutionChangedEvent>(OnSolutionChange); SubscribeLocalEvent<MicrowaveComponent, SolutionChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<MicrowaveComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(AnchorableSystem) }); SubscribeLocalEvent<MicrowaveComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(AnchorableSystem) });
SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak); SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak);
@@ -57,6 +64,8 @@ namespace Content.Server.Kitchen.EntitySystems
SubscribeLocalEvent<MicrowaveComponent, RefreshPartsEvent>(OnRefreshParts); SubscribeLocalEvent<MicrowaveComponent, RefreshPartsEvent>(OnRefreshParts);
SubscribeLocalEvent<MicrowaveComponent, UpgradeExamineEvent>(OnUpgradeExamine); SubscribeLocalEvent<MicrowaveComponent, UpgradeExamineEvent>(OnUpgradeExamine);
SubscribeLocalEvent<MicrowaveComponent, SignalReceivedEvent>(OnSignalReceived);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u, c, m) => Wzhzhzh(u, c, m.Session.AttachedEntity)); SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u, c, m) => Wzhzhzh(u, c, m.Session.AttachedEntity));
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage); SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectSolidIndexedMessage>(OnEjectIndex); SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectSolidIndexedMessage>(OnEjectIndex);
@@ -172,9 +181,15 @@ namespace Content.Server.Kitchen.EntitySystems
} }
} }
private void OnInit(EntityUid uid, MicrowaveComponent component, ComponentInit ags) private void OnInit(Entity<MicrowaveComponent> ent, ref ComponentInit args)
{ {
component.Storage = _container.EnsureContainer<Container>(uid, "microwave_entity_container"); // this really does have to be in ComponentInit
ent.Comp.Storage = _container.EnsureContainer<Container>(ent, "microwave_entity_container");
}
private void OnMapInit(Entity<MicrowaveComponent> ent, ref MapInitEvent args)
{
_deviceLink.EnsureSinkPorts(ent, ent.Comp.OnPort);
} }
private void OnSuicide(EntityUid uid, MicrowaveComponent component, SuicideEvent args) 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); args.AddPercentageUpgrade("microwave-component-upgrade-cook-time", component.CookTimeMultiplier);
} }
private void OnSignalReceived(Entity<MicrowaveComponent> 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) public void UpdateUserInterfaceState(EntityUid uid, MicrowaveComponent component)
{ {
var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key); var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key);

View File

@@ -33,6 +33,14 @@
False: { visible: false } False: { visible: false }
- type: ActivatableUI - type: ActivatableUI
key: enum.MicrowaveUiKey.Key key: enum.MicrowaveUiKey.Key
- type: DeviceLinkSink
ports:
- On
- type: DeviceNetwork
deviceNetId: Wireless
receiveFrequencyId: BasicDevice
- type: WirelessNetworkConnection
range: 200
- type: UserInterface - type: UserInterface
interfaces: interfaces:
- key: enum.MicrowaveUiKey.Key - key: enum.MicrowaveUiKey.Key