|
- using System;
- using System.Reflection;
- using Harmony;
- using RobocraftX.GUI.CommandLine;
- using RobocraftX.Multiplayer;
- using RobocraftX.StateSync;
- using RobocraftX.Character;
- using RobocraftX.Character.Movement;
- using RobocraftX.Common.Input;
- using Svelto.ECS;
- using Unity.Entities;
- using UnityEngine;
- using uREPL;
- using Svelto.Context;
- using RobocraftX;
-
- namespace ExtraCommands.Basics
- {
- //[HarmonyPatch]
- //[CustomCommand("ToggleJumpEnabled")]
- class ToggleJumpCommandEngine : CustomCommandEngine
- {
- private static bool isJumpEnabled = false;
- public ToggleJumpCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
- {
- }
-
- public override void Ready()
- {
- CustomCommandUtility.Register<bool>("ToggleJumpEnabled", ToggleJumpCommand, "Enable or disable the character's ability to jump");
- }
-
- private void ToggleJumpCommand(bool isEnabled)
- {
- isJumpEnabled = isEnabled;
- }
-
- public override void Dispose()
- {
- CustomCommandUtility.Unregister("ToggleJumpEnabled");
- }
-
- public static void Postfix (ref CharacterInputEntityStruct input, InputStruct entity)
- {
- if (entity.CheckInputAction(ActionInput.Up) && !isJumpEnabled)
- {
- input.action.y -= 1f;
- }
- }
-
- public static MethodBase TargetMethod(HarmonyInstance instance)
- {
- Type targetType = Harmony.AccessTools.TypeByName("RobocraftX.Character.Input.CharacterInputEngine");
- return Harmony.AccessTools.Method(targetType, "SaveInput", new Type[] { typeof(CharacterInputEntityStruct), typeof(InputStruct) });
- }
- }
- }
|