Table of Contents

Class DamageInfo

Namespace
ElectricDrill.AstraHealth.Damage.CalculationPipeline
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
object
DamageInfo
Implements
IHasPerformer
IHasTarget
IHasInstigator

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

pre PreDamageContext

The immutable pre-damage description used to initialize this instance.

config IAstraHealthConfig

The health configuration to embed in this context so pipeline steps avoid calling the static config provider on every hot-path invocation. Pass null in 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

DamageAmountContext

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

IAstraHealthConfig

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

DamageSourceSO

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).

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

DamagePreventionReason

RoundingSettings

Rounding policy resolved from Config once for this damage calculation.

public HealthRoundingSettings RoundingSettings { get; }

Property Value

HealthRoundingSettings

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

IBarrierContainer

TargetStats

Stat reader for the damage target, pre-resolved once in the constructor via the ElectricDrill.AstraRpgFramework.EntityCoreElectricDrill.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

DamageTypeSO

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

reason DamagePreventionReason

Reason to add.

stepType Type

Type of the step that added the reason (can be null for pre-phase).

terminate bool

If true and the termination step is not already set, records stepType as the termination cause.