Class DamageInfo
- Assembly
- com.electricdrill.astra-health.Runtime.dll
Container for damage pipeline state while a damage calculation is executed. Holds the amounts being transformed, the source/type metadata and accumulated prevention reasons.
public class DamageInfo : IHasPerformer, IHasTarget, IHasInstigator
- Inheritance
-
objectDamageInfo
- Implements
-
IHasPerformerIHasTargetIHasInstigator
Remarks
Built-in pipeline services (TargetBarrier, TargetStats,
PerformerStats) are pre-resolved once in the constructor so pipeline steps avoid
repeated GetComponent calls on the hot path.
Extensibility pattern for external package steps: follow the same approach used by
ApplyDamageCapStep — define your own interface, implement it on a MonoBehaviour, and
query it in your step via data.Target.TryGetComponent<IYourInterface>(out var svc).
No changes to DamageInfo are required.
Constructors
DamageInfo(PreDamageContext, IAstraHealthConfig)
Creates a new DamageInfo from the provided PreDamageContext. The constructor initializes amounts, metadata and sets pre-phase prevention reasons if applicable.
public DamageInfo(PreDamageContext pre, IAstraHealthConfig config = null)
Parameters
prePreDamageContextThe immutable pre-damage description used to initialize this instance.
configIAstraHealthConfigThe health configuration to embed in this context so pipeline steps avoid calling the static config provider on every hot-path invocation. Pass
nullin unit tests that do not exercise config-dependent steps.
Properties
Amounts
Numeric amounts and intermediate records for the damage being processed.
public DamageAmountContext Amounts { get; set; }
Property Value
Config
Active health configuration for this damage calculation. Provided by the originating EntityHealth so that pipeline steps never need to call the static config provider.
public IAstraHealthConfig Config { get; }
Property Value
CriticalMultiplier
Critical multiplier applied when IsCritical is true (1.0 means no change).
public double CriticalMultiplier { get; }
Property Value
- double
DamageSource
The origin/source of the damage (spell, environmental, trap, etc.).
public DamageSourceSO DamageSource { get; }
Property Value
Instigator
The specific thing that caused this damage — propagated from the originating
PreDamageContext. May be null if unspecified.
public IEffectInstigator Instigator { get; }
Property Value
- IEffectInstigator
IsCritical
Indicates whether the incoming hit was marked as critical.
public bool IsCritical { get; }
Property Value
- bool
IsPrevented
Returns true when accumulated reasons include a terminal prevention condition.
public bool IsPrevented { get; }
Property Value
- bool
Performer
Entity that deals the damage (may be the same as target for self damage or null for environmental damage).
public EntityCore Performer { get; }
Property Value
- EntityCore
PerformerStats
Stat reader for the performer (damage dealer), pre-resolved once in the constructor.
null for environmental damage (no performer) or when Performer is null.
public IStatReader PerformerStats { get; }
Property Value
- IStatReader
Remarks
Pipeline steps accessing piercing or offensive stats must guard against null
(environmental damage has no performer).
Under DamageStatsAttribution other than ElectricDrill.AstraRpgFramework.Ownership.EntityAttribution.Direct, this is a fallback chain: the performer's own stats (e.g. a weapon's) stay authoritative, and the resolved owner's stats (e.g. a ship's) are consulted only for stats the performer doesn't define. See ElectricDrill.AstraHealth.Damage.CalculationPipeline.ChainedStatReader.
Reasons
Reasons accumulated through the pipeline that caused damage to be prevented. This is a flag enum that can contain multiple reasons.
public DamagePreventionReason Reasons { get; }
Property Value
RoundingSettings
Rounding policy resolved from Config once for this damage calculation.
public HealthRoundingSettings RoundingSettings { get; }
Property Value
Target
Entity that is the target of this damage calculation.
public EntityCore Target { get; }
Property Value
- EntityCore
TargetBarrier
Barrier container on the target, pre-resolved once in the constructor.
null when the target has no IBarrierContainer component (e.g. non-health entities).
public IBarrierContainer TargetBarrier { get; }
Property Value
TargetStats
Stat reader for the damage target, pre-resolved once in the constructor via the
ElectricDrill.AstraRpgFramework.EntityCore → ElectricDrill.AstraRpgFramework.Stats.IStatReader implicit cast.
Returns 0 for any stat not present in the target's stat set.
null when Target is null.
public IStatReader TargetStats { get; }
Property Value
- IStatReader
TerminationStepType
DamageStep that caused termination of the pipeline.
public Type TerminationStepType { get; }
Property Value
- Type
Type
Configured damage type describing how the damage behaves (defenses, true, etc.).
public DamageTypeSO Type { get; }
Property Value
Methods
AddReason(DamagePreventionReason, Type, bool)
Adds a prevention reason to the accumulated flags and optionally marks the termination step.
public void AddReason(DamagePreventionReason reason, Type stepType, bool terminate = true)
Parameters
reasonDamagePreventionReasonReason to add.
stepTypeTypeType of the step that added the reason (can be null for pre-phase).
terminateboolIf true and the termination step is not already set, records
stepTypeas the termination cause.