2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:29:17 +01:00
|
|
|
#include "gsai_infinite_proximity.h"
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-14 00:28:56 +01:00
|
|
|
#include "../gsai_steering_agent.h"
|
|
|
|
#include "scene/main/scene_tree.h"
|
|
|
|
|
|
|
|
int GSAIInfiniteProximity::_find_neighbors(Ref<FuncRef> callback) {
|
2023-01-13 21:35:07 +01:00
|
|
|
int neighbor_count = 0;
|
|
|
|
int agent_count = agents.size();
|
2023-01-14 00:28:56 +01:00
|
|
|
Variant arg;
|
|
|
|
const Variant *argptr[1];
|
|
|
|
argptr[0] = &arg;
|
|
|
|
Variant::CallError err;
|
|
|
|
|
|
|
|
for (int i = 0; i < agent_count; ++i) {
|
|
|
|
Ref<GSAISteeringAgent> current_agent = agents[i];
|
2023-01-13 21:35:07 +01:00
|
|
|
|
2023-01-14 00:28:56 +01:00
|
|
|
ERR_CONTINUE(!current_agent.is_valid());
|
2023-01-13 21:35:07 +01:00
|
|
|
|
|
|
|
if (current_agent != agent) {
|
2023-01-14 00:28:56 +01:00
|
|
|
if (callback->call_func(argptr, 1, err)) {
|
2023-01-13 21:35:07 +01:00
|
|
|
neighbor_count += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return neighbor_count;
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
GSAIInfiniteProximity::GSAIInfiniteProximity() {
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
GSAIInfiniteProximity::~GSAIInfiniteProximity() {
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-14 00:28:56 +01:00
|
|
|
void GSAIInfiniteProximity::_bind_methods() {
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|