Horizon Official Technical Documentation
Horizon::Zone::ScriptManager Class Reference

#include <ScriptManager.hpp>

+ Inheritance diagram for Horizon::Zone::ScriptManager:
+ Collaboration diagram for Horizon::Zone::ScriptManager:

Public Member Functions

 ScriptManager ()
 
 ~ScriptManager ()
 
void initialize_basic_state (std::shared_ptr< sol::state > state)
 
void initialize_player_state (std::shared_ptr< sol::state > state)
 
void initialize_npc_state (std::shared_ptr< sol::state > state)
 
void initialize_monster_state (std::shared_ptr< sol::state > state)
 
std::shared_ptr< PlayerComponentplayer ()
 
std::shared_ptr< NPCComponentnpc ()
 
std::shared_ptr< MonsterComponentmonster ()
 
std::shared_ptr< MapComponentmap ()
 
std::shared_ptr< ItemComponentitem ()
 
std::shared_ptr< UnitComponentunit ()
 
std::shared_ptr< SkillComponentskill ()
 
std::shared_ptr< StatusEffectComponentstatus_effect ()
 
std::shared_ptr< CombatComponentcombat ()
 
std::shared_ptr< sol::state > lua_state ()
 
bool is_initialized () override
 
bool is_finalized () override
 
void initialize (int segment_number=1) override
 
void finalize () override
 
void prepare_lua_state (std::shared_ptr< sol::state > &lua)
 
void start ()
 
void update (uint64_t diff)
 
TaskSchedulergetScheduler ()
 
ResourceManagerget_resource_manager ()
 
- Public Member Functions inherited from KernelComponent
 KernelComponent (Kernel *kernel, Horizon::System::runtime_module_type module_type)
 
virtual void initialize (int segment_number=1)
 
virtual void finalize ()
 
virtual bool is_initialized ()
 
virtual bool is_finalized ()
 
void set_segment_number (int64_t segment_number)
 
int64_t get_segment_number ()
 
void system_routine_queue_push (std::shared_ptr< Horizon::System::RuntimeContext > context)
 
void system_routine_queue_push (std::shared_ptr< Horizon::System::RuntimeContextChain > context)
 
void system_routine_process_queue ()
 
void system_routine_register (Horizon::System::runtime_module_type module_t, Horizon::System::runtime_synchronization_method sync_t, std::shared_ptr< Horizon::System::RuntimeContext > context)
 
const std::string get_uuid_string ()
 
const std::string get_type_string ()
 
Horizon::System::SystemRoutineManagerget_system_routine_manager ()
 
Kernelget_kernel ()
 
void set_thread_cpu_id (int cpu_id)
 
int get_thread_cpu_id ()
 
void set_thread_update_rate (double rate)
 
double get_thread_update_rate ()
 
void set_total_execution_time (int time)
 
int get_total_execution_time ()
 
void calculate_and_set_cpu_load ()
 

Protected Types

using PrimaryResource = SharedPriorityResourceMedium< s_segment_storage< uint64_t, std::shared_ptr< Units::NPC > > >
 
using ResourceManager = SharedPriorityResourceManager< PrimaryResource >
 

Protected Attributes

std::atomic< bool > _is_initialized {false}
 
std::atomic< bool > _is_finalized {false}
 
ResourceManager _resource_manager
 
TaskScheduler _scheduler
 

Private Member Functions

void load_constants ()
 
void load_scripts ()
 
void load_scripts_internal ()
 

Private Attributes

std::vector< std::string > _script_files
 
std::shared_ptr< sol::state > _lua_state
 
std::shared_ptr< PlayerComponent_player_component
 
std::shared_ptr< NPCComponent_npc_component
 
std::shared_ptr< MonsterComponent_monster_component
 
std::shared_ptr< MapComponent_map_component
 
std::shared_ptr< ItemComponent_item_component
 
std::shared_ptr< UnitComponent_unit_component
 
std::shared_ptr< SkillComponent_skill_component
 
