Files
tbd-station-14/Content.Shared/Nutrition/EntitySystems/SealableSystem.cs
deltanedas 1db178b632 scoopable ash and foam, solution transfer prediction (#25832)
* move SolutionTransfer to shared and predict as much as possible

* fully move OpenableSystem to shared now that SolutionTransfer is

* fix imports for everything

* doc for solution transfer system

* trolling

* add scoopable system

* make ash and foam scoopable

* untroll

* untroll real

* make clickable it work

* troll

* the scooping room

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-04-01 17:27:39 +11:00

60 lines
1.8 KiB
C#

using Content.Shared.Examine;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Nutrition.Components;
namespace Content.Shared.Nutrition.EntitySystems;
public sealed partial class SealableSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SealableComponent, ExaminedEvent>(OnExamined, after: new[] { typeof(OpenableSystem) });
SubscribeLocalEvent<SealableComponent, OpenableOpenedEvent>(OnOpened);
}
private void OnExamined(EntityUid uid, SealableComponent comp, ExaminedEvent args)
{
if (!args.IsInDetailsRange)
return;
var sealedText = comp.Sealed ? Loc.GetString(comp.ExamineTextSealed) : Loc.GetString(comp.ExamineTextUnsealed);
args.PushMarkup(sealedText);
}
private void OnOpened(EntityUid uid, SealableComponent comp, OpenableOpenedEvent args)
{
comp.Sealed = false;
Dirty(uid, comp);
UpdateAppearance(uid, comp);
}
/// <summary>
/// Update seal visuals to the current value.
/// </summary>
public void UpdateAppearance(EntityUid uid, SealableComponent? comp = null, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref comp))
return;
_appearance.SetData(uid, SealableVisuals.Sealed, comp.Sealed, appearance);
}
/// <summary>
/// Returns true if the entity's seal is intact.
/// Items without SealableComponent are considered unsealed.
/// </summary>
public bool IsSealed(EntityUid uid, SealableComponent? comp = null)
{
if (!Resolve(uid, ref comp, false))
return false;
return comp.Sealed;
}
}