fix mutually canceling orbits
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "RepairExecutor.h"
|
||||
|
||||
#include "BehaviorKind.h"
|
||||
#include "DynamicBodyComponent.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "ModuleOwnerComponent.h"
|
||||
#include "MovementIntentComponent.h"
|
||||
@@ -27,12 +28,17 @@ void RepairExecutor::execute(EntityAdmin& admin)
|
||||
const entt::entity t = *repair.currentTarget;
|
||||
QVector2D center = pos.value;
|
||||
float radius = 0.0f;
|
||||
QVector2D centerVelocity;
|
||||
if (admin.isValid(t) && admin.hasAll<PositionComponent>(t))
|
||||
{
|
||||
center = admin.get<PositionComponent>(t).value;
|
||||
radius = repair.orbitRadius_tiles;
|
||||
if (admin.hasAll<DynamicBodyComponent>(t))
|
||||
{
|
||||
centerVelocity = admin.get<DynamicBodyComponent>(t).velocity_tpt;
|
||||
}
|
||||
}
|
||||
intent = MovementIntentComponent{true, center, radius};
|
||||
intent = MovementIntentComponent{true, center, radius, centerVelocity};
|
||||
});
|
||||
|
||||
// Repair tools: prefer the behavior target if it is within tool range.
|
||||
|
||||
Reference in New Issue
Block a user