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:
parent
6995cd257f
commit
55ca65dbd8
|
|
@ -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<SinkPortPrototype> OnPort = "On";
|
||||
|
||||
/// <summary>
|
||||
/// This is a fixed offset of 5.
|
||||
/// The cook times for all recipes should be divisible by 5,with a minimum of 1 second.
|
||||
|
|
|
|||
|
|
@ -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<MicrowaveComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<MicrowaveComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<MicrowaveComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||
SubscribeLocalEvent<MicrowaveComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(AnchorableSystem) });
|
||||
SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak);
|
||||
|
|
@ -57,6 +64,8 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||
SubscribeLocalEvent<MicrowaveComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
SubscribeLocalEvent<MicrowaveComponent, UpgradeExamineEvent>(OnUpgradeExamine);
|
||||
|
||||
SubscribeLocalEvent<MicrowaveComponent, SignalReceivedEvent>(OnSignalReceived);
|
||||
|
||||
SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u, c, m) => Wzhzhzh(u, c, m.Session.AttachedEntity));
|
||||
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage);
|
||||
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)
|
||||
|
|
@ -277,6 +292,17 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||
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)
|
||||
{
|
||||
var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue