Ver código fonte

Update compatibility to Gamecraft v2019.10.23.16.11

tags/v0.0.2
NGnius 4 anos atrás
pai
commit
a9957f922c
12 arquivos alterados com 90 adições e 42 exclusões
  1. +7
    -9
      extracommands/ChainCommandEngine.cs
  2. +4
    -8
      extracommands/CommandLineCompositionRootSaveCommandPatch.cs
  3. +1
    -3
      extracommands/CustomCommandAttribute.cs
  4. +1
    -1
      extracommands/CustomCommandEngine.cs
  5. +54
    -0
      extracommands/CustomCommandUtility.cs
  6. +3
    -3
      extracommands/ExitCommandEngine.cs
  7. +4
    -1
      extracommands/ExtraCommands.csproj
  8. +2
    -2
      extracommands/MoveBlocksCommandEngine.cs
  9. +3
    -3
      extracommands/SetFOVCommandEngine.cs
  10. +3
    -3
      extracommands/SetTargetFramerateCommandEngine.cs
  11. +5
    -6
      extracommands/TeleportWaypointCommandEngine.cs
  12. +3
    -3
      extracommands/WaitCommandEngine.cs

+ 7
- 9
extracommands/ChainCommandEngine.cs Ver arquivo

@@ -12,9 +12,7 @@ using RobocraftX;

namespace ExtraCommands.Basics
{
[CustomCommand("Chain", "Run two commands, one after the other")]
[CustomCommand("ChainNoFail", "Run two commands, one after the other even if the first one is invalid")]
[CustomCommand("ChainQuiet", "Run two commands, one after the other quietly")]
[CustomCommand]
class ChainCommandEngine : CustomCommandEngine
{
public ChainCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
@@ -23,9 +21,9 @@ namespace ExtraCommands.Basics

public override void Ready()
{
uREPL.RuntimeCommands.Register<string, string>("Chain", ChainCommand, "Run two commands, one after the other");
uREPL.RuntimeCommands.Register<string, string>("ChainNoFail", ChainNoFailCommand, "Run two commands, one after the other even if the first one is invalid");
uREPL.RuntimeCommands.Register<string, string>("ChainQuiet", ChainQuietCommand, "Run two commands, one after the other quietly");
CustomCommandUtility.Register<string, string>("Chain", ChainCommand, "Run two commands, one after the other");
CustomCommandUtility.Register<string, string>("ChainNoFail", ChainNoFailCommand, "Run two commands, one after the other even if the first one is invalid");
CustomCommandUtility.Register<string, string>("ChainQuiet", ChainQuietCommand, "Run two commands, one after the other quietly");
}

private void ChainCommand(string command1, string command2)
@@ -90,9 +88,9 @@ namespace ExtraCommands.Basics

public override void Dispose()
{
uREPL.RuntimeCommands.Unregister("Chain");
uREPL.RuntimeCommands.Unregister("ChainNoFail");
uREPL.RuntimeCommands.Unregister("ChainQuiet");
CustomCommandUtility.Unregister("Chain");
CustomCommandUtility.Unregister("ChainNoFail");
CustomCommandUtility.Unregister("ChainQuiet");
}
}
}

+ 4
- 8
extracommands/CommandLineCompositionRootSaveCommandPatch.cs Ver arquivo

@@ -16,7 +16,6 @@ namespace ExtraCommands
{
static void Postfix(UnityContext<FullGameCompositionRoot> contextHolder, EnginesRoot enginesRoot, World physicsWorld, Action reloadGame, MultiplayerInitParameters multiplayerParameters)
{
int commandCount = 0;
int engineCount = 0;
MethodInfo commandHelp = Harmony.AccessTools.Method(Harmony.AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineUtility"), "SaveCommandHelp", new Type[] { typeof(string), typeof(string) });
foreach (Type t in typeof(CustomCommandEngine).Assembly.GetTypes())
@@ -36,22 +35,19 @@ namespace ExtraCommands
enginesRoot.AddEngine(inst);
engineCount++;
}
// add to Gamecraft help command
commandHelp.Invoke(null, new string[] { attr.Name, attr.Description });
commandCount++;
}
}
}
enginesRoot.AddEngine(new UnregisterCommandEngine(contextHolder, enginesRoot, physicsWorld, reloadGame, multiplayerParameters));
Debug.Log($"Added {commandCount} custom commands in {engineCount} engines");
// enginesRoot.AddEngine(new UnregisterCommandEngine(contextHolder, enginesRoot, physicsWorld, reloadGame, multiplayerParameters));
Debug.Log($"Added {engineCount} custom command engines");
}

static MethodBase TargetMethod(HarmonyInstance instance)
{
return _ComposeMethodInfo(CommandLineCompositionRoot.Compose<CommandLineContext>);
return _ComposeMethodInfo(CommandLineCompositionRoot.Compose<UnityContext<FullGameCompositionRoot>>);
}

