Files
RobustToolbox/SS14.Client/GameObjects/EntitySystems/InputSystem.cs
Dumplin cd74d12812 Fixed Movement; Edited OSX error message; Fixed some Sonar complaints (#410)
* * CluwneLib.cs: Make _window a local variable

* BaseCollection.cs: Formatting issue

* BaseServer.cs: Removed unused parameter

* ChatManager.cs: Made public encapsulated fields

* BoundKeyEventArgs.cs: Public encapsulated parameters

* CVarFlags.cs: Explicit variable setting

* ComponentFactory.cs: unused variable

* * CluwneLib.cs: Make _window a local variable

* BaseCollection.cs: Formatting issue

* BaseServer.cs: Removed unused parameter

* ChatManager.cs: Made public encapsulated fields

* BoundKeyEventArgs.cs: Public encapsulated parameters

* CVarFlags.cs: Explicit variable setting

* ComponentFactory.cs: unused variable

* CVar fixes

* Edited the OSX error message to be a little more helpful. (You have to edit the .dylibs because they come broken).

* Fixing the sprite movement problem

* Reverted error message

* Revert Again
2017-09-11 09:43:21 -06:00

53 lines
1.7 KiB
C#

using SS14.Shared;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.System;
using System;
using System.Collections.Generic;
namespace SS14.Client.GameObjects.EntitySystems
{
public class InputSystem : EntitySystem
{
/// <summary>
/// Default constructor.
/// </summary>
public InputSystem()
{
EntityQuery = new ComponentEntityQuery()
{
OneSet = new List<Type>()
{
typeof(KeyBindingInputComponent),
},
};
}
/// <inheritdoc />
public override void Update(float frameTime)
{
var entities = EntityManager.GetEntities(EntityQuery);
foreach (var entity in entities)
{
var inputs = entity.GetComponent<KeyBindingInputComponent>();
//Animation setting
if (entity.TryGetComponent<AnimatedSpriteComponent>(out var component))
{
//Char is moving
if (inputs.GetKeyState(BoundKeyFunctions.MoveRight) ||
inputs.GetKeyState(BoundKeyFunctions.MoveDown) ||
inputs.GetKeyState(BoundKeyFunctions.MoveLeft) ||
inputs.GetKeyState(BoundKeyFunctions.MoveUp))
{
component.SetAnimationState(inputs.GetKeyState(BoundKeyFunctions.Run) ? "run" : "walk");
}
//Char is not moving
else
{
component.SetAnimationState("idle");
}
}
}
}
}
}