<commit_before>#include "LevelDirector.h"
#define SUCCESS 1
#define FAIL 0

FSMEnvironment::LevelDirector::LevelDirector(){}
FSMEnvironment::LevelDirector::~LevelDirector(){}
int FSMEnvironment::LevelDirector::Shutdown()
{
	this->m_states.clear();
	return SUCCESS;
}

int FSMEnvironment::LevelDirector::Initialize()
{
	// Reset values
	this->m_states.clear();

	this->m_defaultState = nullptr;
	this->m_currentState = nullptr;
	this->m_goalState = nullptr;

	// TODO: Import new states from new LevelState
#pragma region temp
	State test;
	test.stateID = 0;
	test.timeDelay = 10;
	test.hint = Hint::EXAMPLE;
	AddState(&test);
	//m_states.push_back(test);
	test.stateID = 1;
	test.timeDelay = 15;
	test.hint = Hint::EXAMPLE;
	AddState(&test);
	//m_states.push_back(test);
	test.stateID = 2;
	test.timeDelay = 20;
	test.hint = Hint::EXAMPLE;
	AddState(&test);
	//m_states.push_back(test);
	for (int i = 0; i < 3; i++)
	{
		printf("%d\n", m_states[i].stateID);
	}
	m_currentState = &m_states.front();
#pragma endregion

	return SUCCESS;
}
int FSMEnvironment::LevelDirector::Update(float dt)
{
	// Return if there are no states
	if (this->m_states.size() == 0)
		return SUCCESS;
	// Return if there are no current state or default state
	if (!(this->m_currentState))
		this->m_currentState = this->m_defaultState;
	if(!(this->m_currentState))
		return SUCCESS;
	
	int oldStateID = this->m_currentState->stateID;
	this->m_goalID = this->m_currentState->CheckTransitions();
	if (this->m_goalID != oldStateID)
	{
		if (this->ChangeState(this->m_goalID))
		{
			this->m_currentState->Exit();
			this->m_currentState = this->m_goalState;
			this->m_currentState->Enter();
		}
		this->m_currentState->Update(dt);
	}

	return SUCCESS;
}

int FSMEnvironment::LevelDirector::React(int entityID, EVENT event)
{

	return SUCCESS;
}

void FSMEnvironment::LevelDirector::AddState(State* newState)
{
	this->m_states.push_back(*newState);
}
void FSMEnvironment::LevelDirector::SetDefaultState(State* state)
{
	this->m_defaultState = state;
}
bool FSMEnvironment::LevelDirector::ChangeState(int newState)
{
	bool change = false;
	// Query list of states to see if the state exists
	for (int i = 0; i < m_states.size(); i++)
	{
		if (m_states[i].stateID == newState)
		{
			change = true;
			break;
		}
	}
	return change;
}

#pragma region temp
int FSMEnvironment::State::CheckTransitions()
{

	return 1;// TODO: Return ID
}
void FSMEnvironment::State::Enter()
{

}
void FSMEnvironment::State::Exit()
{

}
void FSMEnvironment::State::Update(float dt)
{

}
#pragma endregion

<commit_msg>UPDATE initialisation to set default state instead of currentstate<commit_after>#include "LevelDirector.h"
#define SUCCESS 1
#define FAIL 0

FSMEnvironment::LevelDirector::LevelDirector(){}
FSMEnvironment::LevelDirector::~LevelDirector(){}
int FSMEnvironment::LevelDirector::Shutdown()
{
	this->m_states.clear();
	return SUCCESS;
}

int FSMEnvironment::LevelDirector::Initialize()
{
	// Reset values
	this->m_states.clear();

	this->m_defaultState = nullptr;
	this->m_currentState = nullptr;
	this->m_goalState = nullptr;

	// TODO: Import new states from new LevelState
#pragma region temp
	State test;
	test.stateID = 0;
	test.timeDelay = 10;
	test.hint = Hint::EXAMPLE;
	AddState(&test);
	//m_states.push_back(test);
	test.stateID = 1;
	test.timeDelay = 15;
	test.hint = Hint::EXAMPLE;
	AddState(&test);
	//m_states.push_back(test);
	test.stateID = 2;
	test.timeDelay = 20;
	test.hint = Hint::EXAMPLE;
	AddState(&test);
	//m_states.push_back(test);
	for (int i = 0; i < 3; i++)
	{
		printf("%d\n", m_states[i].stateID);
	}
	SetDefaultState(&m_states[0]);
#pragma endregion

	return SUCCESS;
}
int FSMEnvironment::LevelDirector::Update(float dt)
{
	// Return if there are no states
	if (this->m_states.size() == 0)
		return SUCCESS;
	// Return if there are no current state or default state
	if (!(this->m_currentState))
		this->m_currentState = this->m_defaultState;
	if(!(this->m_currentState))
		return SUCCESS;
	
	int oldStateID = this->m_currentState->stateID;
	this->m_goalID = this->m_currentState->CheckTransitions();
	if (this->m_goalID != oldStateID)
	{
		if (this->ChangeState(this->m_goalID))
		{
			this->m_currentState->Exit();
			this->m_currentState = this->m_goalState;
			this->m_currentState->Enter();
		}
		this->m_currentState->Update(dt);
	}

	return SUCCESS;
}

int FSMEnvironment::LevelDirector::React(int entityID, EVENT event)
{

	return SUCCESS;
}

void FSMEnvironment::LevelDirector::AddState(State* newState)
{
	this->m_states.push_back(*newState);
}
void FSMEnvironment::LevelDirector::SetDefaultState(State* state)
{
	this->m_defaultState = state;
}
bool FSMEnvironment::LevelDirector::ChangeState(int newState)
{
	bool change = false;
	// Query list of states to see if the state exists
	for (int i = 0; i < m_states.size(); i++)
	{
		if (m_states[i].stateID == newState)
		{
			change = true;
			break;
		}
	}
	return change;
}

#pragma region temp
int FSMEnvironment::State::CheckTransitions()
{

	return 1;// TODO: Return ID
}
void FSMEnvironment::State::Enter()
{

}
void FSMEnvironment::State::Exit()
{

}
void FSMEnvironment::State::Update(float dt)
{

}
#pragma endregion


{'fraction_non_alphanumeric': 0.14903474903474903, 'fraction_numerical': 0.006370656370656371, 'mean_word_length': 5.024418604651163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 59, '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': '1775584', 'n_tokens_mistral': 2015, 'n_tokens_neox': 1839, 'n_words': 389}