refactor AI system
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
#include "ScrapSystem.h"
|
||||
#include "ShipSystem.h"
|
||||
#include "Simulation.h"
|
||||
#include "AttackBehavior.h"
|
||||
#include "StationBodyComponent.h"
|
||||
#include "Tick.h"
|
||||
#include "ThreatResponseBehaviorComponent.h"
|
||||
#include "WeaponComponent.h"
|
||||
|
||||
static GameConfig loadConfig()
|
||||
@@ -80,17 +80,18 @@ struct CombatFixture
|
||||
|
||||
void wireEnemyTarget(entt::entity enemy, entt::entity playerTarget)
|
||||
{
|
||||
// Set target on weapon child entity (CombatSystem syncs from ThreatResponse each tick,
|
||||
// but also setting directly ensures the first tick fires without waiting for sync).
|
||||
// Set the target directly on the weapon child entity. CombatSystem now
|
||||
// fires at whatever target a weapon already has (AttackExecutor would set
|
||||
// it in a full tick); setting it here drives CombatSystem in isolation.
|
||||
const entt::entity wc = findWeaponChild(admin, enemy);
|
||||
if (wc != entt::null)
|
||||
{
|
||||
admin.get<WeaponComponent>(wc).currentTarget = playerTarget;
|
||||
admin.get<WeaponComponent>(wc).cooldownTicks = 0.0f;
|
||||
}
|
||||
if (admin.hasAll<ThreatResponseBehaviorComponent>(enemy))
|
||||
if (admin.hasAll<AttackBehavior>(enemy))
|
||||
{
|
||||
admin.get<ThreatResponseBehaviorComponent>(enemy).currentTarget = playerTarget;
|
||||
admin.get<AttackBehavior>(enemy).currentTarget = playerTarget;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user