@@ -103,6 +103,8 @@ Haywire::collision_squished(GameObject& object)
103
103
void
104
104
Haywire::active_update (float dt_sec)
105
105
{
106
+ auto * player = get_nearest_player ();
107
+
106
108
if (is_exploding) {
107
109
ticking->set_position (get_pos ());
108
110
grunting->set_position (get_pos ());
@@ -126,7 +128,6 @@ Haywire::active_update(float dt_sec)
126
128
127
129
if (is_exploding)
128
130
{
129
- auto player = Sector::get ().get_nearest_player (m_col.m_bbox );
130
131
if (on_ground () && std::abs (m_physic.get_velocity_x ()) > 40 .f && player)
131
132
{
132
133
// jump over 1-tall roadblocks
@@ -154,7 +155,7 @@ Haywire::active_update(float dt_sec)
154
155
gap_box.set_bottom (m_col.m_bbox .get_bottom () + 28 .f );
155
156
156
157
if (Sector::get ().is_free_of_statics (gap_box)
157
- && (get_nearest_player () ->get_bbox ().get_bottom () <= m_col.m_bbox .get_bottom ()))
158
+ && (player ->get_bbox ().get_bottom () <= m_col.m_bbox .get_bottom ()))
158
159
{
159
160
m_physic.set_velocity_y (-325 .f );
160
161
}
@@ -174,17 +175,16 @@ Haywire::active_update(float dt_sec)
174
175
walk_right_action = " active-right" ;
175
176
}
176
177
177
- auto p = get_nearest_player ();
178
178
float target_velocity = 0 .f ;
179
179
180
180
if (stomped_timer.get_timeleft () >= 0 .05f )
181
181
{
182
182
target_velocity = 0 .f ;
183
183
}
184
- else if (p && time_stunned == 0 .0f )
184
+ else if (player && time_stunned == 0 .0f )
185
185
{
186
186
/* Player is on the right or left*/
187
- target_velocity = (p ->get_pos ().x > get_pos ().x ) ? walk_speed : (-1 .f ) * walk_speed;
187
+ target_velocity = (player ->get_pos ().x > get_pos ().x ) ? walk_speed : (-1 .f ) * walk_speed;
188
188
}
189
189
190
190
WalkingBadguy::active_update (dt_sec, target_velocity, 3 .f );
0 commit comments