From d1c0556b9ce90a8c1718bda21a20d09764a539ed Mon Sep 17 00:00:00 2001 From: NGnius Date: Tue, 7 Apr 2020 13:05:00 -0400 Subject: [PATCH] Update to Gamecraft 2020.04.06.14.50 --- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 2 +- GamecraftModdingAPI/Blocks/SignalEngine.cs | 16 ++++---- ...terministicStepComposeEngineGroupsPatch.cs | 24 +++++++++--- .../Events/GameStateBuildEmitterEngine.cs | 10 +++++ .../GameStateSimulationEmitterEngine.cs | 9 +++++ .../GamecraftModdingAPI.csproj | 39 +++---------------- GamecraftModdingAPI/Main.cs | 4 +- .../Tests/GamecraftModdingAPIPluginTest.cs | 2 + GamecraftModdingAPI/Utility/FullGameFields.cs | 17 -------- GamecraftModdingAPI/Utility/Logging.cs | 6 ++- 10 files changed, 60 insertions(+), 69 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index 3856bc0..9a3632e 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -135,7 +135,7 @@ namespace GamecraftModdingAPI.Blocks static MethodBase TargetMethod(HarmonyInstance instance) { - return typeof(PlaceBlockEngine).GetConstructors()[0]; + return AccessTools.TypeByName("RobocraftX.CR.MachineEditing.PlaceBlockEngine").GetConstructors()[0]; } } } diff --git a/GamecraftModdingAPI/Blocks/SignalEngine.cs b/GamecraftModdingAPI/Blocks/SignalEngine.cs index d84eefe..6af4176 100644 --- a/GamecraftModdingAPI/Blocks/SignalEngine.cs +++ b/GamecraftModdingAPI/Blocks/SignalEngine.cs @@ -59,7 +59,7 @@ namespace GamecraftModdingAPI.Blocks ExclusiveGroup group = input ? NamedExclusiveGroup.Group : NamedExclusiveGroup.Group; if (entitiesDB.Exists(signalID, group)) { - entitiesDB.QueryEntity(signalID, group).value = signal; + entitiesDB.QueryEntity(signalID, group).anyChannel.valueAsFloat = signal; return true; } return false; @@ -77,18 +77,18 @@ namespace GamecraftModdingAPI.Blocks if (entitiesDB.Exists(signalID, group)) { ref PortEntityStruct pes = ref entitiesDB.QueryEntity(signalID, group); - pes.value += signal; + pes.anyChannel.valueAsFloat += signal; if (clamp) { - if (pes.value > Signals.POSITIVE_HIGH) + if (pes.anyChannel.valueAsFloat > Signals.POSITIVE_HIGH) { - pes.value = Signals.POSITIVE_HIGH; + pes.anyChannel.valueAsFloat = Signals.POSITIVE_HIGH; } - else if (pes.value < Signals.NEGATIVE_HIGH) + else if (pes.anyChannel.valueAsFloat < Signals.NEGATIVE_HIGH) { - pes.value = Signals.NEGATIVE_HIGH; + pes.anyChannel.valueAsFloat = Signals.NEGATIVE_HIGH; } - return pes.value; + return pes.anyChannel.valueAsFloat; } } return signal; @@ -105,7 +105,7 @@ namespace GamecraftModdingAPI.Blocks ExclusiveGroup group = input ? NamedExclusiveGroup.Group : NamedExclusiveGroup.Group; if (entitiesDB.Exists(signalID, group)) { - return entitiesDB.QueryEntity(signalID, group).value; + return entitiesDB.QueryEntity(signalID, group).anyChannel.valueAsFloat; } return 0f; } diff --git a/GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs b/GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs index 6493b0c..4779869 100644 --- a/GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs +++ b/GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Harmony; using Svelto.ECS; +using RobocraftX.Common; using RobocraftX.StateSync; using GamecraftModdingAPI.Utility; @@ -16,19 +17,30 @@ namespace GamecraftModdingAPI.Events /// /// Patch of RobocraftX.StateSync.DeterministicStepCompositionRoot.ComposeEnginesGroups(...) /// - [HarmonyPatch(typeof(DeterministicStepCompositionRoot), "ComposeEnginesGroups")] - //[HarmonyPatch] - class DeterministicStepComposeEngineGroupsPatch + //[HarmonyPatch(typeof(DeterministicStepCompositionRoot), "DeterministicCompose")] + [HarmonyPatch] + class GameHostTransitionDeterministicGroupEnginePatch { public static readonly GameStateBuildEmitterEngine buildEngine = new GameStateBuildEmitterEngine(); public static readonly GameStateSimulationEmitterEngine simEngine = new GameStateSimulationEmitterEngine(); - public static void Prefix(ref StateSyncRegistrationHelper stateSyncReg) + public static void Postfix() { - stateSyncReg.buildModeInitializationEngines.Add(buildEngine); - stateSyncReg.simulationModeInitializationEngines.Add(simEngine); + //stateSyncReg.buildModeInitializationEngines.Add(buildEngine); + //stateSyncReg.simulationModeInitializationEngines.Add(simEngine); + //enginesRoot.AddEngine(buildEngine); + //enginesRoot.AddEngine(simEngine); + buildEngine.EmitIfBuildMode(); + simEngine.EmitIfSimMode(); } + + [HarmonyTargetMethod] + public static MethodBase TargetMethod(HarmonyInstance harmonyInstance) + { + return AccessTools.Method(AccessTools.TypeByName("RobocraftX.StateSync.GameHostTransitionDeterministicGroupEngine"), "EndTransition"); + //.MakeGenericMethod(typeof(CosmeticEnginesSequenceBuildOrder), typeof(CosmeticEnginesSequenceSimOrder), typeof(DeterministicToCosmeticSyncBuildOrder), typeof(DeterministicToCosmeticSyncSimOrder)); + } } } diff --git a/GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs b/GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs index 5e6f1fe..1c5b363 100644 --- a/GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs +++ b/GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs @@ -1,6 +1,7 @@ using System; using Unity.Jobs; +using RobocraftX.SimulationModeState; using RobocraftX.StateSync; using Svelto.ECS; @@ -33,6 +34,15 @@ namespace GamecraftModdingAPI.Events .Init(new ModEventEntityStruct { type = type }); } + public void EmitIfBuildMode() + { + //Logging.MetaDebugLog($"nextSimulationMode: {entitiesDB.QueryUniqueEntity(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode}"); + if (entitiesDB.QueryUniqueEntity(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode == SimulationMode.Build) + { + Emit(); + } + } + public JobHandle OnInitializeBuildMode() { Emit(); diff --git a/GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs b/GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs index 578f320..91ee596 100644 --- a/GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs +++ b/GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs @@ -1,6 +1,7 @@ using System; using Unity.Jobs; +using RobocraftX.SimulationModeState; using RobocraftX.StateSync; using Svelto.ECS; @@ -33,6 +34,14 @@ namespace GamecraftModdingAPI.Events .Init(new ModEventEntityStruct { type = type }); } + public void EmitIfSimMode() + { + if (entitiesDB.QueryUniqueEntity(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode == SimulationMode.Simulation) + { + Emit(); + } + } + public JobHandle OnInitializeSimulationMode() { Emit(); diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index d000ff5..4371236 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -88,9 +88,6 @@ ..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll - - ..\ref\Gamecraft_Data\Managed\HdgRemoteDebugRuntime.dll - ..\ref\Gamecraft_Data\Managed\IllusionInjector.dll @@ -121,9 +118,6 @@ ..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll - - ..\ref\Gamecraft_Data\Managed\Robocraft.MainGame.AutoEnterSimulation.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll @@ -148,15 +142,9 @@ ..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll - - ..\ref\Gamecraft_Data\Managed\RobocraftX.EntityStreamUtility.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GameSignalHandling.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll @@ -169,18 +157,12 @@ ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.SignalLabel.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll ..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Inventory.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll @@ -214,9 +196,6 @@ ..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Priority.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll @@ -286,12 +265,6 @@ ..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll - - ..\ref\Gamecraft_Data\Managed\Unity.Entities.Properties.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Entities.StaticTypeRegistry.dll - ..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll @@ -322,9 +295,6 @@ ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Lightweight.Runtime.dll - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll @@ -394,9 +364,6 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.DSPGraphModule.dll - - ..\ref\Gamecraft_Data\Managed\UnityEngine.FileSystemHttpModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.GameCenterModule.dll @@ -539,6 +506,12 @@ ..\ref\Gamecraft_Data\Managed\VisualProfiler.dll + + ..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll + + + ..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll + diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index 0767bab..6ce1126 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -56,8 +56,8 @@ namespace GamecraftModdingAPI EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Game, "GamecraftModdingAPIGameActivatedEventEmitter", false)); EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameReloaded, "GamecraftModdingAPIGameReloadedEventEmitter", false)); EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameSwitchedTo, "GamecraftModdingAPIGameSwitchedToEventEmitter", false)); - EventManager.AddEventEmitter(DeterministicStepComposeEngineGroupsPatch.buildEngine); - EventManager.AddEventEmitter(DeterministicStepComposeEngineGroupsPatch.simEngine); + EventManager.AddEventEmitter(GameHostTransitionDeterministicGroupEnginePatch.buildEngine); + EventManager.AddEventEmitter(GameHostTransitionDeterministicGroupEnginePatch.simEngine); // init block implementors Logging.MetaDebugLog($"Initializing Blocks"); Blocks.Movement.Init(); diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 1d55602..dac4312 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -41,6 +41,8 @@ namespace GamecraftModdingAPI.Tests public void OnApplicationStart() { + FileLog.Reset(); + HarmonyInstance.DEBUG = true; GamecraftModdingAPI.Main.Init(); // in case Steam is not installed/running // this will crash the game slightly later during startup diff --git a/GamecraftModdingAPI/Utility/FullGameFields.cs b/GamecraftModdingAPI/Utility/FullGameFields.cs index c90dbbe..d90ef44 100644 --- a/GamecraftModdingAPI/Utility/FullGameFields.cs +++ b/GamecraftModdingAPI/Utility/FullGameFields.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using DataLoader; using Harmony; using RobocraftX; -using RobocraftX.Blocks.GUI; using RobocraftX.Common.Utilities; using RobocraftX.GUI; using RobocraftX.Multiplayer; @@ -137,22 +136,6 @@ namespace GamecraftModdingAPI.Utility } } - public static LabelResourceManager _textBlockLabelResourceManager - { - get - { - return (LabelResourceManager)fgcr?.Field("_textBlockLabelResourceManager").GetValue(); - } - } - - public static LabelResourceManager _labelResourceManager - { - get - { - return (LabelResourceManager)fgcr?.Field("_labelResourceManager").GetValue(); - } - } - public static ECSGameObjectResourceManager _eCsGameObjectResourceManager { get diff --git a/GamecraftModdingAPI/Utility/Logging.cs b/GamecraftModdingAPI/Utility/Logging.cs index 0f22c0a..20c17cf 100644 --- a/GamecraftModdingAPI/Utility/Logging.cs +++ b/GamecraftModdingAPI/Utility/Logging.cs @@ -123,20 +123,22 @@ namespace GamecraftModdingAPI.Utility Svelto.Console.LogWarning(obj.ToString()); } + [Obsolete("SystemLog was removed from Svelto.Common")] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void SystemLog(string msg) { - Svelto.Console.SystemLog(msg); + Svelto.Console.Log(msg); } /// /// Write a message to stdout (ie the terminal, like Command Prompt or PowerShell) /// /// The object to log + [Obsolete("SystemLog was removed from Svelto.Common")] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void SystemLog(object obj) { - Svelto.Console.SystemLog(obj.ToString()); + Svelto.Console.Log(obj.ToString()); } // descriptive logging