<commit_before>#include "ComponentScript.h"
#include "Application.h"
#include "ModuleScripting.h"
#include "Color.h"
#include "GameObject.h"
#include "ModuleGOManager.h"
#include "PhysBody3D.h"
#include "Brofiler/include/Brofiler.h"

#include "imgui\imgui.h"

ComponentScript::ComponentScript(ComponentType type, GameObject* game_object, const char* path) : Component(type, game_object)
{
	SetPath(path);
	started = false;
	finded_start = false;
	finded_update = false;
	script_num = 0;
	filter = "";
	public_gos_to_set = false;
}

ComponentScript::ComponentScript(ComponentType type, GameObject* game_object) : Component(type, game_object)
{
	started = false;
	finded_start = false;
	finded_update = false;
	script_num = 0;
	filter = "";
	public_gos_to_set = false;
}

ComponentScript::~ComponentScript()
{
}

void ComponentScript::Update()
{
	BROFILER_CATEGORY("ComponentScript::Update", Profiler::Color::LawnGreen);
	
	if (public_gos_to_set)
	{
		if (!public_gos.empty())
		{
			for (map<const char*, GameObject*>::iterator it = public_gos.begin(); it != public_gos.end(); it++)
			{
				(*it).second = App->go_manager->FindGameObjectByUUID(App->go_manager->root, tmp_public_gos_uuint.find((*it).first)->second);
			}
			public_gos_to_set = false;
			tmp_public_gos_uuint.clear();
		}
	}

	//Component must be active to update
	if (!IsActive())
		return;	

	if (App->scripting->scripts_loaded)
	{
		if (App->IsGameRunning() && !App->IsGamePaused())
		{
			if (!started)
			{
				string start_path = path.c_str();
				start_path.append("_Start");
				if (f_Start start = (f_Start)GetProcAddress(App->scripting->scripts_lib->lib, start_path.c_str()))
				{
					finded_start = true;
					string update_publics_path = path.c_str();
					update_publics_path.append("_UpdatePublics");
					if (f_Update update_publics = (f_Update)GetProcAddress(App->scripting->scripts_lib->lib, update_publics_path.c_str()))
					{
						update_publics(GetGameObject());
					}
					if (App->IsGameRunning() && !App->IsGamePaused())
					{
						start(GetGameObject());
						started = true;
					}
				}
				else
				{
					finded_start = false;
					error = GetLastError();
				}
			}
			else
			{
				string update_path = path.c_str();
				update_path.append("_Update");
				if (f_Update update = (f_Update)GetProcAddress(App->scripting->scripts_lib->lib, update_path.c_str()))
				{
					finded_update = true;
					string update_publics_path = path.c_str();
					update_publics_path.append("_UpdatePublics");
					if (f_Update update_publics = (f_Update)GetProcAddress(App->scripting->scripts_lib->lib, update_publics_path.c_str()))
					{
						update_publics(GetGameObject());
					}
					if (App->IsGameRunning() && !App->IsGamePaused())
					{
						update(GetGameObject());<commit_msg>actualize script variables in start too<commit_after>#include "ComponentScript.h"
#include "Application.h"
#include "ModuleScripting.h"
#include "Color.h"
#include "GameObject.h"
#include "ModuleGOManager.h"
#include "PhysBody3D.h"
#include "Brofiler/include/Brofiler.h"

#include "imgui\imgui.h"

ComponentScript::ComponentScript(ComponentType type, GameObject* game_object, const char* path) : Component(type, game_object)
{
	SetPath(path);
	started = false;
	finded_start = false;
	finded_update = false;
	script_num = 0;
	filter = "";
	public_gos_to_set = false;
}

ComponentScript::ComponentScript(ComponentType type, GameObject* game_object) : Component(type, game_object)
{
	started = false;
	finded_start = false;
	finded_update = false;
	script_num = 0;
	filter = "";
	public_gos_to_set = false;
}

ComponentScript::~ComponentScript()
{
}

void ComponentScript::Update()
{
	BROFILER_CATEGORY("ComponentScript::Update", Profiler::Color::LawnGreen);
	
	if (public_gos_to_set)
	{
		if (!public_gos.empty())
		{
			for (map<const char*, GameObject*>::iterator it = public_gos.begin(); it != public_gos.end(); it++)
			{
				(*it).second = App->go_manager->FindGameObjectByUUID(App->go_manager->root, tmp_public_gos_uuint.find((*it).first)->second);
			}
			public_gos_to_set = false;
			tmp_public_gos_uuint.clear();
		}
	}

	//Component must be active to update
	if (!IsActive())
		return;	

	if (App->scripting->scripts_loaded)
	{
		if (App->IsGameRunning() && !App->IsGamePaused())
		{
			if (!started)
			{
				string start_path = path.c_str();
				start_path.append("_Start");
				if (f_Start start = (f_Start)GetProcAddress(App->scripting->scripts_lib->lib, start_path.c_str()))
				{
					finded_start = true;
					string update_publics_path = path.c_str();
					update_publics_path.append("_UpdatePublics");
					if (f_Update update_publics = (f_Update)GetProcAddress(App->scripting->scripts_lib->lib, update_publics_path.c_str()))
					{
						update_publics(GetGameObject());
					}
					if (App->IsGameRunning() && !App->IsGamePaused())
					{
						start(GetGameObject());
						started = true;
					}
					string actualize_publics_path = path.c_str();
					actualize_publics_path.append("_ActualizePublics");
					if (f_Update actualize_publics = (f_Update)GetProcAddress(App->scripting->scripts_lib->lib, actualize_publics_path.c_str()))
					{
						actualize_publics(GetGameObject());
					}
				}
				else
				{
					finded_start = false;
					error = GetLastError();
				}
			}
			else
			{
				string update_path = path.c_str();
				update_path.append("_Update");
				if (f_Update update = (f_Update)GetProcAddress(App->scripting->scripts_lib->lib, update_path.c_str()))
				{
					finded_update = true;
					string update_publics_path = path.c_str();
					update_publics_path.append("_UpdatePublics");
					if (f_Update update_publics = (f_Update)GetProcAddress(App->scripting->scripts_lib->lib, update_publics_path.c_str()))
					{
						update_publics(GetGameObject());
					}
					if (App->IsGameRunning() && !App->IsGamePaused())
					{
						update(GetGameObject());
{'fraction_non_alphanumeric': 0.144925068119891, 'fraction_numerical': 0.0010217983651226157, 'mean_word_length': 4.286228622862287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 58, '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': '2313580', 'n_tokens_mistral': 2425, 'n_tokens_neox': 2055, 'n_words': 322}