Skip to content

Commit

Permalink
Merge pull request #454 from ASleepyCat/laser-fix-2
Browse files Browse the repository at this point in the history
Fix regression in laser logic when turning in the opposite direction of an incoming laser
  • Loading branch information
Drewol committed Apr 13, 2021
2 parents afd52a9 + 1c88047 commit cd86945
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Main/src/Scoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ void Scoring::m_UpdateLasers(float deltaTime)
{
MapTime mapTime = m_playback->GetLastTime() + m_inputOffset;
bool currentlySlamNextSegmentStraight[2] = { false };

// Check for new laser segments in laser queue
for (auto it = m_laserSegmentQueue.begin(); it != m_laserSegmentQueue.end();)
{
Expand Down Expand Up @@ -1181,14 +1182,14 @@ void Scoring::m_UpdateLasers(float deltaTime)
}

m_laserInput[i] = autoplay ? 0.0f : m_input->GetInputLaserDir(i);
float inputDir = Math::Sign(m_laserInput[i]);

if (currentSegment)
{
// Update laser gameplay
float positionDelta = laserTargetPositions[i] - laserPositions[i];
float laserDir = currentSegment->GetDirection();
float input = m_laserInput[i];
float inputDir = Math::Sign(input);

if (inputDir != 0)
{
Expand Down Expand Up @@ -1224,8 +1225,14 @@ void Scoring::m_UpdateLasers(float deltaTime)
timeSinceLaserUsed[i] += deltaTime;

// Always snap laser to start sections
if (m_GetLaserObjectWithinTwoBeats(i))
m_autoLaserTime[i] = m_autoLaserDuration;
auto incomingLaser = m_GetLaserObjectWithinTwoBeats(i);
if (incomingLaser)
{
laserPositions[i] = incomingLaser->points[0];
m_autoLaserTime[i] = inputDir == incomingLaser->GetDirection() || inputDir == 0
? m_autoLaserDuration
: 0;
}
}

if (currentlySlamNextSegmentStraight[i])
Expand Down

0 comments on commit cd86945

Please sign in to comment.