💚 Health — Heal Rules¶
📦 Folder Overview¶
This folder contains healing-side rule components that plug into HealRuleHub.
Heal rules define how healing is modified and observed as it flows through HealthSystem.
All heal rules are:
- Modular
- Priority-driven
- Designed to avoid allocations in hot paths
- Composable per prefab
🎯 Purpose¶
Provide a composable, priority-driven pipeline for healing behaviour without modifying core systems.
🧩 What Lives Here¶
PRE Rules¶
- Implement
IHealRule - Mutate
HealContextbefore healing is applied
POST Observers¶
- Implement
IPostHealRule - Observe finalized results after evaluation
🧠 Usage Guidance¶
Basic Usage¶
- Add
HealRuleHubto a GameObject withHealthSystem - Add rule components from this folder
- PRE rules run in ascending
Priority - POST observers run after evaluation completes (execution for rejected heals is implementation-defined)
No heal rules are required by default.
Common Priority Bands¶
| Priority | Purpose | Example Rules |
|---|---|---|
| 0–99 | Custom gates | — |
| 100 | Anti-heal | AntiHealRule |
| 200 | Heal boosts | LowHPHealBoostRule |
| 999 | Post reactions | HealEventPostRule, HealSFXPostRule, HealVFXPostRule |
See HealRulePriority.cs for canonical constants.
⚠️ Important Notes¶
PRE Rule Behaviour¶
PRE rules may:
- Modify
MultiplierorFlatDelta - Set
ctx.Cancelled = true - Return
falseto stop further rule execution
POST Rule Behaviour¶
POST rules:
- Do not mutate health state
- React to finalized results only
- Use
ctx.FinalAppliedwhen healing is applied
Boundaries¶
Heal rules should not:
- Apply healing directly
- Assume ordering beyond
Priority - Implement regeneration systems
- Encode networking or authority logic
- Include UI logic in PRE rules
Rules operate on context and act as extensions, not owners.
🧩 Components¶
AntiHealRule (priority 100)¶
- Reduces or blocks healing
- Uses
healMultiplierand optionalblockChance - May scale or cancel healing
LowHPHealBoostRule (priority 200)¶
- Boosts healing when health is below a threshold
- Multiplies
ctx.Multiplier - Stacks with other modifiers
HealEventPostRule¶
- Emits a
UnityEvent<int>with applied heal amount - Includes rate limiting
HealSFXPostRule¶
- Plays an
AudioClipwhen healing applies - Ensures an
AudioSourceexists
HealVFXPostRule¶
- Spawns VFX on heal
- Optional scaling based on
FinalApplied - Includes rate limiting
🔗 Related Documentation¶
- Rules Overview
- Damage Rules
- Rules Abstractions
- Handlers