2023-09-23 03:10:04 +01:00
|
|
|
using Content.Server.Chemistry.EntitySystems;
|
2024-02-13 17:08:07 -05:00
|
|
|
using Content.Shared.Nutrition.EntitySystems;
|
2023-09-23 03:10:04 +01:00
|
|
|
using Content.Shared.Nutrition.Components;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Nutrition.EntitySystems;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides API for openable food and drinks, handles opening on use and preventing transfer when closed.
|
|
|
|
|
/// </summary>
|
2024-02-13 17:08:07 -05:00
|
|
|
public sealed class OpenableSystem : SharedOpenableSystem
|
2023-09-23 03:10:04 +01:00
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<OpenableComponent, SolutionTransferAttemptEvent>(OnTransferAttempt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnTransferAttempt(EntityUid uid, OpenableComponent comp, SolutionTransferAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!comp.Opened)
|
|
|
|
|
{
|
|
|
|
|
// message says its just for drinks, shouldn't matter since you typically dont have a food that is openable and can be poured out
|
|
|
|
|
args.Cancel(Loc.GetString("drink-component-try-use-drink-not-open", ("owner", uid)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|