diff --git a/README.md b/README.md index b106b4d..432f654 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Proof of concept mod and reference implementation 1. Patch Gamecraft with [GCIPA](https://git.exmods.org/modtainers/GCIPA). You should download the latest release and extract it to the Gamecraft folder. To patch, drag `Gamecraft.exe` onto `IPA.exe`. You will need to redo this step whenever Gamecraft is updated. -2. Extract the TestMod zip into Gamecraft's `Plugins\` folder (GCIPA should have created this automatically in the previous step). You should see `0Harmony.dll` and `ExtraCommands.dll` in the `Plugins\` folder. If those files are in another folder in `Plugins\` it will not work. +2. Extract the ExtraCommands zip into Gamecraft's `Plugins\` folder (GCIPA should have created this automatically in the previous step). You should see `0Harmony.dll` and `ExtraCommands.dll` in the `Plugins\` folder. If those files are in another folder in `Plugins\` it will not work. 3. Launch Gamecraft. You can check the log file `%APPDATA%\..\LocalLow\FreeJam\RobocraftX\Player.log` to confirm. You should be able to see a message near the top showing how many plugins have been loaded and their names. diff --git a/extracommands/CommandLineCompositionRootSaveCommandPatch.cs b/extracommands/CommandLineCompositionRootSaveCommandPatch.cs index 0e964ad..4ce8510 100644 --- a/extracommands/CommandLineCompositionRootSaveCommandPatch.cs +++ b/extracommands/CommandLineCompositionRootSaveCommandPatch.cs @@ -44,6 +44,7 @@ namespace ExtraCommands static MethodBase TargetMethod(HarmonyInstance instance) { + Type targetType = Harmony.AccessTools.TypeByName(""); return _ComposeMethodInfo(CommandLineCompositionRoot.Compose>); } diff --git a/extracommands/ExtraCommands.csproj b/extracommands/ExtraCommands.csproj index 7b34e8f..258e1be 100644 --- a/extracommands/ExtraCommands.csproj +++ b/extracommands/ExtraCommands.csproj @@ -1,7 +1,7 @@  - net461 + netstandard2 @@ -13,7 +13,7 @@ ..\ref\CommandLine.dll - ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gamecraft\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll + ..\ref\Facepunch.Steamworks.Win64.dll ..\ref\FullGame.dll @@ -27,6 +27,9 @@ ..\ref\RobocraftX.Common.dll + + ..\ref\RobocraftX.Input.dll + ..\ref\RobocraftX.Multiplayer.dll diff --git a/extracommands/MoveBlocksCommandEngine.cs b/extracommands/MoveBlocksCommandEngine.cs index d69452d..35fdad5 100644 --- a/extracommands/MoveBlocksCommandEngine.cs +++ b/extracommands/MoveBlocksCommandEngine.cs @@ -28,17 +28,18 @@ namespace ExtraCommands.Building private void MoveBlocksCommand(float x, float y, float z) { - uint loopCount; - for (loopCount = 0; loopCount < CommonExclusiveGroups.CurrentBlockEntityID; loopCount++) + uint blockCount; + PositionEntityStruct[] posStructs = this.entitiesDB.QueryEntities(CommonExclusiveGroups.OWNED_BLOCKS_GROUP, out blockCount); + for (uint i = 0; i < blockCount; i++) { - ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity(loopCount, CommonExclusiveGroups.OWNED_BLOCKS_GROUP); + ref PositionEntityStruct posStruct = ref posStructs[i]; if (!posStruct.Equals(null) && !posStruct.position.Equals(null)) { posStruct.position.x += x; posStruct.position.y += y; posStruct.position.z += z; } else { - uREPL.Log.Warn("Null position found for ID "+loopCount); + uREPL.Log.Warn("Null position found for position "+i); } } } diff --git a/extracommands/ToggleJumpCommandEngine.cs b/extracommands/ToggleJumpCommandEngine.cs new file mode 100644 index 0000000..0b2f522 --- /dev/null +++ b/extracommands/ToggleJumpCommandEngine.cs @@ -0,0 +1,57 @@ +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] + class ToggleJumpCommandEngine : CustomCommandEngine + { + private static bool isJumpEnabled = false; + public ToggleJumpCommandEngine(UnityContext ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams) + { + } + + public override void Ready() + { + CustomCommandUtility.Register("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) }); + } + } +}