115 lines
5.8 KiB
C#
115 lines
5.8 KiB
C#
using System;
|
|
|
|
using RobocraftX.Common;
|
|
using RobocraftX.Common.Input;
|
|
using Svelto.ECS;
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
namespace GamecraftModdingAPI.Input
|
|
{
|
|
public static class FakeInput
|
|
{
|
|
private static readonly FakeInputEngine inputEngine = new FakeInputEngine();
|
|
|
|
/// <summary>
|
|
/// Customize the player input.
|
|
/// </summary>
|
|
/// <param name="input">The custom input.</param>
|
|
/// <param name="playerID">The player. Omit this to use the local player.</param>
|
|
public static void CustomInput(InputEntityStruct input, uint playerID = uint.MaxValue)
|
|
{
|
|
if (playerID == uint.MaxValue)
|
|
{
|
|
playerID = inputEngine.GetLocalPlayerID();
|
|
}
|
|
inputEngine.SendCustomInput(input, playerID);
|
|
}
|
|
|
|
public static InputEntityStruct GetInput(uint playerID = uint.MaxValue)
|
|
{
|
|
if (playerID == uint.MaxValue)
|
|
{
|
|
playerID = inputEngine.GetLocalPlayerID();
|
|
}
|
|
return inputEngine.GetInput(playerID);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fake a GUI input.
|
|
/// Omit any parameter you do not want to affect.
|
|
/// Parameters that end with "?" don't do anything... yet.
|
|
/// </summary>
|
|
/// <param name="playerID">The player. Omit this to use the local player.</param>
|
|
/// <param name="hotbar">Select the hotbar slot by number.</param>
|
|
/// <param name="hotbarHand">Select the hotbar hand.</param>
|
|
/// <param name="commandLine">Toggle the command line?</param>
|
|
/// <param name="inventory">Open inventory?</param>
|
|
/// <param name="escape">Open escape menu?</param>
|
|
/// <param name="enter">Page return?</param>
|
|
/// <param name="debug">Toggle debug display?</param>
|
|
/// <param name="next">Select next?</param>
|
|
/// <param name="previous">Select previous?</param>
|
|
/// <param name="tab">Tab?</param>
|
|
/// <param name="colour">Toggle to hotbar colour mode?</param>
|
|
/// <param name="hotbarPage">Select the hotbar page by number?</param>
|
|
/// <param name="quickSave">Quicksave?</param>
|
|
/// <param name="paste">Paste?</param>
|
|
public static void GuiInput(uint playerID = uint.MaxValue, int hotbar = -1, bool hotbarHand = false, bool commandLine = false, bool inventory = false, bool escape = false, bool enter = false, bool debug = false, bool next = false, bool previous = false, bool tab = false, bool colour = false, int hotbarPage = -1, bool quickSave = false, bool paste = false)
|
|
{
|
|
if (playerID == uint.MaxValue)
|
|
{
|
|
playerID = inputEngine.GetLocalPlayerID();
|
|
}
|
|
ref InputEntityStruct currentInput = ref inputEngine.GetInputRef(playerID);
|
|
// set inputs
|
|
switch(hotbar)
|
|
{
|
|
case 0: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_0; break;
|
|
case 1: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_1; break;
|
|
case 2: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_2; break;
|
|
case 3: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_3; break;
|
|
case 4: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_4; break;
|
|
case 5: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_5; break;
|
|
case 6: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_6; break;
|
|
case 7: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_7; break;
|
|
case 8: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_8; break;
|
|
case 9: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_9; break;
|
|
case 10: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_Hand; break;
|
|
default: break;
|
|
}
|
|
if (hotbarHand) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_Hand;
|
|
if (commandLine) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleCommandLine;
|
|
if (inventory) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Inventory;
|
|
if (escape) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Escape;
|
|
if (enter) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Return;
|
|
if (debug) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleDebugDisplay;
|
|
if (next) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.SelectNext;
|
|
if (previous) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.SelectPrev;
|
|
if (tab) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Tab;
|
|
if (colour) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_Colour;
|
|
switch (hotbarPage)
|
|
{
|
|
case 1: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage1; break;
|
|
case 2: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage2; break;
|
|
case 3: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage3; break;
|
|
case 4: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage4; break;
|
|
case 5: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage5; break;
|
|
case 6: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage6; break;
|
|
case 7: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage7; break;
|
|
case 8: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage8; break;
|
|
case 9: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage9; break;
|
|
case 10: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage10; break;
|
|
default: break;
|
|
}
|
|
if (quickSave) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.QuickSave;
|
|
if (paste) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.PasteSelection;
|
|
}
|
|
|
|
public static void Init()
|
|
{
|
|
GameEngineManager.AddGameEngine(inputEngine);
|
|
MenuEngineManager.AddMenuEngine(inputEngine);
|
|
}
|
|
}
|
|
}
|