std::shared_ptr< StatusEffectComponent_status_effect_component
 
std::shared_ptr< CombatComponent_combat_component
 
std::thread _thread
 

Member Typedef Documentation

◆ PrimaryResource

◆ ResourceManager

Constructor & Destructor Documentation

◆ ScriptManager()

ScriptManager::ScriptManager ( )
50_lua_state(std::make_shared<sol::state>()),
51_player_component(std::make_shared<PlayerComponent>()),
52_npc_component(std::make_shared<NPCComponent>()),
53_monster_component(std::make_shared<MonsterComponent>()),
54_map_component(std::make_shared<MapComponent>()),
55_item_component(std::make_shared<ItemComponent>()),
56_unit_component(std::make_shared<UnitComponent>()),
57_skill_component(std::make_shared<SkillComponent>()),
58_status_effect_component(std::make_shared<StatusEffectComponent>()),
59_combat_component(std::make_shared<CombatComponent>()),
60_resource_manager(PrimaryResource(RESOURCE_PRIORITY_PRIMARY, std::make_shared<s_segment_storage<uint64_t, std::shared_ptr<Units::NPC>>>()))
61{
62}
@ RESOURCE_PRIORITY_PRIMARY
Definition: Server.hpp:79
#define sZone
Definition: Zone.hpp:247
std::shared_ptr< SkillComponent > _skill_component
Definition: ScriptManager.hpp:108
std::shared_ptr< PlayerComponent > _player_component
Definition: ScriptManager.hpp:102
SharedPriorityResourceMedium< s_segment_storage< uint64_t, std::shared_ptr< Units::NPC > > > PrimaryResource
Definition: ScriptManager.hpp:117
std::shared_ptr< CombatComponent > _combat_component
Definition: ScriptManager.hpp:110
std::shared_ptr< ItemComponent > _item_component
Definition: ScriptManager.hpp:106
ResourceManager _resource_manager
Definition: ScriptManager.hpp:119
std::shared_ptr< MonsterComponent > _monster_component
Definition: ScriptManager.hpp:104
std::shared_ptr< MapComponent > _map_component
Definition: ScriptManager.hpp:105
std::shared_ptr< UnitComponent > _unit_component
Definition: ScriptManager.hpp:107
std::shared_ptr< StatusEffectComponent > _status_effect_component
Definition: ScriptManager.hpp:109
std::shared_ptr< NPCComponent > _npc_component
Definition: ScriptManager.hpp:103
std::shared_ptr< sol::state > _lua_state
Definition: ScriptManager.hpp:100
KernelComponent(Kernel *kernel, Horizon::System::runtime_module_type module_type)
Definition: Server.hpp:194
@ RUNTIME_SCRIPTVM
Definition: System.hpp:87
Definition: Server.hpp:93

◆ ~ScriptManager()

ScriptManager::~ScriptManager ( )
65{
66 if (_lua_state != nullptr)
67 _lua_state.reset();
68}

References _lua_state.

Member Function Documentation

◆ combat()

std::shared_ptr< CombatComponent > Horizon::Zone::ScriptManager::combat ( )
inline
78{ return _combat_component; }

References _combat_component.

◆ finalize()

void ScriptManager::finalize ( )
overridevirtual

Reimplemented from KernelComponent.

92{
93 if (_thread.joinable()) {
94 try {
95 _thread.join();
96 } catch(std::exception &e) {
97 HLog(error) << "ScriptManager::finalize: " << e.what();
98 }
99 }
100
101 _lua_state->collect_garbage();
102
103 _script_files.clear();
104
105 _is_finalized.exchange(true);
106}
#define HLog(type)
Definition: Logger.hpp:122
std::atomic< bool > _is_finalized
Definition: ScriptManager.hpp:115
std::thread _thread
Definition: ScriptManager.hpp:112
std::vector< std::string > _script_files
Definition: ScriptManager.hpp:99

References _is_finalized, _lua_state, _script_files, _thread, and HLog.

◆ get_resource_manager()

