瀏覽代碼

Add untested ToggleJump

tags/v0.0.2
NGnius (Graham) 4 年之前
父節點
當前提交
9fcbaa0e6e
共有 5 個文件被更改,包括 69 次插入7 次删除
  1. +1
    -1
      README.md
  2. +1
    -0
      extracommands/CommandLineCompositionRootSaveCommandPatch.cs
  3. +5
    -2
      extracommands/ExtraCommands.csproj
  4. +5
    -4
      extracommands/MoveBlocksCommandEngine.cs
  5. +57
    -0
      extracommands/ToggleJumpCommandEngine.cs

+ 1
- 1
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.


+ 1
- 0
extracommands/CommandLineCompositionRootSaveCommandPatch.cs 查看文件

@@ -44,6 +44,7 @@ namespace ExtraCommands

static MethodBase TargetMethod(HarmonyInstance instance)
{
Type targetType = Harmony.AccessTools.TypeByName("");
return _ComposeMethodInfo(CommandLineCompositionRoot.Compose<UnityContext<FullGameCompositionRoot>>);
}



+ 5
- 2
extracommands/ExtraCommands.csproj 查看文件

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


+ 5
- 4
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<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);
}
}
}


+ 57
- 0
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<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) });
}
}
}

Loading…
取消
儲存