Files
OldThink/Content.Server/Ame/EntitySystems/AmeFuelSystem.cs

31 lines
980 B
C#
Raw Normal View History

2023-06-28 05:02:06 -07:00
using Content.Server.Ame.Components;
using Content.Shared.Examine;
2023-06-28 05:02:06 -07:00
namespace Content.Server.Ame.EntitySystems;
/// <summary>
/// Adds fuel level info to examine on fuel jars and handles network state.
/// </summary>
2023-06-28 05:02:06 -07:00
public sealed class AmeFuelSystem : EntitySystem
{
2023-06-28 05:02:06 -07:00
public override void Initialize()
{
2023-06-28 05:02:06 -07:00
base.Initialize();
SubscribeLocalEvent<AmeFuelContainerComponent, ExaminedEvent>(OnFuelExamined);
}
2023-06-28 05:02:06 -07:00
private void OnFuelExamined(EntityUid uid, AmeFuelContainerComponent comp, ExaminedEvent args)
{
if (!args.IsInDetailsRange)
return;
// less than 25%: amount < capacity / 4 = amount * 4 < capacity
var low = comp.FuelAmount * 4 < comp.FuelCapacity;
args.PushMarkup(Loc.GetString("ame-fuel-container-component-on-examine-detailed-message",
("colorName", low ? "darkorange" : "orange"),
("amount", comp.FuelAmount),
("capacity", comp.FuelCapacity)));
}
}