Update compatibility to Gamecraft v2019.10.23.16.11
This commit is contained in:
parent
9071fccf76
commit
a9957f922c
12 changed files with 90 additions and 42 deletions
|
@ -12,9 +12,7 @@ using RobocraftX;
|
||||||
|
|
||||||
namespace ExtraCommands.Basics
|
namespace ExtraCommands.Basics
|
||||||
{
|
{
|
||||||
[CustomCommand("Chain", "Run two commands, one after the other")]
|
[CustomCommand]
|
||||||
[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")]
|
|
||||||
class ChainCommandEngine : CustomCommandEngine
|
class ChainCommandEngine : CustomCommandEngine
|
||||||
{
|
{
|
||||||
public ChainCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
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()
|
public override void Ready()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Register<string, string>("Chain", ChainCommand, "Run two commands, one after the other");
|
CustomCommandUtility.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");
|
CustomCommandUtility.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>("ChainQuiet", ChainQuietCommand, "Run two commands, one after the other quietly");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChainCommand(string command1, string command2)
|
private void ChainCommand(string command1, string command2)
|
||||||
|
@ -90,9 +88,9 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Unregister("Chain");
|
CustomCommandUtility.Unregister("Chain");
|
||||||
uREPL.RuntimeCommands.Unregister("ChainNoFail");
|
CustomCommandUtility.Unregister("ChainNoFail");
|
||||||
uREPL.RuntimeCommands.Unregister("ChainQuiet");
|
CustomCommandUtility.Unregister("ChainQuiet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace ExtraCommands
|
||||||
{
|
{
|
||||||
static void Postfix(UnityContext<FullGameCompositionRoot> contextHolder, EnginesRoot enginesRoot, World physicsWorld, Action reloadGame, MultiplayerInitParameters multiplayerParameters)
|
static void Postfix(UnityContext<FullGameCompositionRoot> contextHolder, EnginesRoot enginesRoot, World physicsWorld, Action reloadGame, MultiplayerInitParameters multiplayerParameters)
|
||||||
{
|
{
|
||||||
int commandCount = 0;
|
|
||||||
int engineCount = 0;
|
int engineCount = 0;
|
||||||
MethodInfo commandHelp = Harmony.AccessTools.Method(Harmony.AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineUtility"), "SaveCommandHelp", new Type[] { typeof(string), typeof(string) });
|
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())
|
foreach (Type t in typeof(CustomCommandEngine).Assembly.GetTypes())
|
||||||
|
@ -36,22 +35,19 @@ namespace ExtraCommands
|
||||||
enginesRoot.AddEngine(inst);
|
enginesRoot.AddEngine(inst);
|
||||||
engineCount++;
|
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));
|
// enginesRoot.AddEngine(new UnregisterCommandEngine(contextHolder, enginesRoot, physicsWorld, reloadGame, multiplayerParameters));
|
||||||
Debug.Log($"Added {commandCount} custom commands in {engineCount} engines");
|
Debug.Log($"Added {engineCount} custom command engines");
|
||||||
}
|
}
|
||||||
|
|
||||||
static MethodBase TargetMethod(HarmonyInstance instance)
|
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;
|
return a.Method;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,9 @@ namespace ExtraCommands
|
||||||
{
|
{
|
||||||
public string Name { get; protected set; }
|
public string Name { get; protected set; }
|
||||||
|
|
||||||
public string Description { get; protected set; }
|
public CustomCommandAttribute(string name = "")
|
||||||
public CustomCommandAttribute(string name, string description = "")
|
|
||||||
{
|
{
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Description = description;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace ExtraCommands
|
||||||
|
|
||||||
virtual public void Dispose() { }
|
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() { }
|
virtual public void Ready() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
54
extracommands/CustomCommandUtility.cs
Normal file
54
extracommands/CustomCommandUtility.cs
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ using RobocraftX;
|
||||||
|
|
||||||
namespace ExtraCommands.Basics
|
namespace ExtraCommands.Basics
|
||||||
{
|
{
|
||||||
[CustomCommand("Exit", "Forcefully close Gamecraft")]
|
[CustomCommand("Exit")]
|
||||||
class ExitCommandEngine : CustomCommandEngine
|
class ExitCommandEngine : CustomCommandEngine
|
||||||
{
|
{
|
||||||
public ExitCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
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()
|
public override void Ready()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Register("Exit", ExitCommand, "Forcefully close Gamecraft");
|
CustomCommandUtility.Register("Exit", ExitCommand, "Forcefully close Gamecraft");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExitCommand()
|
private void ExitCommand()
|
||||||
|
@ -31,7 +31,7 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Unregister("Exit");
|
CustomCommandUtility.Unregister("Exit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net45</TargetFramework>
|
<TargetFramework>net461</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -12,6 +12,9 @@
|
||||||
<Reference Include="CommandLine">
|
<Reference Include="CommandLine">
|
||||||
<HintPath>..\ref\CommandLine.dll</HintPath>
|
<HintPath>..\ref\CommandLine.dll</HintPath>
|
||||||
</Reference>
|
</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">
|
<Reference Include="FullGame">
|
||||||
<HintPath>..\ref\FullGame.dll</HintPath>
|
<HintPath>..\ref\FullGame.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace ExtraCommands.Building
|
||||||
|
|
||||||
public override void Ready()
|
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)
|
private void MoveBlocksCommand(float x, float y, float z)
|
||||||
|
@ -45,7 +45,7 @@ namespace ExtraCommands.Building
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Unregister("MoveBlocks");
|
CustomCommandUtility.Unregister("MoveBlocks");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ using RobocraftX;
|
||||||
|
|
||||||
namespace ExtraCommands.Basics
|
namespace ExtraCommands.Basics
|
||||||
{
|
{
|
||||||
[CustomCommand("SetFieldOfView", "Set the camera's field of view")]
|
[CustomCommand("SetFieldOfView")]
|
||||||
class SetFOVCommandEngine : CustomCommandEngine
|
class SetFOVCommandEngine : CustomCommandEngine
|
||||||
{
|
{
|
||||||
public SetFOVCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
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()
|
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)
|
private void SetFieldOfViewCommand(float newFoV)
|
||||||
|
@ -31,7 +31,7 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Unregister("SetFieldOfView");
|
CustomCommandUtility.Unregister("SetFieldOfView");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ using RobocraftX;
|
||||||
|
|
||||||
namespace ExtraCommands.Basics
|
namespace ExtraCommands.Basics
|
||||||
{
|
{
|
||||||
[CustomCommand("SetTargetFPS", "Set Gamecraft's target FPS")]
|
[CustomCommand("SetTargetFPS")]
|
||||||
class SetTargetFramerateCommandEngine : CustomCommandEngine
|
class SetTargetFramerateCommandEngine : CustomCommandEngine
|
||||||
{
|
{
|
||||||
public SetTargetFramerateCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
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()
|
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)
|
private void SetFramerateCommand(int newFoV)
|
||||||
|
@ -31,7 +31,7 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Unregister("SetTargetFPS");
|
CustomCommandUtility.Unregister("SetTargetFPS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,7 @@ using RobocraftX;
|
||||||
|
|
||||||
namespace ExtraCommands.Waypoints
|
namespace ExtraCommands.Waypoints
|
||||||
{
|
{
|
||||||
[CustomCommand("CreateWaypoint", "Create a waypoint in your current location")]
|
[CustomCommand]
|
||||||
[CustomCommand("TeleportPlayerWaypoint", "Teleport to a waypoint")]
|
|
||||||
class TeleportWaypointCommandEngine : CustomCommandEngine
|
class TeleportWaypointCommandEngine : CustomCommandEngine
|
||||||
{
|
{
|
||||||
private Dictionary<object, float[]> _waypoints = new Dictionary<object, float[]>();
|
private Dictionary<object, float[]> _waypoints = new Dictionary<object, float[]>();
|
||||||
|
@ -23,8 +22,8 @@ namespace ExtraCommands.Waypoints
|
||||||
|
|
||||||
public override void Ready()
|
public override void Ready()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Register<object>("CreateWaypoint", CreateWaypointCommand, "Create a waypoint in your current location");
|
CustomCommandUtility.Register<object>("CreateWaypoint", CreateWaypointCommand, "Create a waypoint in your current location");
|
||||||
uREPL.RuntimeCommands.Register<object>("TeleportPlayerWaypoint", TeleportToWaypointCommand, "Teleport to a waypoint");
|
CustomCommandUtility.Register<object>("TeleportPlayerWaypoint", TeleportToWaypointCommand, "Teleport to a waypoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateWaypointCommand(object name)
|
private void CreateWaypointCommand(object name)
|
||||||
|
@ -47,8 +46,8 @@ namespace ExtraCommands.Waypoints
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Unregister("CreateWaypoint");
|
CustomCommandUtility.Unregister("CreateWaypoint");
|
||||||
uREPL.RuntimeCommands.Unregister("TeleportPlayerWaypoint");
|
CustomCommandUtility.Unregister("TeleportPlayerWaypoint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ using RobocraftX;
|
||||||
|
|
||||||
namespace ExtraCommands.Basics
|
namespace ExtraCommands.Basics
|
||||||
{
|
{
|
||||||
[CustomCommand("Wait", "Delay execution for a length of time (ms)")]
|
[CustomCommand("Wait")]
|
||||||
class WaitCommandEngine : CustomCommandEngine
|
class WaitCommandEngine : CustomCommandEngine
|
||||||
{
|
{
|
||||||
public WaitCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
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()
|
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)
|
private void WaitCommand(int ms)
|
||||||
|
@ -31,7 +31,7 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Unregister("Wait");
|
CustomCommandUtility.Unregister("Wait");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue