mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
34 lines
1,015 B
C#
34 lines
1,015 B
C#
using Content.Shared.Nutrition.Components;
|
|
|
|
namespace Content.Shared.Nutrition.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// <see cref="SatiationGrantComponent"/>
|
|
/// </summary>
|
|
public sealed partial class SatiationGrantSystem : EntitySystem
|
|
{
|
|
[Dependency] private SatiationSystem _satiation = default!;
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnMapInit(Entity<SatiationGrantComponent> ent, ref MapInitEvent args)
|
|
{
|
|
foreach (var satiation in ent.Comp.Satiation)
|
|
{
|
|
if (!HasComp<SatiationComponent>(ent.Owner))
|
|
continue; //Corvax IPC-fix
|
|
_satiation.AddSatiation(ent.Owner, satiation.Key, satiation.Value);
|
|
}
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnShutdown(Entity<SatiationGrantComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
if (!ent.Comp.RemoveOnShutdown)
|
|
return;
|
|
|
|
foreach (var satiation in ent.Comp.Satiation)
|
|
{
|
|
_satiation.RemoveSatiationType(ent.Owner, satiation.Key);
|
|
}
|
|
}
|
|
}
|