ResourceManager & Horizon::Zone::ScriptManager::get_resource_manager ( )
inline
122{ return _resource_manager; }

References _resource_manager.

◆ getScheduler()

TaskScheduler & Horizon::Zone::ScriptManager::getScheduler ( )
inline
92{ return _scheduler; }
TaskScheduler _scheduler
Definition: ScriptManager.hpp:120

References _scheduler.

Referenced by initialize_basic_state(), and update().

+ Here is the caller graph for this function:

◆ initialize()

void ScriptManager::initialize ( int  segment_number = 1)
overridevirtual

Reimplemented from KernelComponent.

71{
72 set_segment_number(segment_number);
73 _thread = std::thread(&ScriptManager::start, this);
74
75 for (int i = 0; i < sZone->get_registered_component_count_of_type(Horizon::System::RUNTIME_GAMELOGIC); i++)
76 while (sZone->get_component_of_type<Horizon::Zone::GameLogicProcess>(Horizon::System::RUNTIME_GAMELOGIC, i + 1)->is_initialized() == false)
77 std::this_thread::sleep_for(std::chrono::milliseconds(1));
78
83
86
87 _is_initialized.exchange(true);
88
89}
Definition: GameLogicProcess.hpp:48
bool is_initialized() override
Definition: GameLogicProcess.hpp:88
void initialize_monster_state(std::shared_ptr< sol::state > state)
Definition: ScriptManager.cpp:261
void load_constants()
Definition: ScriptManager.cpp:308
void start()
Definition: ScriptManager.cpp:108
std::atomic< bool > _is_initialized
Definition: ScriptManager.hpp:114
void initialize_basic_state(std::shared_ptr< sol::state > state)
Definition: ScriptManager.cpp:139
void initialize_player_state(std::shared_ptr< sol::state > state)
Definition: ScriptManager.cpp:236
void load_scripts()
Definition: ScriptManager.cpp:276
void initialize_npc_state(std::shared_ptr< sol::state > state)
Definition: ScriptManager.cpp:248
void set_segment_number(int64_t segment_number)
Definition: Server.hpp:206
@ RUNTIME_GAMELOGIC
Definition: System.hpp:86

References _is_initialized, _lua_state, _thread, initialize_basic_state(), initialize_monster_state(), initialize_npc_state(), initialize_player_state(), Horizon::Zone::GameLogicProcess::is_initialized(), load_constants(), load_scripts(), Horizon::System::RUNTIME_GAMELOGIC, KernelComponent::set_segment_number(), start(), and sZone.

+ Here is the call graph for this function:

◆ initialize_basic_state()

