<commit_before>#include "precompiled.h"

#include "engine/actor/AISystem.h"
#include "engine/math/random.h"
#include "engine/actor/AIState.h"
#include <vector>

namespace engine {
namespace actor {

	AISystem::AISystem(actor::ActorManager *actorManager)
		: actorManager(actorManager)
	{}

	bool AISystem::init(){
		LOG_INFO("AISystem init");

		return true;
	}

	void AISystem::uninit(){
		LOG_INFO("AISystem uninit");
	}

	void AISystem::update(){ //TODO: could this be moved to a better class!
		std::vector<actor::ActorBase *> actors = actorManager->getActorSystem()->getActorsInRoom(vec3(0,0,0));

		for(unsigned int i = 0; i < actors.size();++i){
			//First handle the general stuff that each actor does
			actorManager->actorTick(actors.at(i));

			//then handle the AI
			handleActor(actors.at(i));
		}

		//remove useless
		actorManager->getActorSystem()->handleRemoveQueue();
	}

	void AISystem::handleActor(actor::ActorBase * actor){
		//TODO: This whole function looks like shit, fix it

		//TODO: IMPLEMENT A DAMN DEATH/ALIVE CHECK HERE!

		vec2 newPos;

		switch( actor->getAIState() ){
			case AISTATE_SLEEP:
				return;
			case AISTATE_PATROL:
				//Patrolling enemies goes to random direction
				newPos.x = actor->getPos()->x + randomRange(-1,1);
				newPos.y = actor->getPos()->y + randomRange(-1,1);

				actorManager->moveActor(actor,newPos);

				return;
			case AISTATE_PLAYER:
				//Do nothing, its the player!<commit_msg>Added some documentation on actor stuff. Added one "tool" to refresh repo after a break.<commit_after>#include "precompiled.h"

#include "engine/actor/AISystem.h"
#include "engine/math/random.h"
#include "engine/actor/AIState.h"
#include <vector>

namespace engine {
namespace actor {

	AISystem::AISystem(actor::ActorManager *actorManager)
		: actorManager(actorManager)
	{}

	bool AISystem::init(){
		LOG_INFO("AISystem init");

		return true;
	}

	void AISystem::uninit(){
		LOG_INFO("AISystem uninit");
	}

	void AISystem::update(){ //TODO: could this be moved to a better class!
		std::vector<actor::ActorBase *> actors = actorManager->getActorSystem()->getActorsInRoom(vec3(0,0,0));

		for(unsigned int i = 0; i < actors.size();++i){
			//First handle the general stuff that each actor does
			actorManager->actorTick(actors.at(i));

			//then handle the AI
			handleActor(actors.at(i));
		}

		//remove useless
		actorManager->getActorSystem()->handleRemoveQueue();
	}

	void AISystem::handleActor(actor::ActorBase * actor){
		//TODO: This whole function looks like shit, fix it

		vec2 newPos;

		switch( actor->getAIState() ){
			case AISTATE_SLEEP:
				return;
			case AISTATE_PATROL:
				//Patrolling enemies goes to random direction
				newPos.x = actor->getPos()->x + randomRange(-1,1);
				newPos.y = actor->getPos()->y + randomRange(-1,1);

				actorManager->moveActor(actor,newPos);

				return;
			case AISTATE_PLAYER:
				//Do nothing, its the player!
{'fraction_non_alphanumeric': 0.1423670668953688, 'fraction_numerical': 0.00686106346483705, 'mean_word_length': 4.244604316546763, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1659002', 'n_tokens_mistral': 1098, 'n_tokens_neox': 965, 'n_words': 234}