Browse Source

Implement missing events

tags/v0.1.1.0
NGnius (Graham) 5 years ago
parent
commit
fae054b72b
23 changed files with 353 additions and 79 deletions
  1. +1
    -1
      GamecraftModdingAPI/Commands/CommandPatch.cs
  2. +1
    -1
      GamecraftModdingAPI/Commands/ICustomCommandEngine.cs
  3. +6
    -4
      GamecraftModdingAPI/Events/EventType.cs
  4. +29
    -0
      GamecraftModdingAPI/Events/GameActivatedPatch.cs
  5. +27
    -0
      GamecraftModdingAPI/Events/GameReloadedPatch.cs
  6. +27
    -0
      GamecraftModdingAPI/Events/GameSwitchedToPatch.cs
  7. +24
    -1
      GamecraftModdingAPI/Events/IEventEmitterEngine.cs
  8. +7
    -1
      GamecraftModdingAPI/Events/IEventHandlerEngine.cs
  9. +4
    -1
      GamecraftModdingAPI/Events/Manager.cs
  10. +4
    -1
      GamecraftModdingAPI/Events/MenuActivatedPatch.cs
  11. +27
    -0
      GamecraftModdingAPI/Events/MenuSwitchedToPatch.cs
  12. +3
    -0
      GamecraftModdingAPI/Events/ModEventEntityDescriptor.cs
  13. +6
    -2
      GamecraftModdingAPI/Events/ModEventEntityStruct.cs
  14. +27
    -6
      GamecraftModdingAPI/Events/SimpleEventEmitterEngine.cs
  15. +39
    -6
      GamecraftModdingAPI/Events/SimpleEventHandlerEngine.cs
  16. +1
    -11
      GamecraftModdingAPI/GamecraftModdingAPI.csproj
  17. +8
    -6
      GamecraftModdingAPI/Main.cs
  18. +0
    -26
      GamecraftModdingAPI/Properties/Settings.Designer.cs
  19. +0
    -6
      GamecraftModdingAPI/Properties/Settings.settings
  20. +31
    -5
      GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs
  21. +25
    -1
      GamecraftModdingAPI/Utility/Logging.cs
  22. +27
    -0
      GamecraftModdingAPI/Utility/MinimumSpecsCheckPatch.cs
  23. +29
    -0
      GamecraftModdingAPI/Utility/SteamInitPatch.cs

+ 1
- 1
GamecraftModdingAPI/Commands/CommandPatch.cs View File

