Replace SystemArray wrapper methods with actual System.Array methods

This commit is contained in:
GreenComfyTea
2022-08-13 17:00:55 +03:00
parent acd7486b16
commit abec9a5c27
4 changed files with 40 additions and 33 deletions

View File

@@ -179,10 +179,10 @@ local poison_damage_field = poison_param_type:get_field("<Damage>k__BackingField
local poison_get_is_damage_method = poison_param_type:get_method("get_IsDamage");
local system_array_type_def = sdk.find_type_definition("System.Array");
local length_method = system_array_type_def:get_method("GetLength");
local length_method = system_array_type_def:get_method("get_Length");
local get_value_method = system_array_type_def:get_method("GetValue(System.Int32)");
function ailments.update_ailments(enemy, monster, is_init)
function ailments.update_ailments(enemy, monster)
if enemy == nil then
return;
end
@@ -209,22 +209,22 @@ function ailments.update_ailments(enemy, monster, is_init)
return;
end
local condition_param_array_size = condition_param_array:get_size();
if condition_param_array_size == nil then
local condition_param_array_length = length_method:call(condition_param_array);
if condition_param_array_length == nil then
return;
end
for id = 0, condition_param_array_size - 1 do
for id = 0, condition_param_array_length - 1 do
if id == ailments.stun_id or id == ailments.poison_id or id == ailments.blast_id then
goto continue
end
local ailment_param = condition_param_array[id];
local ailment_param = get_value_method:call(condition_param_array, id);
if ailment_param == nil then
goto continue
end
ailments.update_ailment(monster, ailment_param, id, is_init);
ailments.update_ailment(monster, ailment_param, id);
::continue::
end
end
@@ -246,7 +246,7 @@ function ailments.update_stun_poison_blast_ailments(monster, damage_param)
end
end
function ailments.update_ailment(monster, ailment_param, id, is_init)
function ailments.update_ailment(monster, ailment_param, id)
local is_enable = get_is_enable_method:call(ailment_param);
local activate_count_array = get_activate_count_method:call(ailment_param);
local buildup_array = get_stock_method:call(ailment_param);
@@ -260,12 +260,12 @@ function ailments.update_ailment(monster, ailment_param, id, is_init)
local buildup_limit = 9999;
if activate_count_array ~= nil then
local activate_count_array_size = activate_count_array:get_size();
local activate_count_array_length = length_method:call(activate_count_array);
if activate_count_array_size ~= nil then
if activate_count_array_length ~= nil then
if activate_count_array_size > 0 then
local activate_count_valuetype = activate_count_array[0];
if activate_count_array_length > 0 then
local activate_count_valuetype = get_value_method:call(activate_count_array, 0);
if activate_count_valuetype ~= nil then
local _activate_count = activate_count_valuetype:get_field("mValue");
@@ -279,12 +279,12 @@ function ailments.update_ailment(monster, ailment_param, id, is_init)
end
if buildup_array ~= nil then
local buildup_array_size = buildup_array:get_size();
local buildup_array_length = length_method:call(buildup_array);
if buildup_array_size ~= nil then
if buildup_array_length ~= nil then
if buildup_array_size > 0 then
local buildup_valuetype = buildup_array[0];
if buildup_array_length > 0 then
local buildup_valuetype = get_value_method:call(buildup_array, 0);
if buildup_valuetype ~= nil then
local _buildup = buildup_valuetype:get_field("mValue");
@@ -298,12 +298,12 @@ function ailments.update_ailment(monster, ailment_param, id, is_init)
end
if buildup_limit_array ~= nil then
local buildup_limit_array_size = buildup_limit_array:get_size();
local buildup_limit_array_length = length_method:call(buildup_limit_array);
if buildup_limit_array_size ~= nil then
if buildup_limit_array_length ~= nil then
if buildup_limit_array_size > 0 then
local buildup_limit_valuetype = buildup_limit_array[0];
if buildup_limit_array_length > 0 then
local buildup_limit_valuetype = get_value_method:call(buildup_limit_array, 0);
if buildup_limit_valuetype ~= nil then
local _buildup_limit = buildup_limit_valuetype:get_field("mValue");

View File

@@ -105,7 +105,7 @@ function large_monster.new(enemy)
large_monster.update_rage(enemy, monster, nil);
large_monster.update_rage_timer(enemy, monster, nil);
large_monster.update(enemy, monster, true);
large_monster.update(enemy, monster);
pcall(large_monster.update_parts, enemy, monster, physical_param);
if large_monster.list[enemy] == nil then
@@ -320,6 +320,10 @@ local get_mario_player_index_method = mario_param_type:get_method("get_MarioPlay
local get_pos_field = enemy_character_base_type_def:get_method("get_Pos");
local system_array_type_def = sdk.find_type_definition("System.Array");
local length_method = system_array_type_def:get_method("get_Length");
local get_value_method = system_array_type_def:get_method("GetValue(System.Int32)");
function large_monster.update_position(enemy, monster)
if not config.current_config.large_monster_UI.dynamic.enabled and
config.current_config.large_monster_UI.static.sorting.type ~= "Distance" then
@@ -350,7 +354,7 @@ function large_monster.update_all_riders()
end
function large_monster.update(enemy, monster, is_init)
function large_monster.update(enemy, monster)
local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled
@@ -369,7 +373,7 @@ function large_monster.update(enemy, monster, is_init)
monster.is_disp_icon_mini_map = is_disp_icon_mini_map;
end
pcall(ailments.update_ailments, enemy, monster, is_init);
pcall(ailments.update_ailments, enemy, monster);
end
function large_monster.update_health(enemy, monster)
@@ -627,14 +631,19 @@ function large_monster.update_parts(enemy, monster, physical_param)
return;
end
local enemy_parts_info_array_size = enemy_parts_info_array:get_size();
if enemy_parts_info_array_size == nil then
local enemy_parts_info_array_length = length_method:call(enemy_parts_info_array);
if enemy_parts_info_array_length == nil then
return;
end
local part_id = 1;
for i = 0, enemy_parts_info_array_size - 1 do
local enemy_parts_info = enemy_parts_info_array[i];
for i = 0, enemy_parts_info_array_length - 1 do
local part_id = i + 1;
local enemy_parts_info = get_value_method:call(enemy_parts_info_array, i);
if enemy_parts_info == nil then
goto continue
end
local part = monster.parts[part_id];
if part == nil then
@@ -695,12 +704,11 @@ function large_monster.update_parts(enemy, monster, physical_param)
end
end
body_part.update_loss(part, part_loss_current, part_loss_max, is_severed)
body_part.update_loss(part, part_loss_current, part_loss_max, is_severed);
end
end
::continue::
part_id = part_id + 1;
end
end

View File

@@ -123,7 +123,7 @@ function monster_hook.update_large_monster(enemy)
pcall(large_monster.update_parts, enemy, monster, physical_param);
end
large_monster.update(enemy, monster, false);
large_monster.update(enemy, monster);
end
function monster_hook.update_small_monster(enemy)

View File

@@ -157,8 +157,7 @@ function small_monster.update(enemy, monster)
monster.dead_or_captured = dead_or_captured;
end
--do return end;
pcall(ailments.update_ailments, enemy, monster, false);
pcall(ailments.update_ailments, enemy, monster);
end
function small_monster.update_health(enemy, monster)