private static MethodInfo _ComposeMethodInfo(Action<CommandLineContext, EnginesRoot, World, Action, MultiplayerInitParameters> a)
private static MethodInfo _ComposeMethodInfo(Action<UnityContext<FullGameCompositionRoot>, EnginesRoot, World, Action, MultiplayerInitParameters> a)
{
return a.Method;
}


+ 1
- 3
extracommands/CustomCommandAttribute.cs Ver arquivo

@@ -7,11 +7,9 @@ namespace ExtraCommands
{
public string Name { get; protected set; }

public string Description { get; protected set; }
public CustomCommandAttribute(string name, string description = "")
public CustomCommandAttribute(string name = "")
{
this.Name = name;
this.Description = description;
}
}
}

+ 1
- 1
extracommands/CustomCommandEngine.cs Ver arquivo

@@ -33,7 +33,7 @@ namespace ExtraCommands

virtual public void Dispose() { }

// NOTE: Ready() should call uREPL.RuntimeCommands.Register to add the command to the command line
// NOTE: Ready() should call CustomCommandUtility.Register to add the command to the command line
virtual public void Ready() { }
}
}

+ 54
- 0
extracommands/CustomCommandUtility.cs Ver arquivo

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using uREPL;
using RobocraftX.CommandLine.Custom;

namespace ExtraCommands
{
static class CustomCommandUtility
{
public static void Register(string name, Action action, string desc)
{
RuntimeCommands.Register(name, action, desc);
ConsoleCommands.Register(name, action, desc);
}

public static void Register(string name, Action<object> action, string desc)
{
RuntimeCommands.Register<object>(name, action, desc);
}

public static void Register<Param0>(string name, Action<Param0> action, string desc)
{
RuntimeCommands.Register<Param0>(name, action, desc);
ConsoleCommands.Register<Param0>(name, action, desc);
}

public static void Register<Param0, Param1>(string name, Action<Param0, Param1> action, string desc)
{
RuntimeCommands.Register<Param0, Param1>(name, action, desc);
ConsoleCommands.Register<Param0, Param1>(name, action, desc);
}

public static void Register(string name, Action<object, object, object> action, string desc)
{
RuntimeCommands.Register<object, object, object>(name, action, desc);
ConsoleCommands.Register<object, object, object>(name, action, desc);
}

public static void Register<Param0, Param1, Param2>(string name, Action<Param0, Param1, Param2> action, string desc)
{
RuntimeCommands.Register<Param0, Param1, Param2>(name, action, desc);
ConsoleCommands.Register<Param0, Param1, Param2>(name, action, desc);
}

public static void Unregister(string name)
{
RuntimeCommands.Unregister(name);
ConsoleCommands.Unregister(name);
}
}
}

+ 3
- 3
extracommands/ExitCommandEngine.cs Ver arquivo

@@ -12,7 +12,7 @@ using RobocraftX;

namespace ExtraCommands.Basics
{
[CustomCommand("Exit", "Forcefully close Gamecraft")]
[CustomCommand("Exit")]
class ExitCommandEngine : CustomCommandEngine
{
public ExitCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
@@ -21,7 +21,7 @@ namespace ExtraCommands.Basics

public override void Ready()
{
uREPL.RuntimeCommands.Register("Exit", ExitCommand, "Forcefully close Gamecraft");
CustomCommandUtility.Register("Exit", ExitCommand, "Forcefully close Gamecraft");
}

private void ExitCommand()
@@ -31,7 +31,7 @@ namespace ExtraCommands.Basics

public override void Dispose()
{
uREPL.RuntimeCommands.Unregister("Exit");
CustomCommandUtility.Unregister("Exit");
}
}
}

+ 4
- 1
extracommands/ExtraCommands.csproj Ver arquivo

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>

<ItemGroup>
@@ -12,6 +12,9 @@
<Reference Include="CommandLine">
<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>
</Reference>
<Reference Include="FullGame">
<HintPath>..\ref\FullGame.dll</HintPath>
</Reference>


+ 2
- 2
extracommands/MoveBlocksCommandEngine.cs Ver arquivo

@@ -23,7 +23,7 @@ namespace ExtraCommands.Building

public override void Ready()
{
uREPL.RuntimeCommands.Register<float, float, float>("MoveBlocks", MoveBlocksCommand, "Move blocks from their original position");
CustomCommandUtility.Register<float, float, float>("MoveBlocks", MoveBlocksCommand, "Move blocks from their original position");
}

private void MoveBlocksCommand(float x, float y, float z)
@@ -45,7 +45,7 @@ namespace ExtraCommands.Building

public override void Dispose()
{
uREPL.RuntimeCommands.Unregister("MoveBlocks");
CustomCommandUtility.Unregister("MoveBlocks");
}
}
}

+ 3
- 3
extracommands/SetFOVCommandEngine.cs Ver arquivo

