Interface ISystemHookCapability
- Namespace
- KeenEyes.Capabilities
- Assembly
- KeenEyes.Abstractions.dll
Capability interface for adding system hooks to an ECS world.
public interface ISystemHookCapability
Examples
public void Install(IPluginContext context)
{
if (!context.TryGetCapability<ISystemHookCapability>(out var hookCapability))
{
throw new InvalidOperationException("Plugin requires system hook capability");
}
hookSubscription = hookCapability.AddSystemHook(
beforeHook: (system, dt) => profiler.BeginSystem(system.GetType().Name),
afterHook: (system, dt) => profiler.EndSystem()
);
}
Remarks
System hooks enable cross-cutting concerns such as profiling, logging, conditional execution, and metrics collection without modifying individual systems.
Plugins that need to hook into system execution should request this capability via GetCapability<T>() rather than casting World to the concrete World type.
Methods
AddSystemHook(SystemHook?, SystemHook?, SystemPhase?)
Adds global hooks that execute before and/or after every system in the world.
EventSubscription AddSystemHook(SystemHook? beforeHook = null, SystemHook? afterHook = null, SystemPhase? phase = null)
Parameters
beforeHookSystemHookOptional hook to execute before each system runs.
afterHookSystemHookOptional hook to execute after each system completes.
phaseSystemPhase?Optional phase filter. If specified, hooks only execute for systems in this phase.
Returns
- EventSubscription
A subscription that can be disposed to remove the hooks.
Exceptions
- ArgumentException
Thrown when both beforeHook and afterHook are null.