// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. #pragma once #include "Object.h" /// /// Removing old objects service. Your friendly garbage collector! /// class FLAXENGINE_API ObjectsRemovalService { public: /// /// Determines whether object has been registered in the pool for the removing. /// /// The object. /// True if object has been registered in the pool for the removing, otherwise false. static bool IsInPool(Object* obj); /// /// Removes the specified object from the dead pool (clears the reference to it). /// /// The object. static void Dereference(Object* obj); /// /// Adds the specified object to the dead pool. /// /// The object. /// The time to live (in seconds). /// True if unscaled game time for the object life timeout, otherwise false to use absolute time. static void Add(Object* obj, float timeToLive = 1.0f, bool useGameTime = false); /// /// Flushes the objects pool removing objects marked to remove now (with negative or zero time to live). /// FORCE_INLINE static void Flush() { Flush(0, 0); } /// /// Flushes the objects pool. /// /// The delta time (in seconds). /// The game update delta time (in seconds). static void Flush(float dt, float gameDelta); /// /// Forces the flush the all objects from the pool. /// FORCE_INLINE static void ForceFlush() { Flush(1000, 1000); } };