@@ -16,7 +16,7 @@ using GamecraftModdingAPI.Utility;
namespace GamecraftModdingAPI.Commands
{
[HarmonyPatch]
class CommandPatch
public static class CommandPatch
{
public static void Prefix(UnityContext<FullGameCompositionRoot> contextHolder, EnginesRoot enginesRoot, World physicsWorld, Action reloadGame, MultiplayerInitParameters multiplayerParameters)
{


+ 1
- 1
GamecraftModdingAPI/Commands/ICustomCommandEngine.cs View File

@@ -7,7 +7,7 @@ using Svelto.ECS;

namespace GamecraftModdingAPI.Commands
{
interface ICustomCommandEngine : IEngine, IQueryingEntitiesEngine
public interface ICustomCommandEngine : IEngine, IQueryingEntitiesEngine
{
string Name { get; }



+ 6
- 4
GamecraftModdingAPI/Events/EventType.cs View File

@@ -6,14 +6,16 @@ using System.Threading.Tasks;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// Built-in event types.
/// These are configured to fire when the API is initialized.
/// </summary>
public enum EventType
{
ApplicationInitialized,
MenuActivated,
MenuDestroyed,
Menu,
MenuSwitchedTo,
GameActivated,
GameDestroyed,
Game,
GameReloaded,
GameSwitchedTo
}


+ 29
- 0
GamecraftModdingAPI/Events/GameActivatedPatch.cs View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Harmony;
using RobocraftX;
using Svelto.ECS;

using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
/// </summary>
[HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateGame")]
class GameActivatedPatch
{
public static void Postfix(ref EnginesRoot ____mainGameEnginesRoot)
{
// A new EnginesRoot is always created when ActivateGame is called
// so all event emitters and handlers must be re-registered.
Manager.RegisterEngines(____mainGameEnginesRoot);
Logging.Log("Dispatching Game Activated event");
Manager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit();
}
}
}

+ 27
- 0
GamecraftModdingAPI/Events/GameReloadedPatch.cs View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Harmony;
using RobocraftX;
using Svelto.ECS;

using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.ReloadGame()
/// </summary>
[HarmonyPatch(typeof(FullGameCompositionRoot), "ReloadGame")]
class GameReloadedPatch
{
public static void Postfix()
{
// Event emitters and handlers should already be registered by GameActivatedPatch
Logging.Log("Dispatching Game Reloaded event");
Manager.GetEventEmitter("GamecraftModdingAPIGameReloadedEventEmitter").Emit();
}
}
}

+ 27
- 0
GamecraftModdingAPI/Events/GameSwitchedToPatch.cs View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Harmony;
using RobocraftX;
using Svelto.ECS;

using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.SwitchToGame()
/// </summary>
[HarmonyPatch(typeof(FullGameCompositionRoot), "SwitchToGame")]
class GameSwitchedToPatch
{
public static void Postfix()
{
// Event emitters and handlers should already be registered by GameActivated event
Logging.Log("Dispatching Game Switched To event");
Manager.GetEventEmitter("GamecraftModdingAPIGameSwitchedToEventEmitter").Emit();
}
}
}

+ 24
- 1
GamecraftModdingAPI/Events/IEventEmitterEngine.cs View File

@@ -7,13 +7,36 @@ using Svelto.ECS;

namespace GamecraftModdingAPI.Events
{
public interface IEventEmitterEngine : IEngine, IQueryingEntitiesEngine
/// <summary>
/// Engine interface to create a ModEventEntityStruct in entitiesDB when Emit() is called.
/// </summary>
public interface IEventEmitterEngine : IEngine, IQueryingEntitiesEngine, IDisposable
{
/// <summary>
/// The name of the IEventEmitterEngine
/// </summary>
string Name { get; }

/// <summary>
/// The type of event emitted
/// </summary>
object type { get; }

/// <summary>
/// Whether the emitter can be removed with Manager.RemoveEventEmitter(name)
/// </summary>
bool isRemovable { get; }

/// <summary>
/// The EntityFactory for the entitiesDB.
/// Use this to create a ModEventEntityStruct when Emit() is called.
/// </summary>
IEntityFactory Factory { set; }

/// <summary>
/// Emit the event so IEventHandlerEngines can handle it.
/// Call Emit() to trigger the IEventEmitterEngine's event.
/// </summary>
void Emit();
}
}

+ 7
- 1
GamecraftModdingAPI/Events/IEventHandlerEngine.cs View File

@@ -8,8 +8,14 @@ using Svelto.ECS.Internal;

namespace GamecraftModdingAPI.Events
{
public interface IEventHandlerEngine : IEngine, IQueryingEntitiesEngine, IReactOnAddAndRemove<ModEventEntityStruct>, IReactOnAddAndRemove
/// <summary>
/// Engine interface to handle ModEventEntityStruct events emitted by IEventEmitterEngines.
/// </summary>
public interface IEventHandlerEngine : IEngine, IQueryingEntitiesEngine, IReactOnAddAndRemove<ModEventEntityStruct>, IReactOnAddAndRemove, IDisposable
{
/// <summary>
/// The name of the IEventHandlerEngine
/// </summary>
string Name { get; }
}
}

+ 4
- 1
GamecraftModdingAPI/Events/Manager.cs View File

@@ -78,7 +78,10 @@ namespace GamecraftModdingAPI.Events

public static void RemoveEventEmitter(string name)
{
_eventEmitters.Remove(name);
if (_eventEmitters[name].isRemovable)
{
_eventEmitters.Remove(name);
}
}

public static void RegisterEngines(EnginesRoot enginesRoot)


GamecraftModdingAPI/Events/GameInitPatch.cs → GamecraftModdingAPI/Events/MenuActivatedPatch.cs View File

@@ -11,8 +11,11 @@ using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateMenu()
/// </summary>
[HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateMenu")]
class GameInitPatch
class MenuActivatedPatch
{

private static bool firstLoad = true;

+ 27
- 0
GamecraftModdingAPI/Events/MenuSwitchedToPatch.cs View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Harmony;
using RobocraftX;
using Svelto.ECS;

using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.SwitchToMenu()
/// </summary>
[HarmonyPatch(typeof(FullGameCompositionRoot), "SwitchToMenu")]
class MenuSwitchedToPatch
{
public static void Postfix()
{
// Event emitters and handlers should already be registered by MenuActivated event
Logging.Log("Dispatching Menu Switched To event");
Manager.GetEventEmitter("GamecraftModdingAPIMenuSwitchedToEventEmitter").Emit();
}
}
}

+ 3
- 0
GamecraftModdingAPI/Events/ModEventEntityDescriptor.cs View File

@@ -7,6 +7,9 @@ using Svelto.ECS;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// EntityDescriptor for creating ModEventEntityStructs
/// </summary>
public class ModEventEntityDescriptor : GenericEntityDescriptor<ModEventEntityStruct>
{
}


+ 6
- 2
GamecraftModdingAPI/Events/ModEventEntityStruct.cs View File

@@ -8,10 +8,14 @@ using Svelto.ECS.Hybrid;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// The event entity struct
/// </summary>
public struct ModEventEntityStruct : IEntityStruct
{
/// <summary>
/// The type of event that has been emitted
/// </summary>
public object type;

public EGID ID { get; set; }
}
}

+ 27
- 6
GamecraftModdingAPI/Events/SimpleEventEmitterEngine.cs View File

@@ -8,36 +8,57 @@ using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// A simple implementation of IEventEmitterEngine sufficient for most uses
/// </summary>
class SimpleEventEmitterEngine : IEventEmitterEngine
{
public string Name { get; set; }
public object type { get; set; }

public bool isRemovable { get; }

public IEntityFactory Factory { private get; set; }

public IEntitiesDB entitiesDB { set; private get; }

public void Ready() { }

/// <summary>
/// Emit the event
/// </summary>
public void Emit()
{
Factory.BuildEntity<ModEventEntityDescriptor>(ApiExclusiveGroups.eventID++, ApiExclusiveGroups.eventsExclusiveGroup)
.Init(new ModEventEntityStruct
{
type = type
});
.Init(new ModEventEntityStruct { type = type });
}

public SimpleEventEmitterEngine(EventType type, string name)
public void Dispose() { }

/// <summary>
/// Construct the engine
/// </summary>
/// <param name="type">The EventType to use for ModEventEntityStruct.type</param>
/// <param name="name">The name of this engine</param>
/// <param name="isRemovable">Will removing this engine not break your code?</param>
public SimpleEventEmitterEngine(EventType type, string name, bool isRemovable = true)
{
this.type = type;
this.Name = name;
this.isRemovable = isRemovable;
}

public SimpleEventEmitterEngine(object type, string name)
/// <summary>
/// Construct the engine
/// </summary>
/// <param name="type">The object to use for ModEventEntityStruct.type</param>
/// <param name="name">The name of this engine</param>
/// <param name="isRemovable">Will removing this engine not break your code?</param>
public SimpleEventEmitterEngine(object type, string name, bool isRemovable = true)
{
this.type = type;
this.Name = name;
this.isRemovable = isRemovable;
}
}
}

+ 39
- 6
GamecraftModdingAPI/Events/SimpleEventHandlerEngine.cs View File

@@ -7,12 +7,19 @@ using System.Threading.Tasks;

namespace GamecraftModdingAPI.Events
{
/// <summary>
/// A simple implementation of IEventHandlerEngine sufficient for most uses
/// </summary>
class SimpleEventHandlerEngine : IEventHandlerEngine
{
public object type { get; set; }
public string Name { get; set; }

private readonly Action<IEntitiesDB> onEvent;
private bool isActivated = false;

private readonly Action<IEntitiesDB> onActivated;

private readonly Action<IEntitiesDB> onDestroyed;

public IEntitiesDB entitiesDB { set; private get; }

@@ -20,21 +27,47 @@ namespace GamecraftModdingAPI.Events
{
if (entityView.type.Equals(this.type))
{
onEvent.Invoke(entitiesDB);
isActivated = true;
onActivated.Invoke(entitiesDB);
}
}

public void Ready() { }

public void Remove(ref ModEventEntityStruct entityView, EGID egid) { }
public void Remove(ref ModEventEntityStruct entityView, EGID egid)
{
if (entityView.type.Equals(this.type) && isActivated)
{
isActivated = false;
onDestroyed.Invoke(entitiesDB);
}
}

public void Dispose()
{
if (isActivated)
{
isActivated = false;
onDestroyed.Invoke(entitiesDB);
}
}

public SimpleEventHandlerEngine(Action handleEvent, object type, string name) : this((IEntitiesDB db) => { handleEvent.Invoke(); }, type, name) { }
/// <summary>
///
/// </summary>
/// <param name="activated"></param>
/// <param name="removed"></param>
/// <param name="type"></param>
/// <param name="name"></param>
public SimpleEventHandlerEngine(Action activated, Action removed, object type, string name)
: this((IEntitiesDB _) => { activated.Invoke(); }, (IEntitiesDB _) => { removed.Invoke(); }, type, name) { }
public SimpleEventHandlerEngine(Action<IEntitiesDB> handleEvent, object type, string name)
public SimpleEventHandlerEngine(Action<IEntitiesDB> activated, Action<IEntitiesDB> removed, object type, string name)
{
this.type = type;
this.Name = name;
this.onEvent = handleEvent;
this.onActivated = activated;
this.onDestroyed = removed;
}
}
}

+ 1
- 11
GamecraftModdingAPI/GamecraftModdingAPI.csproj View File

@@ -537,17 +537,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Folder Include="Properties\" />
</ItemGroup>
<!--End Dependencies-->



+ 8
- 6
GamecraftModdingAPI/Main.cs View File

@@ -21,12 +21,14 @@ namespace GamecraftModdingAPI
harmony = HarmonyInstance.Create(currentAssembly.GetName().Name);
harmony.PatchAll(currentAssembly);
}
// create default event objects
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("App Inited event!"); },
EventType.ApplicationInitialized, "appinit API debug"));
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.ApplicationInitialized, "GamecraftModdingAPIApplicationInitializedEventEmitter"));
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.MenuActivated, "GamecraftModdingAPIMenuActivatedEventEmitter"));
Logging.Log($"{currentAssembly.GetName().Name} {currentAssembly.GetName().Version} start & patch complete");
// create default event emitters
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.ApplicationInitialized, "GamecraftModdingAPIApplicationInitializedEventEmitter", false));
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Menu, "GamecraftModdingAPIMenuActivatedEventEmitter", false));
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.MenuSwitchedTo, "GamecraftModdingAPIMenuSwitchedToEventEmitter", false)); // TODO
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Game, "GamecraftModdingAPIGameActivatedEventEmitter", false));
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameReloaded, "GamecraftModdingAPIGameReloadedEventEmitter", false)); // TODO
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameSwitchedTo, "GamecraftModdingAPIGameSwitchedToEventEmitter", false)); // TODO
Logging.Log($"{currentAssembly.GetName().Name} {currentAssembly.GetName().Version} init & patch complete");
}