void ScriptManager::initialize_basic_state ( std::shared_ptr< sol::state >  state)
140{
141 sol::protected_function_result res{};
142
143 state->open_libraries(sol::lib::base);
144 state->open_libraries(sol::lib::string);
145 state->open_libraries(sol::lib::math);
146 state->open_libraries(sol::lib::coroutine);
147 state->open_libraries(sol::lib::jit);
148 state->open_libraries(sol::lib::table);
149 state->open_libraries(sol::lib::package);
150 state->open_libraries(sol::lib::os);
151
152 // Load timer function
153
154 state->set_function("get_time", get_sys_time);
155 // @TODO Schedule Function
156 state->set_function("schedule", [this] (uint32_t time, sol::function fn) {
158 Milliseconds(time),
159 [fn] (TaskContext context) {
160 sol::protected_function_result result = fn();
161 if (!result.valid()) {
162 sol::error err = result;
163 HLog(error) << "ScriptManager::initialize_basic_state: Error on scheduled function: " << err.what();
164 }
165 }
166 );
167 });
168
169 _map_component->sync_definitions(state);
170 _map_component->sync_data_types(state);
171 _map_component->sync_functions(state);
172
173 _item_component->sync_definitions(state);
174 _item_component->sync_data_types(state);
175 _item_component->sync_functions(state);
176
177 _skill_component->sync_definitions(state);
178 _skill_component->sync_data_types(state);
179 _skill_component->sync_functions(state);
180
181 _status_effect_component->sync_definitions(state);
182 _status_effect_component->sync_data_types(state);
183 _status_effect_component->sync_functions(state);
184
185 _combat_component->sync_definitions(state);
186 _combat_component->sync_data_types(state);
187 _combat_component->sync_functions(state);
188
189 _unit_component->sync_definitions(state);
190 _unit_component->sync_data_types(state);
191 _unit_component->sync_functions(state);
192
193 std::string script_root_path = sZone->config().get_script_root_path().string();
194 std::string static_db_root_path = sZone->config().get_static_db_path().string();
195 std::vector<std::string> _loadable_files = {
196 script_root_path + "utils/strutils.lua",
197 static_db_root_path + "definitions/constants.lua"
198 };
199
200 for (auto &file : _loadable_files) {
201 try {
202 res = state->script_file(file);
203
204 if (!res.valid()) {
205 sol::error error = res;
206 HLog(error) << "ScriptManager::initialize_state: " << error.what();
207 }
208 } catch (sol::error &error) {
209 HLog(error) << "ScriptManager::initialize_state: " << error.what();
210 }
211 }
212
213 // Macro to constants
214 (*state)["MAX_LEVEL"] = MAX_LEVEL;
215 (*state)["MAX_STATUS_POINTS"] = MAX_STATUS_POINTS;
216 (*state)["MAX_CHARACTER_SLOTS"] = MAX_CHARACTER_SLOTS;
217 (*state)["MAX_VIEW_RANGE"] = MAX_VIEW_RANGE;
218 (*state)["MIN_INVENTORY_SIZE"] = MIN_INVENTORY_SIZE;
219 (*state)["MAX_INVENTORY_SIZE"] = MAX_INVENTORY_SIZE;
220 (*state)["MIN_STORAGE_SIZE"] = MIN_STORAGE_SIZE;
221 (*state)["MAX_STORAGE_SIZE"] = MAX_STORAGE_SIZE;
222 (*state)["MAX_INVENTORY_STACK_LIMIT"] = MAX_INVENTORY_STACK_LIMIT;
223 (*state)["MAX_CART_STACK_LIMIT"] = MAX_CART_STACK_LIMIT;
224 (*state)["MAX_STORAGE_STACK_LIMIT"] = MAX_STORAGE_STACK_LIMIT;
225 (*state)["MAX_GSTORAGE_STACK_LIMIT"] = MAX_GSTORAGE_STACK_LIMIT;
226
227#ifdef RENEWAL
228 (*state)["RENEWAL"] = true;
229#else
230 (*state)["RENEWAL"] = false;
231#endif
232
233 (*state)["basic_component"] = true;
234}
#define MAX_CHARACTER_SLOTS
Definition: Horizon.hpp:57
#define MAX_LEVEL
Definition: Horizon.hpp:48
#define MAX_STATUS_POINTS
Definition: Horizon.hpp:49
#define MAX_VIEW_RANGE
Definition: Horizon.hpp:59
#define MAX_INVENTORY_STACK_LIMIT
Definition: ItemDefinitions.hpp:65
#define MIN_STORAGE_SIZE
Definition: ItemDefinitions.hpp:59
#define MAX_INVENTORY_SIZE
Definition: ItemDefinitions.hpp:54
#define MAX_CART_STACK_LIMIT
Definition: ItemDefinitions.hpp:66
#define MAX_STORAGE_STACK_LIMIT
Definition: ItemDefinitions.hpp:67
#define MAX_GSTORAGE_STACK_LIMIT
Definition: ItemDefinitions.hpp:68
#define MIN_INVENTORY_SIZE
Definition: ItemDefinitions.hpp:53
#define MAX_STORAGE_SIZE
Definition: ItemDefinitions.hpp:60
std::chrono::milliseconds Milliseconds
Definition: TaskScheduler.hpp:31
int64_t get_sys_time()
Definition: Utility.cpp:68
TaskScheduler & getScheduler()
Definition: ScriptManager.hpp:92
Definition: TaskScheduler.hpp:487
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Schedule an event with a fixed rate. Never call this from within a task context! Use TaskContext::Sch...
Definition: TaskScheduler.hpp:278

