Part Break/Sever implemented. Fallback to default renderer if d2d is not available.

This commit is contained in:
GreenComfyTea
2022-06-17 14:24:46 +03:00
parent 7d0adc5139
commit 1a95634ec2
17 changed files with 9365 additions and 3941 deletions

View File

@@ -14,25 +14,33 @@ local time;
body_part.list = {};
function body_part.new(REpart, name, id)
function body_part.new(id, name)
local part = {};
part.REpart = REpart;
part.id = id;
part.health = 99999;
part.health = 9999;
part.max_health = 99999;
part.health_percentage = 0;
part.break_health = 9999;
part.break_max_health = 99999;
part.break_health_percentage = 0;
part.lost_health = 9999;
part.loss_max_health = 99999;
part.loss_health_percentage = 0;
part.name = name;
part.flinch_count = 0;
part.break_count = 0;
part.break_max_count = 0;
part.last_change_time = time.total_elapsed_seconds;
body_part.init_dynamic_UI(part);
body_part.init_static_UI(part);
body_part.init_highlighted_UI(part);
return part;
end
@@ -40,62 +48,146 @@ end
function body_part.init_dynamic_UI(part)
part.body_part_dynamic_UI = body_part_UI_entity.new(
config.current_config.large_monster_UI.dynamic.parts.visibility,
config.current_config.large_monster_UI.dynamic.parts.bar,
config.current_config.large_monster_UI.dynamic.parts.part_name_label,
config.current_config.large_monster_UI.dynamic.parts.text_label,
config.current_config.large_monster_UI.dynamic.parts.value_label,
config.current_config.large_monster_UI.dynamic.parts.percentage_label
config.current_config.large_monster_UI.dynamic.parts.part_health.visibility,
config.current_config.large_monster_UI.dynamic.parts.part_health.bar,
config.current_config.large_monster_UI.dynamic.parts.part_health.text_label,
config.current_config.large_monster_UI.dynamic.parts.part_health.value_label,
config.current_config.large_monster_UI.dynamic.parts.part_health.percentage_label,
config.current_config.large_monster_UI.dynamic.parts.part_break.visibility,
config.current_config.large_monster_UI.dynamic.parts.part_break.bar,
config.current_config.large_monster_UI.dynamic.parts.part_break.text_label,
config.current_config.large_monster_UI.dynamic.parts.part_break.value_label,
config.current_config.large_monster_UI.dynamic.parts.part_break.percentage_label,
config.current_config.large_monster_UI.dynamic.parts.part_loss.visibility,
config.current_config.large_monster_UI.dynamic.parts.part_loss.bar,
config.current_config.large_monster_UI.dynamic.parts.part_loss.text_label,
config.current_config.large_monster_UI.dynamic.parts.part_loss.value_label,
config.current_config.large_monster_UI.dynamic.parts.part_loss.percentage_label
);
end
function body_part.init_static_UI(part)
part.body_part_static_UI = body_part_UI_entity.new(
config.current_config.large_monster_UI.static.parts.visibility,
config.current_config.large_monster_UI.static.parts.bar,
config.current_config.large_monster_UI.static.parts.part_name_label,
config.current_config.large_monster_UI.static.parts.text_label,
config.current_config.large_monster_UI.static.parts.value_label,
config.current_config.large_monster_UI.static.parts.percentage_label
config.current_config.large_monster_UI.static.parts.part_health.visibility,
config.current_config.large_monster_UI.static.parts.part_health.bar,
config.current_config.large_monster_UI.static.parts.part_health.text_label,
config.current_config.large_monster_UI.static.parts.part_health.value_label,
config.current_config.large_monster_UI.static.parts.part_health.percentage_label,
config.current_config.large_monster_UI.static.parts.part_break.visibility,
config.current_config.large_monster_UI.static.parts.part_break.bar,
config.current_config.large_monster_UI.static.parts.part_break.text_label,
config.current_config.large_monster_UI.static.parts.part_break.value_label,
config.current_config.large_monster_UI.static.parts.part_break.percentage_label,
config.current_config.large_monster_UI.static.parts.part_loss.visibility,
config.current_config.large_monster_UI.static.parts.part_loss.bar,
config.current_config.large_monster_UI.static.parts.part_loss.text_label,
config.current_config.large_monster_UI.static.parts.part_loss.value_label,
config.current_config.large_monster_UI.static.parts.part_loss.percentage_label
);
end
function body_part.init_highlighted_UI(part)
part.body_part_highlighted_UI = body_part_UI_entity.new(
config.current_config.large_monster_UI.highlighted.parts.visibility,
config.current_config.large_monster_UI.highlighted.parts.bar,
config.current_config.large_monster_UI.highlighted.parts.part_name_label,
config.current_config.large_monster_UI.highlighted.parts.text_label,
config.current_config.large_monster_UI.highlighted.parts.value_label,
config.current_config.large_monster_UI.highlighted.parts.percentage_label
config.current_config.large_monster_UI.highlighted.parts.part_health.visibility,
config.current_config.large_monster_UI.highlighted.parts.part_health.bar,
config.current_config.large_monster_UI.highlighted.parts.part_health.text_label,
config.current_config.large_monster_UI.highlighted.parts.part_health.value_label,
config.current_config.large_monster_UI.highlighted.parts.part_health.percentage_label,
config.current_config.large_monster_UI.highlighted.parts.part_break.visibility,
config.current_config.large_monster_UI.highlighted.parts.part_break.bar,
config.current_config.large_monster_UI.highlighted.parts.part_break.text_label,
config.current_config.large_monster_UI.highlighted.parts.part_break.value_label,
config.current_config.large_monster_UI.highlighted.parts.part_break.percentage_label,
config.current_config.large_monster_UI.highlighted.parts.part_loss.visibility,
config.current_config.large_monster_UI.highlighted.parts.part_loss.bar,
config.current_config.large_monster_UI.highlighted.parts.part_loss.text_label,
config.current_config.large_monster_UI.highlighted.parts.part_loss.value_label,
config.current_config.large_monster_UI.highlighted.parts.part_loss.percentage_label
);
end
function body_part.update(part, new_health, new_max_health)
function body_part.update(part, part_current, part_max, part_break_current, part_break_max, part_loss_current, part_loss_max, part_break_count, part_break_max_count, is_severed)
if part == nil then
return;
end
if new_health > part.health then
if part_current > part.health then
part.flinch_count = part.flinch_count + 1;
end
if part.health ~= new_health then
if part_break_current > part.break_health then
part.break_count = part.break_count + 1;
end
if part.health ~= part_current then
part.last_change_time = time.total_elapsed_seconds;
end
if part.break_health ~= part_break_current then
part.last_change_time = time.total_elapsed_seconds;
end
if part.loss_health ~= part_loss_current then
part.last_change_time = time.total_elapsed_seconds;
end
if part.break_count ~= part_break_count then
part.last_change_time = time.total_elapsed_seconds;
end
if part.break_max_count ~= part_break_max_count then
part.last_change_time = time.total_elapsed_seconds;
end
if part.is_severed ~= is_severed then
part.last_change_time = time.total_elapsed_seconds;
end
part.health = new_health;
part.max_health = new_max_health;
part.health = part_current;
part.max_health = part_max;
part.break_health = part_break_current;
part.break_max_health = part_break_max;
part.loss_health = part_loss_current;
part.loss_max_health = part_loss_max;
part.break_count = part_break_count;
part.break_max_count = part_break_max_count;
part.is_severed = is_severed;
if part.max_health ~= 0 then
part.health_percentage = part.health / part.max_health;
end
if part.break_max_health ~= 0 then
part.break_health_percentage = part.break_health / part.break_max_health;
end
if part.loss_max_health ~= 0 then
part.loss_health_percentage = part.loss_health / part.loss_max_health;
end
end
function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale)
--sort parts here
local displayed_parts = {};
for REpart, part in pairs(monster.parts) do
if config.current_config.large_monster_UI.dynamic.parts.settings.hide_undamaged_parts and part.health == part.max_health and part.flinch_count == 0 then
if config.current_config.large_monster_UI.dynamic.parts.settings.hide_undamaged_parts
and part.health == part.max_health and part.flinch_count == 0
and ((part.break_health == part.break_max_health and part.break_count == 0) or part.break_max_health < 0)
and ((part.loss_health == part.loss_max_health and not part.is_severed) or part.loss_max_health < 0) then
goto continue;
end
if (not part.body_part_dynamic_UI.flinch_visibility)
and (not part.body_part_dynamic_UI.break_visibility or part.break_max_health < 0 or part.break_count >= part.break_max_count)
and (not part.body_part_dynamic_UI.loss_visibility or part.loss_max_health < 0 or part.is_severed) then
goto continue;
end
@@ -137,6 +229,66 @@ function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Flinch Count" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.flinch_count > right.flinch_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.flinch_count < right.flinch_count;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Break Health" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health > right.break_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health < right.break_health;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Break Health Percentage" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage > right.break_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage < right.break_health_percentage;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Break Count" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_count > right.break_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_count < right.break_count;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Sever Health" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health > right.loss_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health < right.loss_health;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Sever Health Percentage" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage > right.loss_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage < right.loss_health_percentage;
end);
end
end
local last_part_position_on_screen;
@@ -155,11 +307,19 @@ function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale
end
function body_part.draw_static(monster, parts_position_on_screen, opacity_scale)
--sort parts here
local displayed_parts = {};
for REpart, part in pairs(monster.parts) do
if config.current_config.large_monster_UI.static.parts.settings.hide_undamaged_parts and part.health == part.max_health and part.flinch_count == 0 then
if config.current_config.large_monster_UI.static.parts.settings.hide_undamaged_parts
and part.health == part.max_health and part.flinch_count == 0
and ((part.break_health == part.break_max_health and part.break_count == 0) or part.break_max_health < 0)
and ((part.loss_health == part.loss_max_health and not part.is_severed) or part.loss_max_health < 0) then
goto continue;
end
if (not part.body_part_static_UI.flinch_visibility)
and (not part.body_part_static_UI.break_visibility or part.break_max_health < 0 or part.break_count >= part.break_max_count)
and (not part.body_part_static_UI.loss_visibility or part.loss_max_health < 0 or part.is_severed) then
goto continue;
end
@@ -201,6 +361,66 @@ function body_part.draw_static(monster, parts_position_on_screen, opacity_scale)
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Flinch Count" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.flinch_count > right.flinch_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.flinch_count < right.flinch_count;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Break Health" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health > right.break_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health < right.break_health;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Break Health Percentage" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage > right.break_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage < right.break_health_percentage;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Break Count" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_count > right.break_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_count < right.break_count;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Sever Health" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health > right.loss_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health < right.loss_health;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Sever Health Percentage" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage > right.loss_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage < right.loss_health_percentage;
end);
end
end
local last_part_position_on_screen;
@@ -219,10 +439,18 @@ function body_part.draw_static(monster, parts_position_on_screen, opacity_scale)
end
function body_part.draw_highlighted(monster, parts_position_on_screen, opacity_scale)
--sort parts here
local displayed_parts = {};
for REpart, part in pairs(monster.parts) do
if config.current_config.large_monster_UI.highlighted.parts.settings.hide_undamaged_parts and part.health == part.max_health and part.flinch_count == 0 then
if config.current_config.large_monster_UI.highlighted.parts.settings.hide_undamaged_parts
and part.health == part.max_health and part.flinch_count == 0
and ((part.break_health == part.break_max_health and part.break_count == 0) or part.break_max_health < 0)
and ((part.loss_health == part.loss_max_health and not part.is_severed) or part.loss_max_health < 0) then
goto continue;
end
if (not part.body_part_highlighted_UI.flinch_visibility)
and (not part.body_part_highlighted_UI.break_visibility or part.break_max_health < 0 or part.break_count >= part.break_max_count)
and (not part.body_part_highlighted_UI.loss_visibility or part.loss_max_health < 0 or part.is_severed) then
goto continue;
end
@@ -264,6 +492,66 @@ function body_part.draw_highlighted(monster, parts_position_on_screen, opacity_s
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Flinch Count" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.flinch_count > right.flinch_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.flinch_count < right.flinch_count;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Break Health" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health > right.break_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health < right.break_health;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Break Health Percentage" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage > right.break_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage < right.break_health_percentage;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Break Count" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_count > right.break_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_count < right.break_count;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Sever Health" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health > right.loss_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health < right.loss_health;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Sever Health Percentage" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage > right.loss_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage < right.loss_health_percentage;
end);
end
end
local last_part_position_on_screen;