2020-02-23 19:47:33 -05:00
|
|
|
|
using Content.Server.GameObjects.Components.Metabolism;
|
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
using Robust.Shared.GameObjects.Systems;
|
|
|
|
|
|
|
2020-07-06 14:27:03 -07:00
|
|
|
|
namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
2020-02-23 19:47:33 -05:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Triggers metabolism updates for <see cref="BloodstreamComponent"/>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
|
public class BloodstreamSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
private float _accumulatedFrameTime;
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
EntityQuery = new TypeEntityQuery(typeof(BloodstreamComponent));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Trigger metabolism updates at most once per second
|
|
|
|
|
|
_accumulatedFrameTime += frameTime;
|
|
|
|
|
|
if (_accumulatedFrameTime > 1.0f)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var entity in RelevantEntities)
|
|
|
|
|
|
{
|
|
|
|
|
|
var comp = entity.GetComponent<BloodstreamComponent>();
|
|
|
|
|
|
comp.OnUpdate(_accumulatedFrameTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
_accumulatedFrameTime = 0.0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|