@@ -12,7 +12,7 @@ using RobocraftX;

namespace ExtraCommands.Basics
{
[CustomCommand("SetFieldOfView", "Set the camera's field of view")]
[CustomCommand("SetFieldOfView")]
class SetFOVCommandEngine : CustomCommandEngine
{
public SetFOVCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
@@ -21,7 +21,7 @@ namespace ExtraCommands.Basics

public override void Ready()
{
uREPL.RuntimeCommands.Register<float>("SetFieldOfView", SetFieldOfViewCommand, "Set the camera's field of view");
CustomCommandUtility.Register<float>("SetFieldOfView", SetFieldOfViewCommand, "Set the camera's field of view");
}

private void SetFieldOfViewCommand(float newFoV)
@@ -31,7 +31,7 @@ namespace ExtraCommands.Basics

public override void Dispose()
{
uREPL.RuntimeCommands.Unregister("SetFieldOfView");
CustomCommandUtility.Unregister("SetFieldOfView");
}
}
}

+ 3
- 3
extracommands/SetTargetFramerateCommandEngine.cs Ver arquivo

@@ -12,7 +12,7 @@ using RobocraftX;

namespace ExtraCommands.Basics
{
[CustomCommand("SetTargetFPS", "Set Gamecraft's target FPS")]
[CustomCommand("SetTargetFPS")]
class SetTargetFramerateCommandEngine : CustomCommandEngine
{
public SetTargetFramerateCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
@@ -21,7 +21,7 @@ namespace ExtraCommands.Basics

public override void Ready()
{
uREPL.RuntimeCommands.Register<int>("SetTargetFPS", SetFramerateCommand, "Set Gamecraft's target FPS");
CustomCommandUtility.Register<int>("SetTargetFPS", SetFramerateCommand, "Set Gamecraft's target FPS");
}

private void SetFramerateCommand(int newFoV)
@@ -31,7 +31,7 @@ namespace ExtraCommands.Basics

public override void Dispose()
{
uREPL.RuntimeCommands.Unregister("SetTargetFPS");
CustomCommandUtility.Unregister("SetTargetFPS");
}
}
}

+ 5
- 6
extracommands/TeleportWaypointCommandEngine.cs Ver arquivo

@@ -12,8 +12,7 @@ using RobocraftX;

namespace ExtraCommands.Waypoints
{
[CustomCommand("CreateWaypoint", "Create a waypoint in your current location")]
[CustomCommand("TeleportPlayerWaypoint", "Teleport to a waypoint")]
[CustomCommand]
class TeleportWaypointCommandEngine : CustomCommandEngine
{
private Dictionary<object, float[]> _waypoints = new Dictionary<object, float[]>();
@@ -23,8 +22,8 @@ namespace ExtraCommands.Waypoints

public override void Ready()
{
uREPL.RuntimeCommands.Register<object>("CreateWaypoint", CreateWaypointCommand, "Create a waypoint in your current location");
uREPL.RuntimeCommands.Register<object>("TeleportPlayerWaypoint", TeleportToWaypointCommand, "Teleport to a waypoint");
CustomCommandUtility.Register<object>("CreateWaypoint", CreateWaypointCommand, "Create a waypoint in your current location");
CustomCommandUtility.Register<object>("TeleportPlayerWaypoint", TeleportToWaypointCommand, "Teleport to a waypoint");
}

private void CreateWaypointCommand(object name)
@@ -47,8 +46,8 @@ namespace ExtraCommands.Waypoints

public override void Dispose()
{
uREPL.RuntimeCommands.Unregister("CreateWaypoint");
uREPL.RuntimeCommands.Unregister("TeleportPlayerWaypoint");
CustomCommandUtility.Unregister("CreateWaypoint");
CustomCommandUtility.Unregister("TeleportPlayerWaypoint");
}
}
}

+ 3
- 3
extracommands/WaitCommandEngine.cs Ver arquivo

@@ -12,7 +12,7 @@ using RobocraftX;

namespace ExtraCommands.Basics
{
[CustomCommand("Wait", "Delay execution for a length of time (ms)")]
[CustomCommand("Wait")]
class WaitCommandEngine : CustomCommandEngine
{
public WaitCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
@@ -21,7 +21,7 @@ namespace ExtraCommands.Basics

public override void Ready()
{
uREPL.RuntimeCommands.Register<int>("Wait", WaitCommand, "Delay execution for a length of time (ms)");
CustomCommandUtility.Register<int>("Wait", WaitCommand, "Delay execution for a length of time (ms)");
}

private void WaitCommand(int ms)
@@ -31,7 +31,7 @@ namespace ExtraCommands.Basics

public override void Dispose()
{
uREPL.RuntimeCommands.Unregister("Wait");
CustomCommandUtility.Unregister("Wait");
}
}
}

Carregando…
Cancelar
Salvar