2021-10-29 13:40:15 +01:00
|
|
|
using Content.Server.Chemistry.EntitySystems;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Kitchen.Components;
|
2022-04-15 17:20:20 -04:00
|
|
|
using Content.Server.Popups;
|
2022-05-03 01:43:25 +03:00
|
|
|
using Content.Shared.Destructible;
|
2022-04-15 17:20:20 -04:00
|
|
|
using Content.Shared.Interaction;
|
|
|
|
|
using Content.Shared.Item;
|
2022-05-03 01:43:25 +03:00
|
|
|
using Content.Shared.Kitchen.Components;
|
2022-04-15 17:20:20 -04:00
|
|
|
using Robust.Shared.Player;
|
2020-08-13 22:17:12 +10:00
|
|
|
using JetBrains.Annotations;
|
2020-05-28 15:28:35 -05:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Kitchen.EntitySystems
|
2020-05-28 15:28:35 -05:00
|
|
|
{
|
2020-08-13 22:17:12 +10:00
|
|
|
[UsedImplicitly]
|
|
|
|
|
internal sealed class MicrowaveSystem : EntitySystem
|
2020-05-28 15:28:35 -05:00
|
|
|
{
|
2022-04-15 17:20:20 -04:00
|
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
2021-09-06 15:49:44 +02:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<MicrowaveComponent, SolutionChangedEvent>(OnSolutionChange);
|
2022-04-15 17:20:20 -04:00
|
|
|
SubscribeLocalEvent<MicrowaveComponent, InteractUsingEvent>(OnInteractUsing);
|
2022-05-03 01:43:25 +03:00
|
|
|
SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak);
|
2021-09-06 15:49:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSolutionChange(EntityUid uid, MicrowaveComponent component, SolutionChangedEvent args)
|
|
|
|
|
{
|
|
|
|
|
component.DirtyUi();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 15:28:35 -05:00
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
|
|
|
|
base.Update(frameTime);
|
2021-10-18 14:58:34 +02:00
|
|
|
foreach (var comp in EntityManager.EntityQuery<MicrowaveComponent>())
|
2020-05-28 15:28:35 -05:00
|
|
|
{
|
|
|
|
|
comp.OnUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-15 17:20:20 -04:00
|
|
|
|
|
|
|
|
private void OnInteractUsing(EntityUid uid, MicrowaveComponent component, InteractUsingEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!component.Powered)
|
|
|
|
|
{
|
|
|
|
|
_popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-no-power"), uid, Filter.Entities(args.User));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (component.Broken)
|
|
|
|
|
{
|
|
|
|
|
_popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-broken"), uid, Filter.Entities(args.User));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!HasComp<SharedItemComponent>(args.Used))
|
|
|
|
|
{
|
|
|
|
|
_popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-transfer-fail"), uid, Filter.Entities(args.User));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
component.Storage.Insert(args.Used);
|
|
|
|
|
component.DirtyUi();
|
|
|
|
|
}
|
2022-05-03 01:43:25 +03:00
|
|
|
|
|
|
|
|
private void OnBreak(EntityUid uid, MicrowaveComponent component, BreakageEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
component.Broken = true;
|
|
|
|
|
component.SetAppearance(MicrowaveVisualState.Broken);
|
|
|
|
|
}
|
2020-05-28 15:28:35 -05:00
|
|
|
}
|
|
|
|
|
}
|