@@ -20,32 +20,25 @@ local color_efficient = Color.terminal_text_header(255, true)
20
20
local color_inefficient = Color .ui_hud_warp_charge_low (255 , true )
21
21
local color_limit = Color .ui_hud_warp_charge_high (255 , true )
22
22
23
- local timer_x_offset = (- UIWorkspaceSettings .screen .size [1 ]
24
- + scenegraph_definition .container .size [1 ])/ 2
23
+ local timer_x_offset = (- UIWorkspaceSettings .screen .size [1 ] + scenegraph_definition .container .size [1 ]) / 2
25
24
25
+ local timer_size = { 0 , 0 }
26
+ local timer_color = { 0 , 0 , 0 , 0 }
26
27
local timer_size_color = function (time_to_refresh , cooldown , current_dodges , force_show_max_width )
27
28
-- NB: time_to_refresh will increase towards zero
28
29
local t_max = cooldown
29
30
if (- time_to_refresh >= t_max or force_show_max_width ) and mod :get (" dodge_timer_hide_full" ) then
30
31
return
31
32
end
32
33
local natural_time = force_show_max_width and 0 or math .clamp ((time_to_refresh + t_max ) / t_max , 0 , 1 )
33
- local timer_size = {
34
- mod :get (" dodge_timer_width" ) * (1 - natural_time ),
35
- mod :get (" dodge_timer_height" ),
36
- }
37
- local timer_color = {}
34
+
35
+ timer_size [1 ] = mod :get (" dodge_timer_width" ) * (1 - natural_time )
36
+ timer_size [2 ] = mod :get (" dodge_timer_height" )
37
+
38
38
local color_start = Color [mod :get (" color_start" )](255 , true )
39
39
local color_end = Color [mod :get (" color_end" )](255 , true )
40
40
for i = 1 , 4 do
41
- table.insert (
42
- timer_color ,
43
- math .lerp (
44
- color_start [i ],
45
- color_end [i ],
46
- natural_time
47
- )
48
- )
41
+ timer_color [i ] = math .lerp (color_start [i ], color_end [i ], natural_time )
49
42
end
50
43
-- Hide timer if dodges are full (useful when playing with the Agile blessing)
51
44
if current_dodges == 0 then
@@ -54,25 +47,6 @@ local timer_size_color = function(time_to_refresh, cooldown, current_dodges, for
54
47
return timer_size , timer_color
55
48
end
56
49
57
- local timer_pass = { {
58
- style_id = " timer" ,
59
- pass_type = " rect" ,
60
- style = {
61
- color = {255 , 255 , 100 , 100 },
62
- vertical_alignment = " top" ,
63
- horizontal_alignment = " center" ,
64
- drop_shadow = true ,
65
- size = {100 , 8 },
66
- offset = {
67
- timer_x_offset ,
68
- mod :get (" dodge_timer_y_offset" ),
69
- },
70
- },
71
- visibility_function = function (content , style )
72
- return mod :get (" dodge_timer" )
73
- end ,
74
- } }
75
-
76
50
local style = {
77
51
line_spacing = 1.2 ,
78
52
font_size = 25 ,
@@ -94,11 +68,26 @@ local widget_definitions = {
94
68
" container"
95
69
),
96
70
97
- dodge_timer = UIWidget .create_definition (
98
- timer_pass
99
- ,
100
- " container"
101
- ),
71
+ dodge_timer = UIWidget .create_definition ({
72
+ {
73
+ style_id = " timer" ,
74
+ pass_type = " rect" ,
75
+ style = {
76
+ color = { 255 , 255 , 100 , 100 },
77
+ vertical_alignment = " top" ,
78
+ horizontal_alignment = " center" ,
79
+ drop_shadow = true ,
80
+ size = { 100 , 8 },
81
+ offset = {
82
+ timer_x_offset ,
83
+ mod :get (" dodge_timer_y_offset" ),
84
+ },
85
+ },
86
+ visibility_function = function (_content , _style )
87
+ return mod :get (" dodge_timer" )
88
+ end ,
89
+ },
90
+ }, " container" ),
102
91
103
92
debug_dodge_count = UIWidget .create_definition ({
104
93
{
@@ -164,12 +153,13 @@ local function _calculate_dodge_diminishing_return(
164
153
return consecutive_dodges , dr_start , dr_limit , diminishing_return
165
154
end
166
155
156
+ local ZERO_SIZE = { 0 , 0 }
167
157
HudElementDodgeCount .update = function (self , dt , t , ui_renderer , render_settings , input_service )
168
158
HudElementDodgeCount .super .update (self , dt , t , ui_renderer , render_settings , input_service )
169
159
-- Reset to empty in case we can't fill it in
170
160
self ._widgets_by_name .dodge_count .content .text = " "
171
161
self ._widgets_by_name .debug_dodge_count .content .text = " "
172
- self ._widgets_by_name .dodge_timer .style .timer .size = { 0 , 0 }
162
+ self ._widgets_by_name .dodge_timer .style .timer .size = ZERO_SIZE
173
163
174
164
if self ._is_in_hub or not mod :get (" dodge_count" ) then
175
165
return
@@ -200,23 +190,23 @@ HudElementDodgeCount.update = function(self, dt, t, ui_renderer, render_settings
200
190
201
191
local archetype = unit_data_extension :archetype ()
202
192
local base_dodge_template = archetype .dodge
203
- local weapon_consecutive_dodges_reset = weapon_dodge_template and weapon_dodge_template .consecutive_dodges_reset or 0
193
+ local weapon_consecutive_dodges_reset = weapon_dodge_template and weapon_dodge_template .consecutive_dodges_reset
194
+ or 0
204
195
local stat_buffs = buff_extension :stat_buffs ()
205
196
local buff_modifier = stat_buffs .dodge_cooldown_reset_modifier
206
197
local buff_dodge_cooldown_reset_modifier = buff_modifier and 1 - (buff_modifier - 1 ) or 1
207
- local relative_cooldown = (base_dodge_template .consecutive_dodges_reset + weapon_consecutive_dodges_reset ) * buff_dodge_cooldown_reset_modifier
198
+ local relative_cooldown = (base_dodge_template .consecutive_dodges_reset + weapon_consecutive_dodges_reset )
199
+ * buff_dodge_cooldown_reset_modifier
208
200
209
- local is_actually_dodging = (movement_state_component .method ~= " vaulting" ) and movement_state_component .is_dodging
201
+ local is_actually_dodging = (movement_state_component .method ~= " vaulting" )
202
+ and movement_state_component .is_dodging
210
203
local relative_time = gameplay_t - dodge_state_component .consecutive_dodges_cooldown
211
- local force_show_max_width = current_dodges ~= 0 and (is_actually_dodging or movement_state_component .method == " sliding" )
212
- local timer_size , timer_color = timer_size_color (
213
- relative_time ,
214
- relative_cooldown ,
215
- current_dodges ,
216
- force_show_max_width
217
- )
204
+ local force_show_max_width = current_dodges ~= 0
205
+ and (is_actually_dodging or movement_state_component .method == " sliding" )
206
+ local timer_size , timer_color =
207
+ timer_size_color (relative_time , relative_cooldown , current_dodges , force_show_max_width )
218
208
219
- self ._widgets_by_name .dodge_timer .style .timer .size = timer_size or { 0 , 0 }
209
+ self ._widgets_by_name .dodge_timer .style .timer .size = timer_size or ZERO_SIZE
220
210
self ._widgets_by_name .dodge_timer .style .timer .color = timer_color or Color .text_default (0 , true )
221
211
222
212
if num_efficient_dodges == math.huge then
@@ -228,11 +218,8 @@ HudElementDodgeCount.update = function(self, dt, t, ui_renderer, render_settings
228
218
or (math.ceil (num_efficient_dodges ) - current_dodges )
229
219
230
220
if mod :get (" show_efficient_dodges" ) then
231
- self ._widgets_by_name .dodge_count .content .text = string.format (
232
- " %d/%d" ,
233
- display_dodges ,
234
- math.ceil (num_efficient_dodges )
235
- )
221
+ self ._widgets_by_name .dodge_count .content .text =
222
+ string.format (" %d/%d" , display_dodges , math.ceil (num_efficient_dodges ))
236
223
else
237
224
self ._widgets_by_name .dodge_count .content .text = tostring (math.ceil (display_dodges ))
238
225
end
@@ -247,11 +234,8 @@ HudElementDodgeCount.update = function(self, dt, t, ui_renderer, render_settings
247
234
end
248
235
249
236
if mod :get (" fade_out_max_dodges" ) and current_dodges == 0 then
250
- local time_since_cooldown = math .clamp (
251
- gameplay_t - dodge_state_component .consecutive_dodges_cooldown - 1 ,
252
- 0 ,
253
- 1
254
- )
237
+ local time_since_cooldown =
238
+ math .clamp (gameplay_t - dodge_state_component .consecutive_dodges_cooldown - 1 , 0 , 1 )
255
239
style .text .text_color [1 ] = math .lerp (255 , 0 , time_since_cooldown )
256
240
end
257
241
0 commit comments