@@ -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]; | |||
} | |||
} | |||
} |
@@ -59,7 +59,7 @@ namespace GamecraftModdingAPI.Blocks | |||
ExclusiveGroup group = input ? NamedExclusiveGroup<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group; | |||
if (entitiesDB.Exists<PortEntityStruct>(signalID, group)) | |||
{ | |||
entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).value = signal; | |||
entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).anyChannel.valueAsFloat = signal; | |||
return true; | |||
} | |||
return false; | |||
@@ -77,18 +77,18 @@ namespace GamecraftModdingAPI.Blocks | |||
if (entitiesDB.Exists<PortEntityStruct>(signalID, group)) | |||
{ | |||
ref PortEntityStruct pes = ref entitiesDB.QueryEntity<PortEntityStruct>(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<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group; | |||
if (entitiesDB.Exists<PortEntityStruct>(signalID, group)) | |||
{ | |||
return entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).value; | |||
return entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).anyChannel.valueAsFloat; | |||
} | |||
return 0f; | |||
} | |||
@@ -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 | |||
/// <summary> | |||
/// Patch of RobocraftX.StateSync.DeterministicStepCompositionRoot.ComposeEnginesGroups(...) | |||
/// </summary> | |||
[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)); | |||
} | |||
} | |||
} |
@@ -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<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode}"); | |||
if (entitiesDB.QueryUniqueEntity<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode == SimulationMode.Build) | |||
{ | |||
Emit(); | |||
} | |||
} | |||
public JobHandle OnInitializeBuildMode() | |||
{ | |||
Emit(); | |||
@@ -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<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode == SimulationMode.Simulation) | |||
{ | |||
Emit(); | |||
} | |||
} | |||
public JobHandle OnInitializeSimulationMode() | |||
{ | |||
Emit(); | |||
@@ -88,9 +88,6 @@ | |||
<Reference Include="Havok.Physics.Hybrid"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll</HintPath> | |||
</Reference> | |||
<Reference Include="HdgRemoteDebugRuntime"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\HdgRemoteDebugRuntime.dll</HintPath> | |||
</Reference> | |||
<Reference Include="IllusionInjector"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\IllusionInjector.dll</HintPath> | |||
</Reference> | |||
@@ -121,9 +118,6 @@ | |||
<Reference Include="Rewired_Windows"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Robocraft.MainGame.AutoEnterSimulation"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Robocraft.MainGame.AutoEnterSimulation.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.AccountPreferences"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll</HintPath> | |||
</Reference> | |||
@@ -148,15 +142,9 @@ | |||
<Reference Include="RobocraftX.Crosshair"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.EntityStreamUtility"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.EntityStreamUtility.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.FrontEnd"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.GameSignalHandling"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.GameSignalHandling.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.GUI.DebugDisplay"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll</HintPath> | |||
</Reference> | |||
@@ -169,18 +157,12 @@ | |||
<Reference Include="RobocraftX.GUI.ScaleGhost"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.GUI.SignalLabel"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.SignalLabel.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.GUIs.WorkshopPrefabs"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.Input"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.Inventory"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Inventory.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.MachineEditor"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll</HintPath> | |||
</Reference> | |||
@@ -214,9 +196,6 @@ | |||
<Reference Include="RobocraftX.Player"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.Priority"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Priority.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.Rendering"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll</HintPath> | |||
</Reference> | |||
@@ -286,12 +265,6 @@ | |||
<Reference Include="Unity.Entities.Hybrid"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.Entities.Properties"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Entities.Properties.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.Entities.StaticTypeRegistry"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Entities.StaticTypeRegistry.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.Jobs"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll</HintPath> | |||
</Reference> | |||
@@ -322,9 +295,6 @@ | |||
<Reference Include="Unity.RenderPipelines.Core.ShaderLibrary"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.RenderPipelines.Lightweight.Runtime"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Lightweight.Runtime.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll</HintPath> | |||
</Reference> | |||
@@ -394,9 +364,6 @@ | |||
<Reference Include="UnityEngine.DSPGraphModule"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\UnityEngine.DSPGraphModule.dll</HintPath> | |||
</Reference> | |||
<Reference Include="UnityEngine.FileSystemHttpModule"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\UnityEngine.FileSystemHttpModule.dll</HintPath> | |||
</Reference> | |||
<Reference Include="UnityEngine.GameCenterModule"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\UnityEngine.GameCenterModule.dll</HintPath> | |||
</Reference> | |||
@@ -539,6 +506,12 @@ | |||
<HintPath>..\ref\Gamecraft_Data\Managed\VisualProfiler.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.CSharp" /> | |||
<Reference Include="Assembly-CSharp"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll</HintPath> | |||
</Reference> | |||
<Reference Include="UnityEngine.CoreModule"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll</HintPath> | |||
</Reference> | |||
</ItemGroup> | |||
<!--End Dependencies--> | |||
@@ -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(); | |||
@@ -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 | |||
@@ -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 | |||
@@ -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); | |||
} | |||
/// <summary> | |||
/// Write a message to stdout (ie the terminal, like Command Prompt or PowerShell) | |||
/// </summary> | |||
/// <param name="obj">The object to log</param> | |||
[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 | |||