* Add BloodstreamComponent and BloodstreamSystem New component for metabolizing reagents that other organs like the stomach pass their input reagents to. * Change StomachComponent to put ingested reagents in bloodstream after delay Now StomachComponent does not metabolize any reagents. Instead, it tracks how long each reagent has been inside it, and once they pass "digestionDelay" they'll be put inside the bloodstream, where the bloodstream will handle metabolism of the reagent. * Add reagent injectors Injects reagents straight into the bloodstream when used on mobs with bloodstreams. Also allows draw/inject from beakers. Does not support drawing blood/reagents from the bloodstream yet. * Address code review Make use of `Loc` static class instead of using `ILocalizationManager`. Localize InjectorToggleMode enum properly.
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Content.Server.GameObjects.Components.Nutrition;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Systems;
|
|
|
|
namespace Content.Server.GameObjects.EntitySystems
|
|
{
|
|
/// <summary>
|
|
/// Triggers digestion updates on <see cref="StomachComponent"/>
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public class StomachSystem : EntitySystem
|
|
{
|
|
private float _accumulatedFrameTime;
|
|
public override void Initialize()
|
|
{
|
|
EntityQuery = new TypeEntityQuery(typeof(StomachComponent));
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
//Update at most once per second
|
|
_accumulatedFrameTime += frameTime;
|
|
if (_accumulatedFrameTime > 1.0f)
|
|
{
|
|
foreach (var entity in RelevantEntities)
|
|
{
|
|
var comp = entity.GetComponent<StomachComponent>();
|
|
comp.OnUpdate(_accumulatedFrameTime);
|
|
}
|
|
_accumulatedFrameTime = 0.0f;
|
|
}
|
|
}
|
|
}
|
|
}
|