Adds movement stress test component.
It moves a lot to stress test moving things.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Resources/Prototypes/Entities/stressTest.yml
Normal file
7
Resources/Prototypes/Entities/stressTest.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
- type: entity
|
||||
id: StressTest
|
||||
name: StressTest
|
||||
components:
|
||||
- type: Sprite
|
||||
texture: Effects/explosion.png
|
||||
- type: StressTestMovement
|
||||
Reference in New Issue
Block a user