public PilotActionMap(InputMap <WingsuitAction, ButtonState> buttons, InputMap <WingsuitAction, float> axes, InputMap <WingsuitAction, float> mouseAxes) { _buttons = buttons.Optimize(); _buttonEvents = _buttons .Adapt <WingsuitAction, ButtonState, ButtonEvent>(() => Adapters.ButtonEvents(Clock.FrameCounter)) .Optimize(); _axes = axes.Optimize(); _mouseAxes = mouseAxes.Optimize(); }
public MenuActionMap(Func <Vector2> pollCursor, Func <Vector2> pollDiscreteCursor, InputMap <MenuAction, ButtonState> buttons) { _pollCursor = pollCursor; _pollDiscreteCursor = pollDiscreteCursor; _buttons = buttons.Optimize <MenuAction, ButtonState>(); _buttonEvents = _buttons .Adapt <MenuAction, ButtonState, ButtonEvent>(() => Adapters.ButtonEvents(Clock.FrameCounter)) .Optimize <MenuAction, ButtonEvent>(); }
public static InputMap <CombinedAxisId <TId>, Vector2> ApplyDeadzone <TId>( this InputMap <CombinedAxisId <TId>, Vector2> inputMap, Func <CombinedAxisId <TId>, float> deadzones) { return(inputMap.Adapt((axisId, pollFn) => { float deadzone = deadzones(axisId); if (deadzone > 0.0f) { return pollFn.Adapt(Adapters.StickDeadzone(deadzone)); } return pollFn; })); }
private static InputMap <WingsuitAction, float> ButtonsAsAxes(InputMap <WingsuitAction, ButtonState> inputWithButtonSource, IClock clock) { return(inputWithButtonSource .Adapt <WingsuitAction, ButtonState, float>((id, pollFn) => { if (PilotActionDetails.MappableAxes.Contains(id)) { Func <ButtonState, float> adapter; if (PilotBodyMovementActions.Contains(id)) { adapter = Adapters.Button2AccumulatedAxis(speed: 1, gravity: 1, deltaTime: () => clock.DeltaTime); } else { adapter = Adapters.Button2AccumulatedAxis(speed: 4, gravity: 4, deltaTime: () => clock.DeltaTime); } return pollFn.Adapt(adapter).Cache(() => clock.FrameCount); } return pollFn.Adapt <ButtonState, float>(Adapters.Button2Axis); })); }