#pragma once #include #include #include #include "Tick.h" #include "entt/entity/entity.hpp" class EntityAdmin; // A piece of debris and the scrap amount it still holds (REQ-RES-DEBRIS-DROP). struct DebrisInfo { entt::entity entity; QVector2D position; int amount; }; // Manages debris entities: the salvageable objects dropped by destroyed ships and // defence stations (REQ-RES-DEBRIS-DROP). Each piece carries a scrap amount that // salvage modules collect one unit at a time (REQ-SHP-SALVAGE). class DebrisSystem { public: explicit DebrisSystem(EntityAdmin& admin); entt::entity spawn(QVector2D position, int amount, Tick despawnAt); void tickDespawn(Tick currentTick); // Removes the debris and returns its remaining scrap amount, or nullopt if not found. std::optional consume(entt::entity entity); // Collects a single scrap unit from the debris: decrements its amount by one, // destroying the entity once depleted. Returns true if a scrap was collected, // false if the entity is invalid or already empty (REQ-SHP-SALVAGE). bool collectOne(entt::entity entity); // Lightweight snapshot for callers that need to iterate all debris. std::vector getAllDebrisInfo() const; private: EntityAdmin& m_admin; };