🔥 Health — Damage Affinities¶
📦 Folder Overview¶
This folder contains affinity providers and authoring assets used by the Health system.
Affinities define how effective different damage types are against a target.
They implement IDamageAffinity and are typically consumed by rules such as AffinityRule.
🎯 Purpose¶
Affinities provide:
- Per-tag damage multipliers
- Data-driven resist and weakness systems
- Composable victim-side behaviour
They answer:
How effective is this damage type against this target?
🧩 What Lives Here¶
AffinityProfile (ScriptableObject)¶
Reusable table mapping DamageTag to multipliers.
Behaviour:
- Supports multi-tag masks
- Matching entries multiply together
- Returns
nullwhen no match is found
Use cases:
- Enemy archetypes
- Elemental systems
- Equipment sets
- Faction modifiers
AffinityProfileProvider (MonoBehaviour)¶
Bridges a profile into runtime.
Behaviour:
- Implements
IDamageAffinity - Delegates lookup to assigned profile
- Returns
nullwhen no match or profile is missing
Use cases:
- Shared tuning data
- Centralised balancing
SimpleAffinityProvider (MonoBehaviour)¶
Inline affinity configuration.
Behaviour:
- Inspector-based entries
- Same matching and multiplication rules
- Local to prefab
Use cases:
- Prototyping
- One-off overrides
⚠️ Important Notes¶
Evaluation Model¶
Affinities are consumed by rules (typically AffinityRule).
The rule is responsible for:
- Enumerating tags
- Querying all
IDamageAffinityproviders - Combining results (commonly multiplicative)
- Handling special values such as
0
Provider Contract¶
Implementations should:
- Return
nullfor no opinion - Return values ≥ 0
- Avoid allocations where possible
- Remain side-effect free
Common conventions:
| Value | Meaning |
|---|---|
| 0 | immune |
| 0.5 | resist |
| 1 | normal |
| >1 | weak |
Boundaries¶
Do not:
- Return
1to indicate no opinion (usenull) - Mix flat mitigation into affinity logic
- Depend on execution order
- Assume healing is affected
Affinities provide inputs only; behaviour is defined by rules.
🧠 Usage Guidance¶
Typical setup:
- Add
DamageRuleHub - Add
AffinityRule -
Add one or more providers:
-
AffinityProfileProvider SimpleAffinityProvider- Configure values
🔗 Related Documentation¶
- Damage Rules (AffinityRule)
- Contracts (
DamageTag,DamageContext) - Health Abstractions