CSC8503_Advanced_Game_Technologies / CSC8503 / CSC8503Common / BehaviourSelector.h
BehaviourSelector.h
Raw
#pragma once
#include "BehaviourNodeWithChildren.h"

class BehaviourSelector : public BehaviourNodeWithChildren {
public:
	BehaviourSelector(const std::string& nodeName) : BehaviourNodeWithChildren(nodeName) {}
	~BehaviourSelector() {}
	BehaviourState Execute(float dt) override {
		//std::cout << "Executing selector" << name << "\n";
		for (auto& i : childNodes) {
			BehaviourState nodeState = i->Execute(dt);
			switch (nodeState) {
			case Failure: continue;
			case Success:
			case Ongoing:
			{
				currentState = nodeState;
				return currentState;
			}
			}
		}
		return Failure;
	}
};