mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-25 21:08:07 -08:00
Add callback timers
This commit is contained in:
@@ -227,11 +227,9 @@ local function main_loop()
|
|||||||
players.update_myself_position();
|
players.update_myself_position();
|
||||||
quest_status.update_is_online();
|
quest_status.update_is_online();
|
||||||
--quest_status.update_is_quest_host();
|
--quest_status.update_is_quest_host();
|
||||||
time.tick();
|
time.update_timers();
|
||||||
buffs.update();
|
buffs.update();
|
||||||
|
|
||||||
--buffs.debug();
|
|
||||||
|
|
||||||
if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
|
if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
|
||||||
|
|
||||||
local large_monster_UI_config = config.current_config.large_monster_UI;
|
local large_monster_UI_config = config.current_config.large_monster_UI;
|
||||||
@@ -341,3 +339,9 @@ end);
|
|||||||
if imgui.begin_table == nil then
|
if imgui.begin_table == nil then
|
||||||
re.msg(language.current_language.customization_menu.reframework_outdated);
|
re.msg(language.current_language.customization_menu.reframework_outdated);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--------------------------Timers-----------------------------
|
||||||
|
time.new_timer(buffs.update, 0.5);
|
||||||
|
time.new_timer(players.update_display_list, 0.5, 0.3);
|
||||||
|
time.new_timer(time.update_quest_time, 1 / 60, 0.6);
|
||||||
|
--------------------------Timers-----------------------------
|
||||||
@@ -8,6 +8,8 @@ local consumables;
|
|||||||
local melody_effects;
|
local melody_effects;
|
||||||
local utils;
|
local utils;
|
||||||
local language;
|
local language;
|
||||||
|
local time;
|
||||||
|
local quest_status;
|
||||||
|
|
||||||
local sdk = sdk;
|
local sdk = sdk;
|
||||||
local tostring = tostring;
|
local tostring = tostring;
|
||||||
@@ -110,6 +112,11 @@ function this.init_names()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function this.update()
|
function this.update()
|
||||||
|
if quest_status.flow_state == quest_status.flow_states.IN_LOBBY
|
||||||
|
or quest_status.flow_state >= quest_status.flow_states.QUEST_END_ANIMATION then
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
local master_player = find_master_player_method:call(singletons.player_manager);
|
local master_player = find_master_player_method:call(singletons.player_manager);
|
||||||
if master_player == nil then
|
if master_player == nil then
|
||||||
return;
|
return;
|
||||||
@@ -167,6 +174,8 @@ function this.init_module()
|
|||||||
melody_effects = require("MHR_Overlay.Buffs.melody_effects");
|
melody_effects = require("MHR_Overlay.Buffs.melody_effects");
|
||||||
utils = require("MHR_Overlay.Misc.utils");
|
utils = require("MHR_Overlay.Misc.utils");
|
||||||
language = require("MHR_Overlay.Misc.language");
|
language = require("MHR_Overlay.Misc.language");
|
||||||
|
time = require("MHR_Overlay.Game_Handler.time");
|
||||||
|
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||||
end
|
end
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -335,6 +335,20 @@ function this.merge_damage(first, second)
|
|||||||
return first;
|
return first;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function this.update_display_list()
|
||||||
|
local is_on_quest = quest_status.flow_state ~= quest_status.flow_states.IN_LOBBY and quest_status.flow_state ~= quest_status.flow_states.IN_TRAINING_AREA;
|
||||||
|
|
||||||
|
this.display_list = {};
|
||||||
|
this.update_player_list(is_on_quest);
|
||||||
|
non_players.update_servant_list();
|
||||||
|
non_players.update_otomo_list(is_on_quest, quest_status.is_online);
|
||||||
|
|
||||||
|
this.update_dps(false);
|
||||||
|
this.sort_players();
|
||||||
|
|
||||||
|
quest_status.get_cart_count();
|
||||||
|
end
|
||||||
|
|
||||||
function this.update_dps(bypass_freeze)
|
function this.update_dps(bypass_freeze)
|
||||||
local cached_config = config.current_config.damage_meter_UI.settings;
|
local cached_config = config.current_config.damage_meter_UI.settings;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ local players;
|
|||||||
local non_players;
|
local non_players;
|
||||||
local config;
|
local config;
|
||||||
local small_monster;
|
local small_monster;
|
||||||
|
local utils;
|
||||||
|
|
||||||
local sdk = sdk;
|
local sdk = sdk;
|
||||||
local tostring = tostring;
|
local tostring = tostring;
|
||||||
@@ -51,17 +52,51 @@ this.elapsed_seconds = 0;
|
|||||||
this.total_elapsed_script_seconds = 0;
|
this.total_elapsed_script_seconds = 0;
|
||||||
this.last_elapsed_script_seconds = 0;
|
this.last_elapsed_script_seconds = 0;
|
||||||
|
|
||||||
|
this.list = {};
|
||||||
|
|
||||||
|
function this.new_timer(callback, cooldown_seconds, start_offset_seconds)
|
||||||
|
start_offset_seconds = start_offset_seconds or 0;
|
||||||
|
|
||||||
|
if callback == nil or cooldown_seconds == nil then
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local timer = {};
|
||||||
|
timer.callback = callback;
|
||||||
|
timer.cooldown = cooldown_seconds;
|
||||||
|
|
||||||
|
timer.last_trigger_time = os.clock() + start_offset_seconds;
|
||||||
|
|
||||||
|
table.insert(this.list, timer);
|
||||||
|
|
||||||
|
callback();
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.update_timers()
|
||||||
|
this.update_script_time();
|
||||||
|
|
||||||
|
for _, timer in ipairs(this.list) do
|
||||||
|
if this.total_elapsed_script_seconds - timer.last_trigger_time > timer.cooldown then
|
||||||
|
timer.last_trigger_time = this.total_elapsed_script_seconds;
|
||||||
|
timer.callback();
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function this.update_script_time()
|
function this.update_script_time()
|
||||||
this.total_elapsed_script_seconds = os.clock();
|
this.total_elapsed_script_seconds = os.clock();
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.tick()
|
function this.update_quest_time()
|
||||||
this.update_script_time();
|
|
||||||
|
|
||||||
if singletons.quest_manager == nil then
|
if singletons.quest_manager == nil then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if quest_status.flow_state == quest_status.flow_states.IN_LOBBY
|
||||||
|
or quest_status.flow_state >= quest_status.flow_states.QUEST_END_TIMER then
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
local quest_time_elapsed_minutes = get_quest_elapsed_time_min_method:call(singletons.quest_manager);
|
local quest_time_elapsed_minutes = get_quest_elapsed_time_min_method:call(singletons.quest_manager);
|
||||||
if quest_time_elapsed_minutes == nil then
|
if quest_time_elapsed_minutes == nil then
|
||||||
customization_menu.status = "No quest time elapsed minutes";
|
customization_menu.status = "No quest time elapsed minutes";
|
||||||
@@ -77,22 +112,6 @@ function this.tick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
this.elapsed_seconds = quest_time_total_elapsed_seconds - quest_time_elapsed_minutes * 60;
|
this.elapsed_seconds = quest_time_total_elapsed_seconds - quest_time_elapsed_minutes * 60;
|
||||||
|
|
||||||
if this.total_elapsed_script_seconds - this.last_elapsed_script_seconds > 0.5 then
|
|
||||||
this.last_elapsed_script_seconds = this.total_elapsed_script_seconds;
|
|
||||||
|
|
||||||
local is_on_quest = quest_status.flow_state ~= quest_status.flow_states.IN_LOBBY and quest_status.flow_state ~= quest_status.flow_states.IN_TRAINING_AREA;
|
|
||||||
|
|
||||||
players.display_list = {};
|
|
||||||
players.update_player_list(is_on_quest);
|
|
||||||
non_players.update_servant_list();
|
|
||||||
non_players.update_otomo_list(is_on_quest, quest_status.is_online);
|
|
||||||
|
|
||||||
players.update_dps(false);
|
|
||||||
players.sort_players();
|
|
||||||
|
|
||||||
quest_status.get_cart_count();
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.init_module()
|
function this.init_module()
|
||||||
@@ -103,6 +122,7 @@ function this.init_module()
|
|||||||
small_monster = require("MHR_Overlay.Monsters.small_monster");
|
small_monster = require("MHR_Overlay.Monsters.small_monster");
|
||||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||||
non_players = require("MHR_Overlay.Damage_Meter.non_players");
|
non_players = require("MHR_Overlay.Damage_Meter.non_players");
|
||||||
|
utils = require("MHR_Overlay.Misc.utils");
|
||||||
end
|
end
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user