using UnityEngine; namespace SepCore.Simulation { public sealed partial class SimulationWorld { [Header("Projectile Simulation")] [Tooltip("Recycle projectile when horizontal distance to player exceeds this range. <=0 disables this rule.")] [SerializeField] private float _projectileMaxDistanceFromPlayer = 120f; [Tooltip("Recycle projectile when vertical offset to player exceeds this range. <=0 disables this rule.")] [SerializeField] private float _projectileMaxVerticalOffsetFromPlayer = 30f; #region Projectile Cleanup private void RecycleInactiveAndExpiredProjectiles() { _projectileRecycleEntityIds.Clear(); for (int i = 0; i < _projectiles.Count; i++) { ProjectileLifeSim life = _projectiles.Life[i]; if (life.Active && (life.LifeTime <= 0f || life.Age < life.LifeTime)) { continue; } _projectileRecycleEntityIds.Add(_projectiles.Identity[i].EntityId); } if (_projectileRecycleEntityIds.Count == 0) { return; } var entityComponent = GameEntry.Entity; for (int i = 0; i < _projectileRecycleEntityIds.Count; i++) { int entityId = _projectileRecycleEntityIds[i]; if (entityComponent != null) { entityComponent.HideEntity(entityId); } RemoveProjectileByEntityId(entityId); } _projectileRecycleEntityIds.Clear(); } #endregion } }