Files
RobustToolbox/Robust.Client/GameObjects/EntitySystems/EyeUpdateSystem.cs
2022-02-05 19:31:58 +01:00

59 lines
1.9 KiB
C#

using System;
using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
#nullable enable
namespace Robust.Client.GameObjects
{
/// <summary>
/// Updates the position of every Eye every frame, so that the camera follows the player around.
/// </summary>
[UsedImplicitly]
public sealed class EyeUpdateSystem : EntitySystem
{
/// <inheritdoc />
public override void Initialize()
{
base.Initialize();
//WARN: Tightly couples this system with InputSystem, and assumes InputSystem exists and is initialized
CommandBinds.Builder
.Bind(EngineKeyFunctions.CameraRotateRight, new NullInputCmdHandler())
.Bind(EngineKeyFunctions.CameraRotateLeft, new NullInputCmdHandler())
.Register<EyeUpdateSystem>();
// Make sure this runs *after* entities have been moved by interpolation and movement.
UpdatesAfter.Add(typeof(TransformSystem));
UpdatesAfter.Add(typeof(PhysicsSystem));
}
/// <inheritdoc />
public override void Shutdown()
{
//WARN: Tightly couples this system with InputSystem, and assumes InputSystem exists and is initialized
CommandBinds.Unregister<EyeUpdateSystem>();
base.Shutdown();
}
/// <inheritdoc />
public override void FrameUpdate(float frameTime)
{
foreach (var eyeComponent in EntityManager.EntityQuery<EyeComponent>(true))
{
eyeComponent.UpdateEyePosition();
}
}
}
}