In the current state, `RemoveBatch` function cleans the `entityCache` and destroy the entities kept in memory whatever the element of the queue we want to delete.**Refactor actual code for remove items in queue.**
This entityCache stores the entities freshly created by `SpawnUnits` function ( that is used when we finish the production of the first batch in the queue) - Rename `RemoveBatch` function in `RemoveItem` to be more general.
- Remove the For-loop for find the index to a findIndex.
- Code style cleanup (var -> let, etc.).
Also clear cached entities when only its first element has removed in ProductionQueue:
- In the current state, `RemoveBatch` function cleans the `entityCache` and destroy the entities kept in memory whatever the element of the queue we want to delete.
- This entityCache stores the entities freshly created by `SpawnUnits` function ( that is used when we finish the production of the first batch in the queue).
- But when we may not be able to spawn all entities then these entities stays in the cache (to avoid being recreated) and reused until successful.
So I moved this cleaning at a better place and I managed this to be executed only when we want delete the first element of the queue.