Disable paint mode during match resolution phase
Force the local avatar out of Paint mode and block the switch key from re-entering it while the match is in its resolution (reveal) window. Painting is off for the local player regardless of role. No restore needed: the match ends by despawning/respawning the avatar, rebuilding the mode cycle at index 0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
91a64545d0
commit
626dcc1bdf
1 file changed
+42
-1
@@ -326,12 +326,53 @@ public class GameModeManager : MonoBehaviour
|
|||||||
if (_paused) return;
|
if (_paused) return;
|
||||||
if (_modes.Count == 0) return;
|
if (_modes.Count == 0) return;
|
||||||
|
|
||||||
|
// Match resolution (the end-of-match reveal window) is watch-only: painting is off. Force out of Paint
|
||||||
|
// mode and keep the switch key from re-entering it. Local + owner by construction - this manager drives
|
||||||
|
// only the local avatar's cycle; remotes have no modes. No restore needed: the match ends by despawning
|
||||||
|
// and respawning the avatar, which rebuilds the cycle at index 0.
|
||||||
|
bool suppressPaint = PaintSuppressed();
|
||||||
|
if (suppressPaint && ActiveMode is PaintMode)
|
||||||
|
{
|
||||||
|
int fallback = FirstNonPaintFrom(0);
|
||||||
|
if (fallback >= 0) SwitchTo(fallback);
|
||||||
|
else if (painter) painter.PaintingEnabled = false; // degenerate paint-only set: at least stop painting
|
||||||
|
}
|
||||||
|
|
||||||
if (WasSwitchPressed())
|
if (WasSwitchPressed())
|
||||||
SwitchTo((_activeIndex + 1) % _modes.Count);
|
{
|
||||||
|
int next = (_activeIndex + 1) % _modes.Count;
|
||||||
|
if (suppressPaint && _modes[next] is PaintMode)
|
||||||
|
{
|
||||||
|
int skip = FirstNonPaintFrom(next);
|
||||||
|
if (skip >= 0) next = skip;
|
||||||
|
}
|
||||||
|
SwitchTo(next);
|
||||||
|
}
|
||||||
|
|
||||||
ActiveMode?.Tick();
|
ActiveMode?.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>True while the local match is in its resolution (reveal) phase, during which painting is
|
||||||
|
/// disabled for the local player regardless of role.</summary>
|
||||||
|
private bool PaintSuppressed()
|
||||||
|
{
|
||||||
|
var match = MatchManager.Instance;
|
||||||
|
return match && match.MatchActive &&
|
||||||
|
match.LocalSubPhase == MatchManager.MatchSubPhase.Resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>First non-Paint mode index at or after <paramref name="start"/> (wrapping once through the
|
||||||
|
/// cycle); -1 if the set has no non-paint mode (a degenerate paint-only configuration).</summary>
|
||||||
|
private int FirstNonPaintFrom(int start)
|
||||||
|
{
|
||||||
|
for (int step = 0; step < _modes.Count; step++)
|
||||||
|
{
|
||||||
|
int i = (start + step) % _modes.Count;
|
||||||
|
if (!(_modes[i] is PaintMode)) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Activates the mode at <paramref name="index"/> (Exit old, Enter new).</summary>
|
/// <summary>Activates the mode at <paramref name="index"/> (Exit old, Enter new).</summary>
|
||||||
public void SwitchTo(int index)
|
public void SwitchTo(int index)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user