References _combat_component, _item_component, _map_component, _skill_component, _status_effect_component, _unit_component, get_sys_time(), getScheduler(), HLog, MAX_CART_STACK_LIMIT, MAX_CHARACTER_SLOTS, MAX_GSTORAGE_STACK_LIMIT, MAX_INVENTORY_SIZE, MAX_INVENTORY_STACK_LIMIT, MAX_LEVEL, MAX_STATUS_POINTS, MAX_STORAGE_SIZE, MAX_STORAGE_STACK_LIMIT, MAX_VIEW_RANGE, MIN_INVENTORY_SIZE, MIN_STORAGE_SIZE, TaskScheduler::Schedule(), and sZone.

Referenced by initialize(), initialize_monster_state(), initialize_npc_state(), and initialize_player_state().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize_monster_state()

void ScriptManager::initialize_monster_state ( std::shared_ptr< sol::state >  state)
262{
263 if ((*state)["basic_component"] == sol::lua_nil)
265
266 _monster_component->sync_definitions(state);
267 _monster_component->sync_data_types(state);
268 // @TODO Monster component functions
269 _monster_component->sync_functions(state);
270
271
272 (*state)["monster_component"] = true;
273}

References _monster_component, and initialize_basic_state().

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize_npc_state()

void ScriptManager::initialize_npc_state ( std::shared_ptr< sol::state >  state)
249{
250 if ((*state)["basic_component"] == sol::lua_nil)
252
253 _npc_component->sync_definitions(state);
254 _npc_component->sync_data_types(state);
255 // @TODO NPC Component Functions
256 _npc_component->sync_functions(state);
257
258 (*state)["npc_component"] = true;
259}

References _npc_component, and initialize_basic_state().

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize_player_state()

void ScriptManager::initialize_player_state ( std::shared_ptr< sol::state >  state)
237{
238 if ((*state)["basic_component"] == sol::lua_nil)
240
241 _player_component->sync_definitions(state);
242 _player_component->sync_data_types(state);
243 _player_component->sync_functions(state);
244
245 (*state)["player_component"] = true;
246}

References _player_component, and initialize_basic_state().

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_finalized()

bool Horizon::Zone::ScriptManager::is_finalized ( )
inlineoverridevirtual

Reimplemented from KernelComponent.

83{ return _is_finalized.load(); }

References _is_finalized.

◆ is_initialized()

bool Horizon::Zone::ScriptManager::is_initialized ( )
inlineoverridevirtual

Reimplemented from KernelComponent.

82{ return _is_initialized.load(); }

References _is_initialized.

◆ item()

std::shared_ptr< ItemComponent > Horizon::Zone::ScriptManager::item ( )
inline
74{ return _item_component; }

References _item_component.

◆ load_constants()

void ScriptManager::load_constants ( )
private
309{
310 std::string file_path = sZone->config().get_static_db_path().string();
311
312 // Constants loader acquired, the other threads do not need to load the constants as one has already done it.
313 if (_constants_loader.exchange(true) == true)
314 return;
315
316 try {
317 _lua_state->script_file(file_path + "definitions/constants.lua");
318 sol::table const_table = _lua_state->get<sol::table>("constants");
319 HLog(info) << "Read constants from '" << file_path << "'.";
320 } catch (sol::error &e) {
321 HLog(error) << "Failed to read constants from '" << file_path << "', reason: " << e.what();
322 }
323}
static std::atomic< bool > _constants_loader
Definition: ScriptManager.cpp:307

References _constants_loader, _lua_state, HLog, and sZone.

Referenced by initialize().

+ Here is the caller graph for this function:

◆ load_scripts()

