Rename ship/station scrap drop entities to "debris"
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "EntityAdmin.h"
|
||||
#include "PositionComponent.h"
|
||||
#include "ScrapDataComponent.h"
|
||||
#include "DebrisComponent.h"
|
||||
#include "ShipIdentityComponent.h"
|
||||
#include "StationBodyComponent.h"
|
||||
#include "HealthComponent.h"
|
||||
@@ -58,16 +58,16 @@ entt::entity entityAtWorldPos(EntityAdmin& admin, QVector2D worldPos)
|
||||
return bestShip;
|
||||
}
|
||||
|
||||
entt::entity scrapAtWorldPos(EntityAdmin& admin, QVector2D worldPos)
|
||||
entt::entity debrisAtWorldPos(EntityAdmin& admin, QVector2D worldPos)
|
||||
{
|
||||
// Slightly larger than the scrap's rendered radius (0.2 tiles) so small piles
|
||||
// Slightly larger than the debris's rendered radius (0.2 tiles) so small pieces
|
||||
// remain easy to click; tunable.
|
||||
constexpr float kScrapHitRadiusSquared = 0.35f * 0.35f;
|
||||
entt::entity bestScrap = entt::null;
|
||||
float bestDistSquared = kScrapHitRadiusSquared;
|
||||
constexpr float kDebrisHitRadiusSquared = 0.35f * 0.35f;
|
||||
entt::entity bestDebris = entt::null;
|
||||
float bestDistSquared = kDebrisHitRadiusSquared;
|
||||
|
||||
admin.forEach<ScrapDataComponent, PositionComponent>(
|
||||
[&](entt::entity entity, const ScrapDataComponent& /*sd*/, const PositionComponent& pos)
|
||||
admin.forEach<DebrisComponent, PositionComponent>(
|
||||
[&](entt::entity entity, const DebrisComponent& /*sd*/, const PositionComponent& pos)
|
||||
{
|
||||
const float dx = pos.value.x() - worldPos.x();
|
||||
const float dy = pos.value.y() - worldPos.y();
|
||||
@@ -75,14 +75,14 @@ entt::entity scrapAtWorldPos(EntityAdmin& admin, QVector2D worldPos)
|
||||
if (distSquared < bestDistSquared)
|
||||
{
|
||||
bestDistSquared = distSquared;
|
||||
bestScrap = entity;
|
||||
bestDebris = entity;
|
||||
}
|
||||
});
|
||||
|
||||
return bestScrap;
|
||||
return bestDebris;
|
||||
}
|
||||
|
||||
std::vector<entt::entity> scrapInBox(EntityAdmin& admin, QPoint tileA, QPoint tileB)
|
||||
std::vector<entt::entity> debrisInBox(EntityAdmin& admin, QPoint tileA, QPoint tileB)
|
||||
{
|
||||
const int minX = std::min(tileA.x(), tileB.x());
|
||||
const int maxX = std::max(tileA.x(), tileB.x());
|
||||
@@ -90,8 +90,8 @@ std::vector<entt::entity> scrapInBox(EntityAdmin& admin, QPoint tileA, QPoint ti
|
||||
const int maxY = std::max(tileA.y(), tileB.y());
|
||||
|
||||
std::vector<entt::entity> result;
|
||||
admin.forEach<ScrapDataComponent, PositionComponent>(
|
||||
[&](entt::entity entity, const ScrapDataComponent& /*sd*/, const PositionComponent& pos)
|
||||
admin.forEach<DebrisComponent, PositionComponent>(
|
||||
[&](entt::entity entity, const DebrisComponent& /*sd*/, const PositionComponent& pos)
|
||||
{
|
||||
const int tileX = static_cast<int>(std::floor(pos.value.x()));
|
||||
const int tileY = static_cast<int>(std::floor(pos.value.y()));
|
||||
|
||||
@@ -11,14 +11,14 @@ class EntityAdmin;
|
||||
|
||||
entt::entity entityAtWorldPos(EntityAdmin& admin, QVector2D worldPos);
|
||||
|
||||
// Returns the nearest scrap pile whose center is within the scrap pick radius of
|
||||
// worldPos, or entt::null if none (REQ-UI-SCRAP-CLICK-SELECT). Scrap is picked only
|
||||
// after actors: entityAtWorldPos never returns scrap (scrap has no HealthComponent).
|
||||
entt::entity scrapAtWorldPos(EntityAdmin& admin, QVector2D worldPos);
|
||||
// Returns the nearest piece of debris whose center is within the debris pick radius of
|
||||
// worldPos, or entt::null if none (REQ-UI-DEBRIS-CLICK-SELECT). Debris is picked only
|
||||
// after actors: entityAtWorldPos never returns debris (debris has no HealthComponent).
|
||||
entt::entity debrisAtWorldPos(EntityAdmin& admin, QVector2D worldPos);
|
||||
|
||||
// Returns every scrap pile whose position falls within the inclusive tile rectangle
|
||||
// spanned by tileA and tileB, in any corner order (REQ-UI-SCRAP-MULTI-SELECT).
|
||||
std::vector<entt::entity> scrapInBox(EntityAdmin& admin, QPoint tileA, QPoint tileB);
|
||||
// Returns every piece of debris whose position falls within the inclusive tile rectangle
|
||||
// spanned by tileA and tileB, in any corner order (REQ-UI-DEBRIS-MULTI-SELECT).
|
||||
std::vector<entt::entity> debrisInBox(EntityAdmin& admin, QPoint tileA, QPoint tileB);
|
||||
|
||||
// Returns every living actor (ship or defence station, player or enemy) that falls
|
||||
// within the inclusive tile rectangle spanned by tileA and tileB, in any corner order
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "PositionComponent.h"
|
||||
#include "RepairSystem.h"
|
||||
#include "SalvagerSystem.h"
|
||||
#include "ScrapDataComponent.h"
|
||||
#include "ScrapSystem.h"
|
||||
#include "DebrisComponent.h"
|
||||
#include "DebrisSystem.h"
|
||||
#include "ShipIdentityComponent.h"
|
||||
#include "ShipSystem.h"
|
||||
#include "StateChecksum.h"
|
||||
@@ -69,7 +69,7 @@ Simulation::Simulation(GameConfig config, unsigned int seed)
|
||||
m_aiSystem = std::make_unique<AiSystem>(m_config);
|
||||
m_movementIntentSystem = std::make_unique<MovementIntentSystem>();
|
||||
m_dynamicBodySystem = std::make_unique<DynamicBodySystem>();
|
||||
m_scrapSystem = std::make_unique<ScrapSystem>(m_admin);
|
||||
m_debrisSystem = std::make_unique<DebrisSystem>(m_admin);
|
||||
m_salvagerSystem = std::make_unique<SalvagerSystem>(m_admin);
|
||||
m_repairSystem = std::make_unique<RepairSystem>(m_admin);
|
||||
m_waveSystem = std::make_unique<WaveSystem>(m_config, m_rng);
|
||||
@@ -141,7 +141,7 @@ void Simulation::reset(unsigned int seed)
|
||||
m_aiSystem = std::make_unique<AiSystem>(m_config);
|
||||
m_movementIntentSystem = std::make_unique<MovementIntentSystem>();
|
||||
m_dynamicBodySystem = std::make_unique<DynamicBodySystem>();
|
||||
m_scrapSystem = std::make_unique<ScrapSystem>(m_admin);
|
||||
m_debrisSystem = std::make_unique<DebrisSystem>(m_admin);
|
||||
m_salvagerSystem = std::make_unique<SalvagerSystem>(m_admin);
|
||||
m_repairSystem = std::make_unique<RepairSystem>(m_admin);
|
||||
m_waveSystem = std::make_unique<WaveSystem>(m_config, m_rng);
|
||||
@@ -329,10 +329,10 @@ void Simulation::tick()
|
||||
m_shipSystem->clearMovementIntents();
|
||||
// Score-based behavior selection: evaluate, select winner, execute (sets
|
||||
// movement intent + preferred module targets only — no world mutation).
|
||||
m_aiSystem->tick(m_admin, *m_buildingSystem, *m_scrapSystem);
|
||||
m_aiSystem->tick(m_admin, *m_buildingSystem, *m_debrisSystem);
|
||||
// Module systems perform the world mutation (collection/delivery, healing).
|
||||
// Each emits its tool beams and applies its own delayed (mid-beam) effects.
|
||||
m_salvagerSystem->tick(m_currentTick, *m_scrapSystem, *m_buildingSystem, m_beamFiredEvents);
|
||||
m_salvagerSystem->tick(m_currentTick, *m_debrisSystem, *m_buildingSystem, m_beamFiredEvents);
|
||||
m_repairSystem->tick(m_currentTick, m_beamFiredEvents);
|
||||
|
||||
// Step 8: combat resolution
|
||||
@@ -352,8 +352,8 @@ void Simulation::tick()
|
||||
m_movementIntentSystem->tick(m_admin);
|
||||
m_dynamicBodySystem->tick(m_admin);
|
||||
|
||||
// Step 11: scrap despawn
|
||||
m_scrapSystem->tickDespawn(m_currentTick);
|
||||
// Step 11: debris despawn
|
||||
m_debrisSystem->tickDespawn(m_currentTick);
|
||||
|
||||
++m_currentTick;
|
||||
}
|
||||
@@ -542,8 +542,8 @@ void Simulation::tickDeathsAndLoot()
|
||||
if (si.scrapDrop > 0)
|
||||
{
|
||||
const Tick despawnAt = m_currentTick
|
||||
+ secondsToTicks(m_config.world.scrapDespawnSeconds);
|
||||
m_scrapSystem->spawn(pos.value, si.scrapDrop, despawnAt);
|
||||
+ secondsToTicks(m_config.world.debrisDespawnSeconds);
|
||||
m_debrisSystem->spawn(pos.value, si.scrapDrop, despawnAt);
|
||||
}
|
||||
m_shipSystem->despawn(deadEntity);
|
||||
}
|
||||
@@ -567,7 +567,7 @@ void Simulation::tickDeathsAndLoot()
|
||||
const FactionComponent& fac = m_admin.get<FactionComponent>(deadEntity);
|
||||
|
||||
const Tick despawnAt = m_currentTick
|
||||
+ secondsToTicks(m_config.world.scrapDespawnSeconds);
|
||||
+ secondsToTicks(m_config.world.debrisDespawnSeconds);
|
||||
int scrap = 0;
|
||||
if (!fac.isEnemy)
|
||||
{
|
||||
@@ -584,7 +584,7 @@ void Simulation::tickDeathsAndLoot()
|
||||
}
|
||||
if (scrap > 0)
|
||||
{
|
||||
m_scrapSystem->spawn(pos.value, scrap, despawnAt);
|
||||
m_debrisSystem->spawn(pos.value, scrap, despawnAt);
|
||||
}
|
||||
m_buildingSystem->unregisterTileOccupancy(sb.bodyCells);
|
||||
{
|
||||
@@ -1000,8 +1000,8 @@ unsigned long long Simulation::computeStateChecksum() const
|
||||
hasher.append(c.linearAcceleration_tptt);
|
||||
hasher.append(c.angularAcceleration_rptt);
|
||||
});
|
||||
m_admin.forEach<ScrapDataComponent>(
|
||||
[&hasher](entt::entity entity, const ScrapDataComponent& c)
|
||||
m_admin.forEach<DebrisComponent>(
|
||||
[&hasher](entt::entity entity, const DebrisComponent& c)
|
||||
{
|
||||
hasher.append(static_cast<std::uint32_t>(entity));
|
||||
hasher.append(c.amount);
|
||||
@@ -1238,14 +1238,14 @@ const ShipSystem& Simulation::getShips() const
|
||||
return *m_shipSystem;
|
||||
}
|
||||
|
||||
ScrapSystem& Simulation::getScraps()
|
||||
DebrisSystem& Simulation::getDebrisSystem()
|
||||
{
|
||||
return *m_scrapSystem;
|
||||
return *m_debrisSystem;
|
||||
}
|
||||
|
||||
const ScrapSystem& Simulation::getScraps() const
|
||||
const DebrisSystem& Simulation::getDebrisSystem() const
|
||||
{
|
||||
return *m_scrapSystem;
|
||||
return *m_debrisSystem;
|
||||
}
|
||||
|
||||
EntityAdmin& Simulation::getAdmin()
|
||||
|
||||
@@ -33,7 +33,7 @@ class MovementIntentSystem;
|
||||
class RepairSystem;
|
||||
class SalvagerSystem;
|
||||
class ShipSystem;
|
||||
class ScrapSystem;
|
||||
class DebrisSystem;
|
||||
class WaveSystem;
|
||||
|
||||
class Simulation: public CombinedEventHandler<TracePrintRequestedEvent>
|
||||
@@ -122,8 +122,8 @@ public:
|
||||
const BeltSystem& getBelts() const;
|
||||
ShipSystem& getShips();
|
||||
const ShipSystem& getShips() const;
|
||||
ScrapSystem& getScraps();
|
||||
const ScrapSystem& getScraps() const;
|
||||
DebrisSystem& getDebrisSystem();
|
||||
const DebrisSystem& getDebrisSystem() const;
|
||||
EntityAdmin& getAdmin();
|
||||
const EntityAdmin& getAdmin() const;
|
||||
|
||||
@@ -172,7 +172,7 @@ private:
|
||||
// Stores their IDs in m_currentEnemyStationIds.
|
||||
void placeEnemyStationSet(int generation);
|
||||
|
||||
// Tick step 9: remove dead ships and buildings, drop scrap, handle push.
|
||||
// Tick step 9: remove dead ships and buildings, drop debris, handle push.
|
||||
void tickDeathsAndLoot();
|
||||
|
||||
// Generate up to 3 schematic choices (REQ-DEF-SCHEMATIC-DROP) for the player.
|
||||
@@ -269,7 +269,7 @@ private:
|
||||
std::unique_ptr<AiSystem> m_aiSystem;
|
||||
std::unique_ptr<MovementIntentSystem> m_movementIntentSystem;
|
||||
std::unique_ptr<DynamicBodySystem> m_dynamicBodySystem;
|
||||
std::unique_ptr<ScrapSystem> m_scrapSystem;
|
||||
std::unique_ptr<DebrisSystem> m_debrisSystem;
|
||||
std::unique_ptr<SalvagerSystem> m_salvagerSystem;
|
||||
std::unique_ptr<RepairSystem> m_repairSystem;
|
||||
std::unique_ptr<WaveSystem> m_waveSystem;
|
||||
|
||||
@@ -66,7 +66,7 @@ ThreatCostTable computeThreatCostTable(const GameConfig& config)
|
||||
ThreatCostTable table;
|
||||
|
||||
// Scrap threat (REQ-THREAT-SCRAP) is the constant inverse of the scrap-drop
|
||||
// conversion (REQ-RES-SCRAP-DROP): one scrap is worth 1 / scrap_per_threat.
|
||||
// conversion (REQ-RES-DEBRIS-DROP): one scrap is worth 1 / scrap_per_threat.
|
||||
// Set it up front so reprocessing-only item threats (below) can use it, and so
|
||||
// it no longer depends on any ship's threat cost.
|
||||
table.scrapThreat = config.world.scrapPerThreat > 0.0
|
||||
|
||||
Reference in New Issue
Block a user