Files
tbd-station-14/Content.Server/GameObjects/EntitySystems/StressTestMovementSystem.cs
Pieter-Jan Briers a66386149d Adds movement stress test component.
It moves a lot to stress test moving things.
2020-06-30 18:34:42 +02:00

44 lines
1.2 KiB
C#

using System;
using Content.Server.GameObjects.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Maths;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class StressTestMovementSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery<StressTestMovementComponent>();
}
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var entity in RelevantEntities)
{
var stressTest = entity.GetComponent<StressTestMovementComponent>();
var transform = entity.Transform;
stressTest.Progress += frameTime;
if (stressTest.Progress > 1)
{
stressTest.Progress -= 1;
}
var x = MathF.Sin(stressTest.Progress * MathHelper.TwoPi);
var y = MathF.Cos(stressTest.Progress * MathHelper.TwoPi);
transform.WorldPosition = stressTest.Origin + (new Vector2(x, y) * 5);
}
}
}
}