Skip to content

Commit 728f2eb

Browse files
committed
3AM Clarity patch
1 parent f2fe200 commit 728f2eb

File tree

1 file changed

+17
-40
lines changed

1 file changed

+17
-40
lines changed

src/badguy/crusher.cpp

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ Crusher::should_crush()
169169

170170
continue;
171171
}
172-
else
172+
else if (!playerbbox.overlaps(get_detect_box()))
173173
{
174-
if (!playerbbox.overlaps(get_detect_box()))
175-
continue;
174+
continue;
176175
}
177176

178177
RaycastResult result = Sector::get().get_first_line_intersection(get_bbox().get_middle(),
@@ -942,18 +941,6 @@ Crusher::update(float dt_sec)
942941
{
943942
MovingSprite::update(dt_sec);
944943

945-
Vector frame_movement;
946-
if (m_state == AWAIT_IDLE)
947-
{
948-
frame_movement = Vector(0.f, 0.f);
949-
m_physic.set_velocity(Vector(0.f, 0.f));
950-
}
951-
else
952-
{
953-
frame_movement = m_physic.get_movement(dt_sec);
954-
}
955-
m_col.propagate_movement(frame_movement);
956-
957944
const CrusherState old_state = m_state;
958945

959946
switch (m_state)
@@ -1002,36 +989,27 @@ Crusher::update(float dt_sec)
1002989
{
1003990
brick.break_for_crusher(this);
1004991
}
1005-
else
992+
else if (is_big())
1006993
{
1007-
if (is_big())
1008-
{
1009-
brick.break_for_crusher(this);
1010-
}
994+
brick.break_for_crusher(this);
1011995
}
1012996
}
1013997
}
1014998

1015999
Vector current_velocity = m_physic.get_velocity();
1016-
if (m_dir_vector.x != 0.f) // Horizontal
1000+
if (m_dir_vector.x != 0.f && std::abs(current_velocity.x) > MAX_CRUSH_SPEED) // Horizontal
10171001
{
1018-
if (std::abs(current_velocity.x) > MAX_CRUSH_SPEED)
1019-
{
1020-
current_velocity.x = std::copysign(MAX_CRUSH_SPEED, current_velocity.x);
1021-
m_physic.set_velocity(current_velocity);
1022-
}
1002+
current_velocity.x = std::copysign(MAX_CRUSH_SPEED, current_velocity.x);
1003+
m_physic.set_velocity(current_velocity);
10231004
}
1024-
if (m_dir_vector.y != 0.f) // Vertical
1005+
if (m_dir_vector.y != 0.f && std::abs(current_velocity.y) > MAX_CRUSH_SPEED) // Vertical
10251006
{
1026-
if (std::abs(current_velocity.y) > MAX_CRUSH_SPEED)
1027-
{
1028-
current_velocity.y = std::copysign(MAX_CRUSH_SPEED, current_velocity.y);
1029-
m_physic.set_velocity(current_velocity);
1030-
}
1007+
current_velocity.y = std::copysign(MAX_CRUSH_SPEED, current_velocity.y);
1008+
m_physic.set_velocity(current_velocity);
10311009
}
10321010
break;
10331011
}
1034-
1012+
10351013
case DELAY:
10361014
if (m_state_timer.check())
10371015
{
@@ -1052,12 +1030,9 @@ Crusher::update(float dt_sec)
10521030
{
10531031
idle();
10541032
}
1055-
else
1033+
else if (is_recovery_path_clear_of_crushers())
10561034
{
1057-
if (is_recovery_path_clear_of_crushers())
1058-
{
1059-
recover();
1060-
}
1035+
recover();
10611036
}
10621037
break;
10631038

@@ -1066,19 +1041,21 @@ Crusher::update(float dt_sec)
10661041
break;
10671042
}
10681043

1044+
Vector frame_movement;
1045+
10691046
// Prevent extra movement after idle() sets position.
10701047
if (old_state == RECOVERING && m_state == IDLE)
10711048
{
10721049
frame_movement = Vector(0.0f, 0.0f);
10731050
}
1074-
1075-
if (m_state != AWAIT_IDLE)
1051+
else if (m_state != AWAIT_IDLE)
10761052
{
10771053
frame_movement = m_physic.get_movement(dt_sec);
10781054
}
10791055
else
10801056
{
10811057
frame_movement = Vector(0.0f, 0.0f);
1058+
m_physic.set_velocity(Vector(0.0f, 0.0f));
10821059
}
10831060

10841061
bool in_water = !Sector::get().is_free_of_tiles(get_bbox(), true, Tile::WATER);

0 commit comments

Comments
 (0)