drop EntityAdmin::add in favour of addComponent
The private add<T> template was identical to the public addComponent<T>; the spawn factory methods now use the public one. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GH8ZMRY3vhxxXcaUxBqxkk
This commit is contained in:
@@ -45,11 +45,11 @@ entt::entity EntityAdmin::spawnShip(QVector2D position, float hp, float maxHp,
|
|||||||
const std::string& schematicId, bool isEnemy)
|
const std::string& schematicId, bool isEnemy)
|
||||||
{
|
{
|
||||||
entt::entity entity = createEntity();
|
entt::entity entity = createEntity();
|
||||||
add<PositionComponent>(entity, PositionComponent{position});
|
addComponent<PositionComponent>(entity, PositionComponent{position});
|
||||||
add<HealthComponent>(entity, HealthComponent{hp, maxHp});
|
addComponent<HealthComponent>(entity, HealthComponent{hp, maxHp});
|
||||||
add<FactionComponent>(entity, FactionComponent{isEnemy});
|
addComponent<FactionComponent>(entity, FactionComponent{isEnemy});
|
||||||
add<FacingComponent>(entity, FacingComponent{0.0f});
|
addComponent<FacingComponent>(entity, FacingComponent{0.0f});
|
||||||
add<DynamicBodyComponent>(entity, DynamicBodyComponent{
|
addComponent<DynamicBodyComponent>(entity, DynamicBodyComponent{
|
||||||
maxSpeed_tpt,
|
maxSpeed_tpt,
|
||||||
mainAcceleration_tptt,
|
mainAcceleration_tptt,
|
||||||
maneuveringAcceleration_tptt,
|
maneuveringAcceleration_tptt,
|
||||||
@@ -60,9 +60,9 @@ entt::entity EntityAdmin::spawnShip(QVector2D position, float hp, float maxHp,
|
|||||||
QVector2D(0.0f, 0.0f), // linearAcceleration_tptt
|
QVector2D(0.0f, 0.0f), // linearAcceleration_tptt
|
||||||
0.0f // angularAcceleration_rptt
|
0.0f // angularAcceleration_rptt
|
||||||
});
|
});
|
||||||
add<SensorRangeComponent>(entity, SensorRangeComponent{sensorRange_tiles});
|
addComponent<SensorRangeComponent>(entity, SensorRangeComponent{sensorRange_tiles});
|
||||||
add<ShipIdentityComponent>(entity, ShipIdentityComponent{schematicId});
|
addComponent<ShipIdentityComponent>(entity, ShipIdentityComponent{schematicId});
|
||||||
add<MovementIntentComponent>(entity, MovementIntentComponent{0, QVector2D(0.0f, 0.0f)});
|
addComponent<MovementIntentComponent>(entity, MovementIntentComponent{0, QVector2D(0.0f, 0.0f)});
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,28 +73,28 @@ entt::entity EntityAdmin::spawnStation(QPoint anchor, QSize footprint,
|
|||||||
entt::entity entity = createEntity();
|
entt::entity entity = createEntity();
|
||||||
QVector2D center(anchor.x() + footprint.width() / 2.0f,
|
QVector2D center(anchor.x() + footprint.width() / 2.0f,
|
||||||
anchor.y() + footprint.height() / 2.0f);
|
anchor.y() + footprint.height() / 2.0f);
|
||||||
add<PositionComponent>(entity, PositionComponent{center});
|
addComponent<PositionComponent>(entity, PositionComponent{center});
|
||||||
add<HealthComponent>(entity, HealthComponent{hp, maxHp});
|
addComponent<HealthComponent>(entity, HealthComponent{hp, maxHp});
|
||||||
add<FactionComponent>(entity, FactionComponent{isEnemy});
|
addComponent<FactionComponent>(entity, FactionComponent{isEnemy});
|
||||||
add<StationBodyComponent>(entity, StationBodyComponent{anchor, footprint, bodyCells});
|
addComponent<StationBodyComponent>(entity, StationBodyComponent{anchor, footprint, bodyCells});
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
entt::entity EntityAdmin::spawnDebris(QVector2D position, int amount, Tick despawnAt)
|
entt::entity EntityAdmin::spawnDebris(QVector2D position, int amount, Tick despawnAt)
|
||||||
{
|
{
|
||||||
entt::entity entity = createEntity();
|
entt::entity entity = createEntity();
|
||||||
add<PositionComponent>(entity, PositionComponent{position});
|
addComponent<PositionComponent>(entity, PositionComponent{position});
|
||||||
add<DebrisComponent>(entity, DebrisComponent{amount});
|
addComponent<DebrisComponent>(entity, DebrisComponent{amount});
|
||||||
add<DespawnAtComponent>(entity, DespawnAtComponent{despawnAt});
|
addComponent<DespawnAtComponent>(entity, DespawnAtComponent{despawnAt});
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
entt::entity EntityAdmin::spawnHqProxy(QVector2D position, float hp, float maxHp)
|
entt::entity EntityAdmin::spawnHqProxy(QVector2D position, float hp, float maxHp)
|
||||||
{
|
{
|
||||||
entt::entity entity = createEntity();
|
entt::entity entity = createEntity();
|
||||||
add<PositionComponent>(entity, PositionComponent{position});
|
addComponent<PositionComponent>(entity, PositionComponent{position});
|
||||||
add<HealthComponent>(entity, HealthComponent{hp, maxHp});
|
addComponent<HealthComponent>(entity, HealthComponent{hp, maxHp});
|
||||||
add<FactionComponent>(entity, FactionComponent{false});
|
addComponent<FactionComponent>(entity, FactionComponent{false});
|
||||||
add<HqProxyComponent>(entity);
|
addComponent<HqProxyComponent>(entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,9 +73,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
entt::entity createEntity();
|
entt::entity createEntity();
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
|
||||||
void add(entt::entity entity, Args&&... args);
|
|
||||||
|
|
||||||
entt::registry m_registry;
|
entt::registry m_registry;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -133,10 +130,4 @@ void EntityAdmin::removeComponent(entt::entity entity)
|
|||||||
m_registry.remove<T>(entity);
|
m_registry.remove<T>(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
|
||||||
void EntityAdmin::add(entt::entity entity, Args&&... args)
|
|
||||||
{
|
|
||||||
m_registry.emplace<T>(entity, std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ENTITY_ADMIN_H
|
#endif // ENTITY_ADMIN_H
|
||||||
|
|||||||
Reference in New Issue
Block a user