Adds movement stress test component.

It moves a lot to stress test moving things.
This commit is contained in:
Pieter-Jan Briers
2020-06-30 18:34:42 +02:00
parent ba09ea2254
commit a66386149d
3 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
namespace Content.Server.GameObjects.Components
{
[RegisterComponent]
public class StressTestMovementComponent : Component
{
public override string Name => "StressTestMovement";
public float Progress { get; set; }
public Vector2 Origin { get; set; }
protected override void Startup()
{
base.Startup();
Origin = Owner.Transform.WorldPosition;
}
}
}

View File

@@ -0,0 +1,43 @@
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);
}
}
}
}

View File

@@ -0,0 +1,7 @@
- type: entity
id: StressTest
name: StressTest
components:
- type: Sprite
texture: Effects/explosion.png
- type: StressTestMovement