public static void Shutdown()


+ 0
- 26
GamecraftModdingAPI/Properties/Settings.Designer.cs View File

@@ -1,26 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace GamecraftModdingAPI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

+ 0
- 6
GamecraftModdingAPI/Properties/Settings.settings View File

@@ -1,6 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>

+ 31
- 5
GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs View File

@@ -1,20 +1,24 @@
using System;
using UnityEngine;
using Harmony;
using System.Reflection;
using Harmony;
using GamecraftModdingAPI.Events;
using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Tests
{
// unused by design
public class GamecraftModdingAPIPluginTest //: IllusionPlugin.IEnhancedPlugin
public class GamecraftModdingAPIPluginTest
#if DEBUG
: IllusionPlugin.IEnhancedPlugin
#endif
{
public static HarmonyInstance harmony { get; protected set; }

public string[] Filter { get; } = new string[] { "Gamecraft" };

public string Name { get; } = "Gamecraft Modding API";
public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;

public string Version { get; } = "v0.1.0.A";
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();

public string HarmonyID { get; } = "org.git.exmods.modtainers.gamecraftmoddingapi";

@@ -26,6 +30,28 @@ namespace GamecraftModdingAPI.Tests
public void OnApplicationStart()
{
GamecraftModdingAPI.Main.Init();
// in case Steam is not installed/running
// this will crash the game slightly later during startup
//SteamInitPatch.ForcePassSteamCheck = true;
// in case running in a VM
//MinimumSpecsCheckPatch.ForcePassMinimumSpecCheck = true;

// debug/test handlers
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("App Inited event!"); }, () => { },
EventType.ApplicationInitialized, "appinit API debug"));
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Menu Activated event!"); },
() => { Logging.Log("Menu Destroyed event!"); },
EventType.Menu, "menuact API debug"));
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Menu Switched To event!"); }, () => { },
EventType.MenuSwitchedTo, "menuswitch API debug"));
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Game Activated event!"); },
() => { Logging.Log("Game Destroyed event!"); },
EventType.Game, "gameact API debug"));
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Game Reloaded event!"); }, () => { },
EventType.GameReloaded, "gamerel API debug"));
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("Game Switched To event!"); }, () => { },
EventType.GameSwitchedTo, "gameswitch API debug"));

}

