21 ITask(name, parameters, condition), _w(w) {
27 movement::WeightedSteerings weightedSteerings;
29 if (ctx->parameters.empty()) {
30 for (
const SteeringPtr& s : ctx->steerings) {
34 std::vector<std::string> tokens;
35 Str::splitString(ctx->parameters, tokens,
",");
36 ai_assert(tokens.size() == ctx->steerings.size(),
"weights doesn't match steerings methods count");
37 const int tokenAmount =
static_cast<int>(tokens.size());
38 for (
int i = 0; i < tokenAmount; ++i) {
43 return std::make_shared<Steer>(ctx->name, ctx->parameters, ctx->condition, w);
46 static const Factory& getFactory() {
51 TreeNodeStatus
doAction(
const AIPtr& entity, int64_t deltaMillis)
override {
52 const ICharacterPtr& chr = entity->getCharacter();
53 const MoveVector& mv = _w.execute(entity, chr->getSpeed());
54 if (isInfinite(mv.getVector())) {
58 const float deltaSeconds =
static_cast<float>(deltaMillis) / 1000.0f;
59 chr->setPosition(chr->getPosition() + (mv.getVector() * deltaSeconds));
60 chr->setOrientation(fmodf(chr->getOrientation() + mv.getRotation() * deltaSeconds, glm::two_pi<float>()));
A node for your real actions in the behaviour tree.
Definition: ITask.h:33
#define ai_assert(condition,...)
Provide your own assert - this is only executed in DEBUG mode.
Definition: Types.h:75
Definition: MoveVector.h:10
TreeNodeStatus doAction(const AIPtr &entity, int64_t deltaMillis) override
Definition: Steer.h:51
Defines some basic movement algorithms like Wandering, Seeking and Fleeing.
Definition: AIFactories.h:24
This class allows you to weight several steering methods and get a blended MoveVector out of it...
Definition: WeightedSteering.h:29
Definition: AIFactories.h:82
Steering and weight as input for WeightedSteering.
Definition: WeightedSteering.h:14