Bladeren bron

Test and fix basic commands

tags/v0.0.2
NGnius 4 jaren geleden
bovenliggende
commit
d4db32ccb4
2 gewijzigde bestanden met toevoegingen van 39 en 10 verwijderingen
  1. +37
    -8
      extracommands/ChainCommandEngine.cs
  2. +2
    -2
      extracommands/SetTargetFramerateCommandEngine.cs

+ 37
- 8
extracommands/ChainCommandEngine.cs Bestand weergeven

@@ -24,18 +24,20 @@ 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", ChainCommand, "Run two commands, one after the other even if the first one is invalid");
uREPL.RuntimeCommands.Register<string, string>("ChainQuiet", ChainCommand, "Run two commands, one after the other quietly");
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");
}

private void ChainCommand(string command1, string command2)
{
bool success1 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1);
string command1a = decomma(command1);
string command2a = decomma(command2);
bool success1 = uREPL.Evaluator.Evaluate(command1a).type == CompileResult.Type.Success;
if (!success1) {
uREPL.Log.Error("First command was not executed successfully");
return;
}
bool success2 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2);
bool success2 = uREPL.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success;
if (!success2) {
uREPL.Log.Error("Second command was not executed successfully");
}
@@ -43,11 +45,13 @@ namespace ExtraCommands.Basics

private void ChainNoFailCommand(string command1, string command2)
{
bool success1 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1);
string command1a = decomma(command1);
string command2a = decomma(command2);
bool success1 = uREPL.Evaluator.Evaluate(command1a).type == CompileResult.Type.Success;
if (!success1) {
uREPL.Log.Error("First command was not executed successfully");
}
bool success2 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2);
bool success2 = uREPL.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success;
if (!success2) {
uREPL.Log.Error("Second command was not executed successfully");
}
@@ -55,8 +59,33 @@ namespace ExtraCommands.Basics

private void ChainQuietCommand(string command1, string command2)
{
uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1);
uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2);
string command1a = decomma(command1);
string command2a = decomma(command2);
uREPL.Evaluator.Evaluate(command1a);
uREPL.Evaluator.Evaluate(command2a);
}

private string decomma(string strIn)
{
string strOut = "";
bool wasCommaLast = false;
foreach (char c in strIn)
{
if (wasCommaLast)
{
wasCommaLast = false;
if (c == ' ')
{
strOut = strOut.Substring(0, strOut.Length - 1);
}
}
if (c == ',')
{
wasCommaLast = true;
}
strOut += c;
}
return strOut;
}

public override void Dispose()


+ 2
- 2
extracommands/SetTargetFramerateCommandEngine.cs Bestand weergeven

@@ -15,13 +15,13 @@ namespace ExtraCommands.Basics
[CustomCommand("SetTargetFPS", "Set Gamecraft's target FPS")]
class SetTargetFramerateCommandEngine : CustomCommandEngine
{
public SetFOVCommandEngine(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)
{
}

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

private void SetFramerateCommand(int newFoV)


Laden…
Annuleren
Opslaan