@@ -7,21 +7,36 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public class SingularitySystem : EntitySystem
|
||||
{
|
||||
private float _accumulator;
|
||||
private float curTimeSingulo;
|
||||
private float curTimePull;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
_accumulator += frameTime;
|
||||
curTimeSingulo += frameTime;
|
||||
curTimePull += frameTime;
|
||||
|
||||
while (_accumulator > 1.0f)
|
||||
var shouldUpdate = curTimeSingulo >= 1f;
|
||||
var shouldPull = curTimePull >= 0.2f;
|
||||
if (!shouldUpdate && !shouldPull) return;
|
||||
var singulos = ComponentManager.EntityQuery<SingularityComponent>(true);
|
||||
|
||||
if (curTimeSingulo >= 1f)
|
||||
{
|
||||
_accumulator -= 1.0f;
|
||||
|
||||
foreach (var singularity in ComponentManager.EntityQuery<SingularityComponent>())
|
||||
curTimeSingulo -= 1f;
|
||||
foreach (var singulo in singulos)
|
||||
{
|
||||
singularity.Update(1);
|
||||
singulo.Update();
|
||||
}
|
||||
}
|
||||
|
||||
if (curTimePull >= 0.5f)
|
||||
{
|
||||
curTimePull -= 0.5f;
|
||||
foreach (var singulo in singulos)
|
||||
{
|
||||
singulo.PullUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user