Rename ship/station scrap drop entities to "debris"

This commit is contained in:
2026-07-23 20:51:05 +02:00
parent 11daa61714
commit 8b71fe1a03
48 changed files with 468 additions and 443 deletions

View File

@@ -0,0 +1,46 @@
#pragma once
#include <optional>
#include <vector>
#include <QVector2D>
#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<int> 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<DebrisInfo> getAllDebrisInfo() const;
private:
EntityAdmin& m_admin;
};