feat(app): wire IGameState+IEvents into Program and SmokePlugin

Pass WorldGameState and WorldEvents into GameWindow so OnLoad fires
FireEntitySpawned and Add for each hydrated entity. SmokePlugin now
subscribes to EntitySpawned in Enable(), unsubscribes in Disable(),
and logs the replay count at subscribe time and total seen at disable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-10 20:31:50 +02:00
parent 0c0c042dca
commit 08097b6c7e
3 changed files with 40 additions and 6 deletions

View file

@ -5,6 +5,7 @@ namespace AcDream.Plugins.Smoke;
public sealed class SmokePlugin : IAcDreamPlugin
{
private IPluginHost? _host;
private int _entitiesSeen;
public void Initialize(IPluginHost host)
{
@ -12,6 +13,22 @@ public sealed class SmokePlugin : IAcDreamPlugin
_host.Log.Info("smoke plugin initialized");
}
public void Enable() => _host?.Log.Info("smoke plugin enabled");
public void Disable() => _host?.Log.Info("smoke plugin disabled");
public void Enable()
{
_host?.Log.Info("smoke plugin enabled");
if (_host is not null)
{
_host.Events.EntitySpawned += OnEntitySpawned;
_host.Log.Info($"smoke plugin sees {_entitiesSeen} entities (replay count at subscribe)");
}
}
public void Disable()
{
if (_host is not null)
_host.Events.EntitySpawned -= OnEntitySpawned;
_host?.Log.Info($"smoke plugin disabled (saw {_entitiesSeen} entities total)");
}
private void OnEntitySpawned(WorldEntitySnapshot snapshot) => _entitiesSeen++;
}