You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

90 lines
2.5 KiB

using System;
using System.Numerics;
using gaemstone.ECS;
namespace gaemstone.Client.Components;
[Module]
public class InputComponents
{
[Symbol, Path("/Input")]
[Add<Input>]
public struct Input { }
[Symbol, Path("/Input/Mouse")]
[Add<Mouse>]
public struct Mouse { }
[Symbol, Path("/Input/Keyboard")]
[Add<Keyboard>]
public struct Keyboard { }
[Symbol, Tag]
public struct Gamepad { }
/// <summary> Present on inputs / actions that are currently active. </summary>
[Symbol, Component] public struct Active { public TimeSpan Duration; }
/// <summary> Present on inputs / actions were activated this frame. </summary>
[Symbol, Tag] public struct Activated { }
/// <summary> Present on inputs / actions were deactivated this frame. </summary>
[Symbol, Tag] public struct Deactivated { }
/// <summary>
/// Relationship on <see cref="Input"/> which indicates keyboard
/// and gamepad input is currently captured by the target.
/// </summary>
/// <remarks>
/// This is set if a UI element is focused that captures
/// navigational or text input.
/// </remarks>
[Symbol, Relation, Tag, Exclusive]
public struct InputCapturedBy { }
/// <summary>
/// Relationship on <see cref="Input"/> which indicates that mouse
/// input (buttons and wheel) is currently captured by the target.
/// </summary>
/// <remarks>
/// This could for example include the mouse currently being over
/// a UI element, preventing the game from handling mouse input.
/// </remarks>
[Symbol, Relation, Tag, Exclusive]
public struct MouseInputCapturedBy { }
/// <summary>
/// Relationship on <see cref="Input"/> which indicates that the
/// cursor is currently captured by the target, and thus hidden.
/// </summary>
/// <remarks>
/// This is set when a camera controller assumes control of the mouse.
/// </remarks>
[Symbol, Relation, Tag, Exclusive]
[With<InputCapturedBy>]
[With<MouseInputCapturedBy>]
public struct CursorCapturedBy { }
[Component]
internal readonly struct RawValue1D
{
private readonly float _value;
private RawValue1D(float value) => _value = value;
public static implicit operator float(RawValue1D value) => value._value;
public static implicit operator RawValue1D(float value) => new(value);
}
[Component]
internal readonly struct RawValue2D
{
private readonly Vector2 _value;
private RawValue2D(Vector2 value) => _value = value;
public static implicit operator Vector2(RawValue2D value) => value._value;
public static implicit operator RawValue2D(Vector2 value) => new(value);
}
}