acdream/src/AcDream.Plugins.Smoke/SmokePlugin.cs
Erik 08097b6c7e 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>
2026-04-10 20:31:50 +02:00

34 lines
919 B
C#

using AcDream.Plugin.Abstractions;
namespace AcDream.Plugins.Smoke;
public sealed class SmokePlugin : IAcDreamPlugin
{
private IPluginHost? _host;
private int _entitiesSeen;
public void Initialize(IPluginHost host)
{
_host = host;
_host.Log.Info("smoke plugin initialized");
}
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++;
}