public void OnFixedUpdate() { }


+ 25
- 1
GamecraftModdingAPI/Utility/Logging.cs View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -135,7 +136,7 @@ namespace GamecraftModdingAPI.Utility
}

/// <summary>
/// Write a message to stdout (usually the terminal which is running, like Command Prompt or PowerShell)
/// Write a message to stdout (ie the terminal, like Command Prompt or PowerShell)
/// </summary>
/// <param name="obj">The object to log</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -143,5 +144,28 @@ namespace GamecraftModdingAPI.Utility
{
Svelto.Console.SystemLog(obj.ToString());
}

/// <summary>
/// Write a descriptive message to Gamecraft's log only when the API is a Debug build
/// </summary>
/// <param name="obj">The object to log</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MetaDebugLog(object obj)
{
#if DEBUG
MetaLog($"[MetaDebug]{obj.ToString()}");
#endif
}

/// <summary>
/// Write a descriptive message to Gamecraft's log including the current time and the DLL's name
/// </summary>
/// <param name="obj">The object to log</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MetaLog(object obj)
{
var callAsm = Assembly.GetCallingAssembly();
Log($"[{DateTime.Now.ToString()}][{callAsm.GetName().Name}]{obj.ToString()}");
}
}
}

+ 27
- 0
GamecraftModdingAPI/Utility/MinimumSpecsCheckPatch.cs View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Harmony;
using RobocraftX.FrontEnd;

