Namespace ElectricDrill.AstraRpgFramework.Contexts
Interfaces
- IEffectInstigator
Marker interface for anything that can be the specific cause of a game effect: an ability definition, a modifier definition or instance, a passive skill, a game system, etc.
Unlike IEffectInstigator — which identifies the entity responsible for an effect — IEffectInstigator identifies the specific thing that produced it.
Consumers use pattern matching (
instigator is MyType t) to identify and react to specific instigator types. This design places no constraints on what an instigator must expose, and allows any future type to participate without changes to this interface.
- IHasEntity
Contract for objects that can provide a reference to their primary EntityCore.
Implemented by two categories:
- Entity components (e.g. EntityCore, EntityStats) where Entity returns the component's own owning entity.
- Event context payloads (e.g. context classes) where Entity returns the primary subject of the event.
This interface enables GameAction<TContext> families typed on IHasEntity to accept both entity components and any domain context that carries an entity reference, bridging the two worlds without requiring inheritance.
- IHasInstigator
Contract for contexts that carry a reference to the specific cause of the effect.
This complements IEffectInstigator (which identifies the responsible entity) by identifying the specific thing — such as an ability, modifier, passive skill, or game system — that produced the effect.
Instigator is nullable: not every effect has a meaningful specific cause beyond its source entity and category (IEffectInstigator + DamageSourceSO / HealSourceSO).
Typical usage:
// Prevent infinite loops: ignore effects caused by this modifier itself if (ctx.Instigator == this.Definition) return;// React only to effects from a specific source type if (ctx.Instigator is AbilityDefinitionSO ability && ability.IsUltimate) ApplyStrengthBuff(ctx.Target);
- IHasPerformer
Contract for objects that expose the entity that performed an action (e.g. the damage dealer, the healer, the entity that triggered an effect). May be
nullwhen the effect has no entity origin (system-initiated, environmental, or engine-driven).
- IInvalidatable
Interface for objects that act as the origin of downstream state and can notify dependents when they are no longer valid — due to entity death, object pooling, aura deactivation, etc.
OnInvalidated is raised when the object becomes invalid. Subscribers should clean up any state that depends on this object (e.g. modifier instances applied by this source).
Invalidate() can be called explicitly by any system that governs the object's lifetime (e.g.
EntityHealthcalls it on entity death; an object pool calls it before returning an instance to the pool). OnInvalidated is also raised automatically fromOnDestroyonEntityCoreas a safety net for GameObject destruction.