mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Add assert that function in InputSystem.HandleInputCommand is correct.
This commit is contained in:
@@ -9,6 +9,7 @@ using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Client.GameObjects.EntitySystems
|
||||
{
|
||||
@@ -43,6 +44,13 @@ namespace Robust.Client.GameObjects.EntitySystems
|
||||
/// <param name="message">Arguments for this event.</param>
|
||||
public void HandleInputCommand(ICommonSession session, BoundKeyFunction function, FullInputCmdMessage message)
|
||||
{
|
||||
#if DEBUG
|
||||
|
||||
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(function);
|
||||
DebugTools.Assert(funcId == message.InputFunctionId, "Function ID in message does not match function.");
|
||||
|
||||
#endif
|
||||
|
||||
// set state, state change is updated regardless if it is locally bound
|
||||
_cmdStates.SetState(function, message.State);
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace Robust.Shared.Input
|
||||
/// A networked identifier for a <see cref="BoundKeyFunction"/>.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public struct KeyFunctionId
|
||||
public readonly struct KeyFunctionId : IEquatable<KeyFunctionId>
|
||||
{
|
||||
private int _value;
|
||||
private readonly int _value;
|
||||
|
||||
public KeyFunctionId(int id)
|
||||
{
|
||||
@@ -28,6 +28,31 @@ namespace Robust.Shared.Input
|
||||
{
|
||||
return _value.ToString();
|
||||
}
|
||||
|
||||
public bool Equals(KeyFunctionId other)
|
||||
{
|
||||
return _value == other._value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is KeyFunctionId other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
public static bool operator ==(KeyFunctionId left, KeyFunctionId right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(KeyFunctionId left, KeyFunctionId right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user