Class AbilityPrefabColliderCache
Static cache of prefab colliders keyed by ability template ID. Extracted from AbilityObject to keep that class focused on lifecycle and collision. Avoids repeated GetComponent calls on the prefab every spawn.
public static class AbilityPrefabColliderCache
- Inheritance
-
AbilityPrefabColliderCache
- Inherited Members
Methods
Clear()
Clears the cache. Call after addressable bundle reloads to prevent stale collider references.
public static void Clear()
GetPrefabCollider(AbilityTemplate)
Returns the cached Collider from the ability's prefab, or null if none exists. Caches on first access. Detects and self-heals stale entries from addressable reloads.
public static Collider GetPrefabCollider(AbilityTemplate template)
Parameters
templateAbilityTemplateThe ability template whose prefab collider to get.
Returns
- Collider
The cached Collider from the prefab, or null if the prefab has no Collider.
ResolveShapeHalfExtents(Collider)
Clears the cache on domain reload (e.g., after entering Play Mode in the Editor).
public static Vector3 ResolveShapeHalfExtents(Collider collider)
Parameters
colliderCollider
Returns
- Vector3
Remarks
GetPrefabCollider(AbilityTemplate) hands back the PREFAB ASSET's collider. A collider that
has never been simulated — a prefab asset, an inactive object — reports an EMPTY bounds,
so anything derived from its bounds is silently zero. That is how a Forward-spawned
Punch came to sit centred on its caster's own surface, half of it inside the caster,
while the AI (already shape-based, see AIAbilityReach) planned as if the volume
reached a full size further: an orc stopped "in reach" and punched the air in front of
the player. Every consumer of the prefab collider's size goes through here so spawn
geometry and reach can never disagree again.