Skip to content

Commit 485c6fe

Browse files
committed
fix(game): prevent freeze when pressing 3456 after 2367
Prevent gameplay shortcuts from carrying across scene transitions and triggering during game loading. Refs #322
1 parent cce9880 commit 485c6fe

1 file changed

Lines changed: 46 additions & 5 deletions

File tree

Assets/Scripts/Scenes/Game/GamePlayManager.cs

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public float PlaybackSpeed
163163
float _3456PressTime = 0;
164164
float _1278PressTime = 0;
165165
float _p1PressTime = 0;
166+
bool _isFnKeyInputArmed = false;
166167

167168
float _devicePlaybackOffset = 0f;
168169

@@ -1315,12 +1316,20 @@ void FnKeyStateUpdate()
13151316
{
13161317
using (UnityProfiler.Create("GamePlayManager.FnKeyStateUpdate"))
13171318
{
1318-
if (State == GamePlayStatus.Ended)
1319+
if (State is not (GamePlayStatus.Running or GamePlayStatus.Blocking or GamePlayStatus.WaitForEnd))
13191320
{
1320-
_3456PressTime = 0;
1321-
_2367PressTime = 0;
1322-
_1278PressTime = 0;
1323-
_p1PressTime = 0;
1321+
_isFnKeyInputArmed = false;
1322+
ResetFnKeyPressTimes();
1323+
return;
1324+
}
1325+
if (!_isFnKeyInputArmed)
1326+
{
1327+
// Do not inherit a shortcut that was pressed while entering this Game scene.
1328+
ResetFnKeyPressTimes();
1329+
if (IsFnKeyInputReleased())
1330+
{
1331+
_isFnKeyInputArmed = true;
1332+
}
13241333
return;
13251334
}
13261335
var _inner_2367 = InputManager.CheckSensorStatus(_sensorAreaFor2367[0], SwitchStatus.On) &&
@@ -1461,6 +1470,38 @@ void FnKeyStateUpdate()
14611470
}
14621471
}
14631472
}
1473+
void ResetFnKeyPressTimes()
1474+
{
1475+
_3456PressTime = 0;
1476+
_2367PressTime = 0;
1477+
_1278PressTime = 0;
1478+
_p1PressTime = 0;
1479+
}
1480+
bool IsFnKeyInputReleased()
1481+
{
1482+
if (InputManager.CheckButtonStatus(ButtonZone.P1, SwitchStatus.On))
1483+
{
1484+
return false;
1485+
}
1486+
for (var i = 0; i < _buttonKeyFor2367.Length; i++)
1487+
{
1488+
if (InputManager.CheckButtonStatus(_buttonKeyFor2367[i], SwitchStatus.On) ||
1489+
InputManager.CheckButtonStatus(_buttonKeyFor3456[i], SwitchStatus.On) ||
1490+
InputManager.CheckButtonStatus(_buttonKeyFor1278[i], SwitchStatus.On))
1491+
{
1492+
return false;
1493+
}
1494+
#if UNITY_ANDROID || UNITY_IOS
1495+
if (InputManager.CheckSensorStatus(_sensorAreaFor2367[i], SwitchStatus.On) ||
1496+
InputManager.CheckSensorStatus(_sensorAreaFor3456[i], SwitchStatus.On) ||
1497+
InputManager.CheckSensorStatus(_sensorAreaFor1278[i], SwitchStatus.On))
1498+
{
1499+
return false;
1500+
}
1501+
#endif
1502+
}
1503+
return true;
1504+
}
14641505
void EnforceGameFailureLateUpdate()
14651506
{
14661507
if (_enforceGameFailureCondition == EnforceGameFailureCondition.Disabled)

0 commit comments

Comments
 (0)