Browse Source

Update to Gamecraft 2020.04.06.14.50

tags/v0.2.0
NGnius 4 years ago
parent
commit
d1c0556b9c
10 changed files with 60 additions and 69 deletions
  1. +1
    -1
      GamecraftModdingAPI/Blocks/PlacementEngine.cs
  2. +8
    -8
      GamecraftModdingAPI/Blocks/SignalEngine.cs
  3. +18
    -6
      GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs
  4. +10
    -0
      GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs
  5. +9
    -0
      GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs
  6. +6
    -33
      GamecraftModdingAPI/GamecraftModdingAPI.csproj
  7. +2
    -2
      GamecraftModdingAPI/Main.cs
  8. +2
    -0
      GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs
  9. +0
    -17
      GamecraftModdingAPI/Utility/FullGameFields.cs
  10. +4
    -2
      GamecraftModdingAPI/Utility/Logging.cs

+ 1
- 1
GamecraftModdingAPI/Blocks/PlacementEngine.cs View File

@@ -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];
}
}
}

+ 8
- 8
GamecraftModdingAPI/Blocks/SignalEngine.cs View File

@@ -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;
}


+ 18
- 6
GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs View File

@@ -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));
}
}
}

+ 10
- 0
GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs View File

@@ -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();


+ 9
- 0
GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs View File

@@ -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();


+ 6
- 33
GamecraftModdingAPI/GamecraftModdingAPI.csproj View File

@@ -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-->



+ 2
- 2
GamecraftModdingAPI/Main.cs View File

@@ -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();


+ 2
- 0
GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs View File

@@ -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


+ 0
- 17
GamecraftModdingAPI/Utility/FullGameFields.cs View File

@@ -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


+ 4
- 2
GamecraftModdingAPI/Utility/Logging.cs View File

@@ -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


Loading…
Cancel
Save