namespace GamecraftModdingAPI.Utility
{
/// <summary>
/// Patch of bool RobocraftX.FrontEnd.MinimumSpecsCheck.CheckRequirementsMet()
/// </summary>
[HarmonyPatch(typeof(MinimumSpecsCheck), "CheckRequirementsMet")]
class MinimumSpecsCheckPatch
{
/// <summary>
/// Ignore result of the requirement check?
/// </summary>
public static bool ForcePassMinimumSpecCheck = false;

public static void Postfix(ref bool __result)
{
__result = __result || ForcePassMinimumSpecCheck;
}
}
}

+ 29
- 0
GamecraftModdingAPI/Utility/SteamInitPatch.cs View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Harmony;
using RobocraftX.Common;

namespace GamecraftModdingAPI.Utility
{
/// <summary>
/// Patch of bool RobocraftX.Common.SteamManager.VerifyOrInit()
/// This does not let you run Gamecraft without Steam.
/// DO NOT USE!
/// </summary>
[HarmonyPatch(typeof(SteamManager), "VerifyOrInit")]
class SteamInitPatch
{
/// <summary>
/// Ignore the result of steam initialization?
/// </summary>
public static bool ForcePassSteamCheck = false;

public static void Postfix(ref bool __result)
{
__result = __result || ForcePassSteamCheck;
}
}
}

Loading…
Cancel
Save