make ships orbit their targets
This commit is contained in:
@@ -343,12 +343,24 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
|
||||
if (!weaponChildren.empty())
|
||||
{
|
||||
m_admin.addComponent<AttackBehavior>(entity, AttackBehavior{});
|
||||
float maxWeaponRange = 0.0f;
|
||||
for (entt::entity child : weaponChildren)
|
||||
{
|
||||
const float r = m_admin.get<WeaponComponent>(child).range_tiles;
|
||||
if (r > maxWeaponRange) { maxWeaponRange = r; }
|
||||
}
|
||||
|
||||
AttackBehavior attack;
|
||||
attack.orbitRadius_tiles =
|
||||
maxWeaponRange * static_cast<float>(m_config.world.orbitFactor);
|
||||
m_admin.addComponent<AttackBehavior>(entity, attack);
|
||||
|
||||
if (!isEnemy)
|
||||
{
|
||||
RallyBehavior rally;
|
||||
rally.rallyPoint = m_rallyPoint;
|
||||
rally.rallyPoint = m_rallyPoint;
|
||||
rally.orbitRadius_tiles =
|
||||
static_cast<float>(m_config.world.rallyOrbitRadius_tiles);
|
||||
m_admin.addComponent<RallyBehavior>(entity, rally);
|
||||
}
|
||||
}
|
||||
@@ -365,6 +377,8 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
SalvageScrapBehavior salvage;
|
||||
salvage.scrapTarget = std::nullopt;
|
||||
salvage.maxCollectionRange_tiles = maxCollRange;
|
||||
salvage.orbitRadius_tiles =
|
||||
maxCollRange * static_cast<float>(m_config.world.orbitFactor);
|
||||
m_admin.addComponent<SalvageScrapBehavior>(entity, salvage);
|
||||
|
||||
DeliverScrapBehavior deliver;
|
||||
@@ -384,6 +398,8 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||
RepairBehavior repair;
|
||||
repair.currentTarget = std::nullopt;
|
||||
repair.maxRepairRange_tiles = maxRepairRange;
|
||||
repair.orbitRadius_tiles =
|
||||
maxRepairRange * static_cast<float>(m_config.world.orbitFactor);
|
||||
m_admin.addComponent<RepairBehavior>(entity, repair);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user