extract the shared Centroid helper into ai/Centroid.h
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <QVector2D>
|
||||
|
||||
#include "BehaviorKind.h"
|
||||
#include "Centroid.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "FactionComponent.h"
|
||||
#include "HealthComponent.h"
|
||||
@@ -16,28 +17,6 @@
|
||||
#include "StationBodyComponent.h"
|
||||
#include "tracing.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
// Accumulates positions to produce their centroid (the center between them).
|
||||
struct Centroid
|
||||
{
|
||||
QVector2D sum;
|
||||
int count = 0;
|
||||
|
||||
void add(const QVector2D& point)
|
||||
{
|
||||
sum += point;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
std::optional<QVector2D> value() const
|
||||
{
|
||||
if (count == 0) { return std::nullopt; }
|
||||
return sum / static_cast<float>(count);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void StandbyExecutor::execute(EntityAdmin& admin)
|
||||
{
|
||||
TRACE();
|
||||
|
||||
Reference in New Issue
Block a user