void ScriptManager::load_scripts ( )
private
277{
278 std::string script_root_path = sZone->config().get_script_root_path().string();
279
280 // Script loader acquired, the other threads do not need to load the scripts as one has already done it.
281 if (_script_loader.exchange(true) == true)
282 return;
283
284 try {
285 _lua_state->script_file(script_root_path + "include.lua");
286
287 sol::table scripts = (*_lua_state)["scripts"];
288
289 int count = 0;
290 scripts.for_each([this, &count, &script_root_path](sol::object const &/*key*/, sol::object const& value) {
291 std::string script_file = value.as<std::string>();
292 sol::protected_function fn = _lua_state->load_file(script_root_path + script_file);
293 sol::protected_function_result result = fn();
294 if (!result.valid()) {
295 sol::error error = result;
296 HLog(warning) << "Failed to load file '" << script_file << "' from '" << script_root_path << "', reason: " << error.what();
297 return;
298 }
299 count++;
300 });
301 HLog(info) << "Read " << count << " NPC scripts from '" << script_root_path << "'.";
302 } catch (sol::error &e) {
303 HLog(warning) << "Failed to load included script files from '" << script_root_path << "', reason: " << e.what();
304 }
305}
static std::atomic< bool > _script_loader
Definition: ScriptManager.cpp:275
size_t count(GridTypeListContainer< SPECIFIC_TYPE > const &elements, SPECIFIC_TYPE *)
Definition: GridReferenceContainer.hpp:100

References _lua_state, _script_loader, GridTypeListIterator::count(), HLog, and sZone.

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_scripts_internal()

void Horizon::Zone::ScriptManager::load_scripts_internal ( )
private

◆ lua_state()

std::shared_ptr< sol::state > Horizon::Zone::ScriptManager::lua_state ( )
inline
80{ return _lua_state; }

References _lua_state.

◆ map()

std::shared_ptr< MapComponent > Horizon::Zone::ScriptManager::map ( )
inline
73{ return _map_component; }

References _map_component.

◆ monster()

std::shared_ptr< MonsterComponent > Horizon::Zone::ScriptManager::monster ( )
inline
72{ return _monster_component; }

References _monster_component.

◆ npc()

std::shared_ptr< NPCComponent > Horizon::Zone::ScriptManager::npc ( )
inline
71{ return _npc_component; }

References _npc_component.

◆ player()

std::shared_ptr< PlayerComponent > Horizon::Zone::ScriptManager::player ( )
inline
70{ return _player_component; }

References _player_component.

◆ prepare_lua_state()

void Horizon::Zone::ScriptManager::prepare_lua_state ( std::shared_ptr< sol::state > &  lua)

◆ skill()

std::shared_ptr< SkillComponent > Horizon::Zone::ScriptManager::skill ( )
inline
76{ return _skill_component; }

References _skill_component.

◆ start()

void ScriptManager::start ( )
109{
110
111 while (!sZone->general_conf().is_test_run_minimal() && get_shutdown_stage() == SHUTDOWN_NOT_STARTED) {
112 update(std::time(nullptr));
113 std::this_thread::sleep_for(std::chrono::microseconds(MAX_CORE_UPDATE_INTERVAL));
114 }
115}
#define MAX_CORE_UPDATE_INTERVAL
Definition: Horizon.hpp:63
shutdown_stages get_shutdown_stage()
Definition: Server.hpp:74
@ SHUTDOWN_NOT_STARTED
Definition: Server.hpp:64
void update(uint64_t diff)
Definition: ScriptManager.cpp:117

References get_shutdown_stage(), MAX_CORE_UPDATE_INTERVAL, SHUTDOWN_NOT_STARTED, sZone, and update().

