From 383519f786fd1901609e7f2e34eb1887c216a016 Mon Sep 17 00:00:00 2001 From: NGnius Date: Fri, 29 Nov 2019 20:11:36 -0500 Subject: [PATCH] Fix for changes in latest GC update --- extracommands/ChainCommandEngine.cs | 63 +++++-------------- extracommands/ExtraCommands.csproj | 3 + extracommands/ExtraCommandsPlugin.cs | 2 +- extracommands/MoveBlocksCommandEngine.cs | 55 +--------------- extracommands/RotateBlocksCommandEngine.cs | 6 +- .../TeleportWaypointCommandEngine.cs | 1 + 6 files changed, 25 insertions(+), 105 deletions(-) diff --git a/extracommands/ChainCommandEngine.cs b/extracommands/ChainCommandEngine.cs index 3b1c14a..869d324 100644 --- a/extracommands/ChainCommandEngine.cs +++ b/extracommands/ChainCommandEngine.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using RobocraftX.GUI.CommandLine; using RobocraftX.Multiplayer; using RobocraftX.StateSync; @@ -8,11 +9,14 @@ using Unity.Entities; using UnityEngine; using uREPL; using Svelto.Context; +using Svelto.Tasks; +using Svelto.Tasks.ExtraLean; using RobocraftX; +using RobocraftX.Schedulers; namespace ExtraCommands.Basics { - [CustomCommand] + [CustomCommand("Chain")] class ChainCommandEngine : CustomCommandEngine { public ChainCommandEngine(UnityContext ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams) @@ -22,75 +26,38 @@ namespace ExtraCommands.Basics public override void Ready() { CustomCommandUtility.Register("Chain", ChainCommand, "Run two commands, one after the other"); - CustomCommandUtility.Register("ChainNoFail", ChainNoFailCommand, "Run two commands, one after the other even if the first one is invalid"); - CustomCommandUtility.Register("ChainQuiet", ChainQuietCommand, "Run two commands, one after the other quietly"); } private void ChainCommand(string command1, string command2) { 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.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success; - if (!success2) { - uREPL.Log.Error("Second command was not executed successfully"); - } + ScheduleCommands(command1a, command2a).RunOn(ExtraLean.CharacterUpdateScheduler); } - private void ChainNoFailCommand(string command1, string command2) + private IEnumerator ScheduleCommands(string c1, string c2) { - string command1a = decomma(command1); - string command2a = decomma(command2); - bool success1 = uREPL.Evaluator.Evaluate(command1a).type == CompileResult.Type.Success; - if (!success1) { + yield return Yield.It; + bool success1 = uREPL.Evaluator.Evaluate(c1).type == CompileResult.Type.Success; + if (!success1) + { uREPL.Log.Error("First command was not executed successfully"); } - bool success2 = uREPL.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success; - if (!success2) { + bool success2 = uREPL.Evaluator.Evaluate(c2).type == CompileResult.Type.Success; + if (!success2) + { uREPL.Log.Error("Second command was not executed successfully"); } } - private void ChainQuietCommand(string command1, string 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; + return strIn.Replace(", ", " "); } public override void Dispose() { CustomCommandUtility.Unregister("Chain"); - CustomCommandUtility.Unregister("ChainNoFail"); - CustomCommandUtility.Unregister("ChainQuiet"); } } } diff --git a/extracommands/ExtraCommands.csproj b/extracommands/ExtraCommands.csproj index 28dabd7..8570e06 100644 --- a/extracommands/ExtraCommands.csproj +++ b/extracommands/ExtraCommands.csproj @@ -49,6 +49,9 @@ ..\ref\RobocraftX.MultiplayerInput.dll + + ..\ref\RobocraftX.Physics.dll + ..\ref\RobocraftX.StateSync.dll diff --git a/extracommands/ExtraCommandsPlugin.cs b/extracommands/ExtraCommandsPlugin.cs index 2c8af75..3f7e4c4 100644 --- a/extracommands/ExtraCommandsPlugin.cs +++ b/extracommands/ExtraCommandsPlugin.cs @@ -14,7 +14,7 @@ namespace ExtraCommands public string Name { get; } = "ExtraCommands"; - public string Version { get; } = "v0.0.1"; + public string Version { get; } = "v0.0.3"; public string HarmonyID { get; } = "org.git.exmods.extracommands.extracommands"; diff --git a/extracommands/MoveBlocksCommandEngine.cs b/extracommands/MoveBlocksCommandEngine.cs index 07fd2ba..c1775d3 100644 --- a/extracommands/MoveBlocksCommandEngine.cs +++ b/extracommands/MoveBlocksCommandEngine.cs @@ -104,7 +104,7 @@ namespace ExtraCommands.Building uint connectedBlockID = cubeStack.Pop(); processedCubes.Add(connectedBlockID); ScalingEntityStruct scale = entitiesDB.QueryEntity(connectedBlockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP); - uREPL.Log.Output($"Catching {connectedBlockID} with scale {scale.scale}"); + //uREPL.Log.Output($"Catching {connectedBlockID} with scale {scale.scale}"); blockConnections = entitiesDB.QueryEntity(connectedBlockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP); connections = entitiesDB.QueryEntities(blockConnections.connectionGroup, out count); @@ -115,7 +115,7 @@ namespace ExtraCommands.Building && (conn.oppositeConnectionEgid.entityID != 0u || conn.oppositeConnectionEgid.entityID != conn.connectedBlock.entityID)) { - uREPL.Log.Output($"Block {connectedBlockID} connects to {conn.connectedBlock.entityID} (opposite {conn.oppositeConnectionEgid.entityID})"); + //uREPL.Log.Output($"Block {connectedBlockID} connects to {conn.connectedBlock.entityID} (opposite {conn.oppositeConnectionEgid.entityID})"); cubeStack.Push(conn.connectedBlock.entityID); } } @@ -124,59 +124,10 @@ namespace ExtraCommands.Building { TranslateSingleBlock(id, translationVector); } - uREPL.Log.Output($"Found {processedCubes.Count} connected blocks"); + //uREPL.Log.Output($"Found {processedCubes.Count} connected blocks"); return this.entitiesDB.QueryEntity(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP).position; } - // unused; for future reference - private void ToggleMode() - { - ref SimulationModeStateEntityStruct ptr = ref this.entitiesDB.QueryUniqueEntity(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP); - ref SimulationFrameEntityStruct ptr2 = ref this.entitiesDB.QueryUniqueEntity(SimulationFrame.SimulationFrameGroup); - switch (ptr.simulationMode) - { - case SimulationMode.Build: - ptr.simulationMode = SimulationMode.SwitchToSim; - ptr.simulationModeChangeFrame = ptr2.simFrame; - return; - case SimulationMode.SwitchToSim: - case SimulationMode.SwitchToBuild: - return; - case SimulationMode.Simulation: - ptr.simulationMode = SimulationMode.SwitchToBuild; - ptr.simulationModeChangeFrame = ptr2.simFrame; - ptr.rigidBodiesCreated = false; - return; - default: - throw new ArgumentOutOfRangeException(); - } - } - - // unused; for future reference - private IEnumerator TriggerSwitchToSimTask() - { - this.ToggleMode(); - yield break; - } - - // unused; for future reference - private IEnumerator WaitThenTriggerSwitchToBuildTask() - { - while (true) - { - SimulationModeStateEntityStruct modeStruct = this.entitiesDB.QueryUniqueEntity(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP); - if (modeStruct.simulationMode == SimulationMode.Simulation) - { - this.ToggleMode(); - break; - } else - { - yield return Yield.It; - } - } - yield break; - } - public override void Dispose() { CustomCommandUtility.Unregister("MoveBlocks"); diff --git a/extracommands/RotateBlocksCommandEngine.cs b/extracommands/RotateBlocksCommandEngine.cs index e8c277f..f379b90 100644 --- a/extracommands/RotateBlocksCommandEngine.cs +++ b/extracommands/RotateBlocksCommandEngine.cs @@ -102,15 +102,13 @@ namespace ExtraCommands.Building switch (ptr.simulationMode) { case SimulationMode.Build: - ptr.simulationMode = SimulationMode.SwitchToSim; - ptr.simulationModeChangeFrame = ptr2.simFrame; + ptr.nextSimulationMode = SimulationMode.SwitchToSim; return; case SimulationMode.SwitchToSim: case SimulationMode.SwitchToBuild: return; case SimulationMode.Simulation: - ptr.simulationMode = SimulationMode.SwitchToBuild; - ptr.simulationModeChangeFrame = ptr2.simFrame; + ptr.nextSimulationMode = SimulationMode.SwitchToBuild; ptr.rigidBodiesCreated = false; return; default: diff --git a/extracommands/TeleportWaypointCommandEngine.cs b/extracommands/TeleportWaypointCommandEngine.cs index 329a177..950326b 100644 --- a/extracommands/TeleportWaypointCommandEngine.cs +++ b/extracommands/TeleportWaypointCommandEngine.cs @@ -9,6 +9,7 @@ using Unity.Entities; using uREPL; using Svelto.Context; using RobocraftX; +using RobocraftX.Physics; namespace ExtraCommands.Waypoints {