mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 12:28:03 -08:00
Refactored into modules.
This commit is contained in:
87
MHR_Overlay/Game_Handler/quest_status.lua
Normal file
87
MHR_Overlay/Game_Handler/quest_status.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
local quest_status = {};
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local player;
|
||||
local small_monster;
|
||||
local large_monster;
|
||||
|
||||
quest_status.index = 0;
|
||||
quest_status.is_online = false;
|
||||
quest_status.is_training_area = false;
|
||||
|
||||
local quest_manager_type_definition = sdk.find_type_definition("snow.QuestManager");
|
||||
local on_changed_game_status = quest_manager_type_definition:get_method("onChangedGameStatus");
|
||||
|
||||
sdk.hook(on_changed_game_status, function(args)
|
||||
local new_quest_status = sdk.to_int64(args[3]);
|
||||
if new_quest_status ~= nil then
|
||||
if (quest_status.index < 2 and new_quest_status == 2) or
|
||||
new_quest_status < 2 then
|
||||
|
||||
player.list = {};
|
||||
player.total = player.new(0, "Total", 0);
|
||||
small_monster.list = {};
|
||||
large_monster.list = {};
|
||||
end
|
||||
|
||||
quest_status.index = new_quest_status;
|
||||
end
|
||||
|
||||
end, function(retval)
|
||||
return retval;
|
||||
end);
|
||||
|
||||
function quest_status.init()
|
||||
if singletons.quest_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local new_quest_status = singletons.quest_manager:call("getStatus");
|
||||
if new_quest_status == nil then
|
||||
customization_menu.status = "No quest status";
|
||||
return;
|
||||
end
|
||||
|
||||
quest_status.index = new_quest_status;
|
||||
quest_status.update_is_online();
|
||||
quest_status.update_is_training_area();
|
||||
end
|
||||
|
||||
function quest_status.update_is_online()
|
||||
if singletons.lobby_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local is_quest_online = singletons.lobby_manager:call("IsQuestOnline");
|
||||
if is_quest_online == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
quest_status.is_online = is_quest_online;
|
||||
end
|
||||
|
||||
function quest_status.update_is_training_area()
|
||||
if singletons.village_area_manager == nil then
|
||||
customization_menu.status = "No village area manager";
|
||||
return;
|
||||
end
|
||||
|
||||
local _is_training_area = singletons.village_area_manager:call("checkCurrentArea_TrainingArea");
|
||||
if _is_training_area == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
quest_status.is_training_area = _is_training_area;
|
||||
end
|
||||
|
||||
function quest_status.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
small_monster = require("MHR_Overlay.Monsters.small_monster");
|
||||
large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
|
||||
quest_status.init();
|
||||
end
|
||||
|
||||
return quest_status;
|
||||
Reference in New Issue
Block a user