Class AgentManagedStorage
Storage for per-agent data that requires managed types.
The Unity ECS wants component data to be unmanaged, but an agent needs to keep hold of things that cannot be: its current path, a traversal provider, user callbacks. Historically these lived in class-based IComponentData components, but those are being removed from the Entities package.
Instead each agent owns one slot in a flat array here, and refers to it through an AgentManagedRef component holding nothing but an integer.
# Threading
Reads take a single snapshot of entries and index it. Growth allocates a larger array, copies, and publishes the new reference, so a reader racing with growth keeps using the pre-growth array; that array stays alive and every slot it already contained still holds the right data.
Invariant: every write to an entry goes through one of the locked methods here, never through a snapshot the caller is holding. Growth copies entry payloads rather than aliasing them, so a write through a snapshot that growth has already superseded lands in an array nobody reads any more and is silently lost. Taking the lock re-reads entries, which is what makes a write always land in the live array.
Inner Types
Private/Protected Members
Gives a cloned agent its own copy of the managed data it currently shares with sourceSlot.
Destroys an agent entity, releasing its managed data first so that it dies immediately.
Explains the one mistake that can produce a slot which does not belong to its entity.
Slot storage.
Slots that have been freed and can be handed out again.
Guards allocation and release.