init mod
This commit is contained in:
commit
5e0a12b038
23 files changed
+1650
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using Cthangover.Core.Events;
|
||||
using Cthangover.Core.Interactive;
|
||||
using Cthangover.Core.Mods;
|
||||
using Cthangover.Core.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cthangover.Mods.Interactive
|
||||
{
|
||||
/// <summary>
|
||||
/// Engine-mod initializer for the interactive subsystem. Takes over the
|
||||
/// lifecycle <c>SceneContextNode</c> owned before the migration: on
|
||||
/// resources-ready it initializes the <c>InteractiveManager</c> singleton
|
||||
/// and subscribes the per-scene teardown (<c>InteractiveManager.Shutdown</c>)
|
||||
/// to <c>SceneExitedEvent</c>, so tracked interactive objects are destroyed
|
||||
/// on every scene change. All operations are idempotent:
|
||||
/// <c>ModManager.Reload()</c> re-runs <c>OnModResourcesReady</c>, so repeat
|
||||
/// invocations must not corrupt state.
|
||||
/// </summary>
|
||||
public class InteractiveModInitializer : IModInitializer
|
||||
{
|
||||
private static bool initialized;
|
||||
|
||||
/// <summary>No per-mod setup is required; lifecycle happens on resources-ready.</summary>
|
||||
public void OnModLoaded(string modId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the manager singleton and wires the scene-exit teardown.
|
||||
/// Safe to call again after a mod reload.
|
||||
/// </summary>
|
||||
public void OnModResourcesReady()
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
InteractiveManager.Initialize();
|
||||
GameLogger.Log("INTERACTIVE", "InteractiveModInitializer: manager initialized");
|
||||
|
||||
ModEventBus.Subscribe<SceneExitedEvent>(_ => InteractiveManager.Shutdown());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user