Add untested ToggleJump

This commit is contained in:
NGnius (Graham) 2019-10-25 22:10:48 -04:00
parent a9957f922c
commit 9fcbaa0e6e
5 changed files with 69 additions and 7 deletions

View file

@ -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.

View file

@ -44,6 +44,7 @@ namespace ExtraCommands
static MethodBase TargetMethod(HarmonyInstance instance)
{
Type targetType = Harmony.AccessTools.TypeByName("");
return _ComposeMethodInfo(CommandLineCompositionRoot.Compose<UnityContext<FullGameCompositionRoot>>);
}

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>netstandard2</TargetFramework>
</PropertyGroup>
<ItemGroup>
@ -13,7 +13,7 @@
<HintPath>..\ref\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Facepunch.Steamworks.Win64">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gamecraft\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll</HintPath>
<HintPath>..\ref\Facepunch.Steamworks.Win64.dll</HintPath>
</Reference>
<Reference Include="FullGame">
<HintPath>..\ref\FullGame.dll</HintPath>
@ -27,6 +27,9 @@
<Reference Include="CommandLine">
<HintPath>..\ref\RobocraftX.Common.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Character">
<HintPath>..\ref\RobocraftX.Input.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Multiplayer">
<HintPath>..\ref\RobocraftX.Multiplayer.dll</HintPath>
</Reference>

View file

@ -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<PositionEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP, out blockCount);
for (uint i = 0; i < blockCount; i++)
{
ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(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);
}
}
}

View file

@ -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<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) });
}
}
}