public static Multiple1DInputs Or(this I1DInput thisInput, I1DInput input) { Multiple1DInputs toReturn; if (thisInput is MultiplePressableInputs) { toReturn = (Multiple1DInputs)thisInput; } else { toReturn = new Multiple1DInputs(); toReturn.Inputs.Add(thisInput); } toReturn.Inputs.Add(input); return(toReturn); }
partial void CustomInitializeTopDownInput() { if (InputDevice is Xbox360GamePad gamePad) { shootLeftInput = gamePad.LeftTrigger .Or(gamePad.GetButton(Xbox360GamePad.Button.LeftShoulder)); shootRightInput = gamePad.RightTrigger .Or(gamePad.GetButton(Xbox360GamePad.Button.RightShoulder)); sailTurningInput = gamePad.RightStick.Horizontal; IPressableInput gas = gamePad.GetButton(Xbox360GamePad.Button.B); Gas = new DelegateBasedPressableInput(() => !gas.IsDown, () => gas.WasJustReleased, () => gas.WasJustPressed).To1DInput(); } else if (InputDevice is Keyboard keyboard) { shootLeftInput = keyboard.GetKey(Microsoft.Xna.Framework.Input.Keys.Q) .Or(InputManager.Mouse.GetButton(Mouse.MouseButtons.LeftButton)); shootRightInput = keyboard.GetKey(Microsoft.Xna.Framework.Input.Keys.E) .Or(InputManager.Mouse.GetButton(Mouse.MouseButtons.RightButton)); sailTurningInput = InputManager.Keyboard.Get1DInput(Microsoft.Xna.Framework.Input.Keys.Left, Microsoft.Xna.Framework.Input.Keys.Right); IPressableInput gas = InputManager.Keyboard.GetKey(Microsoft.Xna.Framework.Input.Keys.Space); Gas = new DelegateBasedPressableInput(() => !gas.IsDown, () => gas.WasJustReleased, () => gas.WasJustPressed).To1DInput(); } }