mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using Content.Server.Lathe.Components;
|
|
using Content.Shared.Power.EntitySystems;
|
|
|
|
namespace Content.Server.Lathe;
|
|
|
|
/// <summary>
|
|
/// System for handling lathes that are actively producing items.
|
|
/// The component is used more so as a marker for EntityQueryEnumerator,
|
|
/// however it's also used to set the power state of the lathe when producing.
|
|
/// </summary>
|
|
public sealed partial class LatheProducingSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedPowerStateSystem _powerState = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<LatheProducingComponent, ComponentStartup>(OnComponentStartup);
|
|
SubscribeLocalEvent<LatheProducingComponent, ComponentShutdown>(OnComponentShutdown);
|
|
}
|
|
|
|
private void OnComponentShutdown(Entity<LatheProducingComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
// use the Try variant of this here
|
|
// or else you get trolled by AllComponentsOneToOneDeleteTest
|
|
_powerState.TrySetWorkingState(ent.Owner, false);
|
|
}
|
|
|
|
private void OnComponentStartup(Entity<LatheProducingComponent> ent, ref ComponentStartup args)
|
|
{
|
|
_powerState.TrySetWorkingState(ent.Owner, true);
|
|
}
|
|
}
|