Referenced by initialize(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ status_effect()

std::shared_ptr< StatusEffectComponent > Horizon::Zone::ScriptManager::status_effect ( )
inline

◆ unit()

std::shared_ptr< UnitComponent > Horizon::Zone::ScriptManager::unit ( )
inline
75{ return _unit_component; }

References _unit_component.

◆ update()

void ScriptManager::update ( uint64_t  diff)
118{
119 std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
121
123
124#if WIN32
125 DWORD cpu = GetCurrentProcessorNumber();
126 if (get_thread_cpu_id() != (int) cpu)
128#elif __linux__
129 int cpu = sched_getcpu();
130 if (get_thread_cpu_id() != cpu)
132#endif
134 std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
135 std::chrono::nanoseconds time_span = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start);
136 set_total_execution_time(time_span.count());
137}
void process_queue()
Definition: System.hpp:676
void set_thread_cpu_id(int cpu_id)
Definition: Server.hpp:239
Horizon::System::SystemRoutineManager & get_system_routine_manager()
Definition: Server.hpp:235
void set_total_execution_time(int time)
Definition: Server.hpp:245
void calculate_and_set_cpu_load()
Definition: Server.hpp:257
int get_thread_cpu_id()
Definition: Server.hpp:240
TaskScheduler & Update(success_t const &callback=EmptyCallback)
Update the scheduler to the current time. Calls the optional callback on successfully finish.
Definition: TaskScheduler.cpp:25

References KernelComponent::calculate_and_set_cpu_load(), KernelComponent::get_system_routine_manager(), KernelComponent::get_thread_cpu_id(), getScheduler(), Horizon::System::SystemRoutineManager::process_queue(), KernelComponent::set_thread_cpu_id(), KernelComponent::set_total_execution_time(), start(), and TaskScheduler::Update().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _combat_component

std::shared_ptr<CombatComponent> Horizon::Zone::ScriptManager::_combat_component
private

Referenced by combat(), and initialize_basic_state().

◆ _is_finalized

std::atomic<bool> Horizon::Zone::ScriptManager::_is_finalized {false}
protected

Referenced by finalize(), and is_finalized().

◆ _is_initialized

std::atomic<bool> Horizon::Zone::ScriptManager::_is_initialized {false}
protected

Referenced by initialize(), and is_initialized().

◆ _item_component

std::shared_ptr<ItemComponent> Horizon::Zone::ScriptManager::_item_component
private

Referenced by initialize_basic_state(), and item().

◆ _lua_state

std::shared_ptr<sol::state> Horizon::Zone::ScriptManager::_lua_state
private

◆ _map_component

std::shared_ptr<MapComponent> Horizon::Zone::ScriptManager::_map_component
private

Referenced by initialize_basic_state(), and map().

◆ _monster_component

std::shared_ptr<MonsterComponent> Horizon::Zone::ScriptManager::_monster_component
private

◆ _npc_component

std::shared_ptr<NPCComponent> Horizon::Zone::ScriptManager::_npc_component
private

Referenced by initialize_npc_state(), and npc().

◆ _player_component

std::shared_ptr<PlayerComponent> Horizon::Zone::ScriptManager::_player_component
private

Referenced by initialize_player_state(), and player().

◆ _resource_manager

ResourceManager Horizon::Zone::ScriptManager::_resource_manager
protected

Referenced by get_resource_manager().

◆ _scheduler

TaskScheduler Horizon::Zone::ScriptManager::_scheduler
protected

Referenced by getScheduler().

◆ _script_files

std::vector<std::string> Horizon::Zone::ScriptManager::_script_files
private

Referenced by finalize().

◆ _skill_component

std::shared_ptr<SkillComponent> Horizon::Zone::ScriptManager::_skill_component
private

Referenced by initialize_basic_state(), and skill().

◆ _status_effect_component

std::shared_ptr<StatusEffectComponent> Horizon::Zone::ScriptManager::_status_effect_component
private

◆ _thread

std::thread Horizon::Zone::ScriptManager::_thread
private

Referenced by finalize(), and initialize().

◆ _unit_component

std::shared_ptr<UnitComponent> Horizon::Zone::ScriptManager::_unit_component
private

Referenced by initialize_basic_state(), and unit().


The documentation for this class was generated from the following files: