// MIT License - Copyright (c) 2025 wallstop
// Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE
#if ZENJECT_PRESENT
namespace WallstopStudios.UnityHelpers.Integrations.Zenject
{
using global::Zenject;
using UnityEngine;
///
/// MemoryPool that assigns relational fields for spawned items automatically.
///
/// Component type managed by the pool.
public class RelationalMemoryPool : MemoryPool
where TValue : Component
{
[Inject]
internal DiContainer _container = null;
protected override void OnSpawned(TValue item)
{
base.OnSpawned(item);
_container.AssignRelationalComponents(item);
}
internal void InternalOnSpawned(TValue item) => OnSpawned(item);
}
///
/// MemoryPool with one spawn parameter that assigns relational fields for spawned items.
///
/// Spawn parameter type.
/// Component type managed by the pool.
public class RelationalMemoryPool : MemoryPool
where TValue : Component
{
[Inject]
internal DiContainer _container = null;
protected override void Reinitialize(TParam1 p1, TValue item)
{
base.Reinitialize(p1, item);
_container.AssignRelationalComponents(item);
}
}
}
#endif