Destroy pre-match objects on seek and block hunter wall-climb while hiding
Destroy every GameObject tagged "PreMatch" locally when the match enters the Seek sub-phase (hooked in ApplyPhaseLocal, runs on every machine; the objects are plain scene geometry with no NetworkObject, so each client cleans up its own copies). Block hunters from starting a wall- or ceiling-climb during the Hide sub-phase via a WallClimbBlockedNow() gate in UpdateWallClimbState; an in-progress climb is exited cleanly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
6fcada4631
commit
c29cd172bf
2 files changed
+31
-2
No files matched your search
@@ -162,6 +162,8 @@ public class MatchManager : MonoBehaviour
|
||||
private float _phaseDuration;
|
||||
private MatchMode _localMode = MatchMode.Classic; // mirror of the server's matchMode, carried in the phase message
|
||||
|
||||
private const string PreMatchTag = "PreMatch"; // scene props destroyed when seek starts
|
||||
|
||||
/// <summary>True while a match sub-phase (Hide/Seek/Resolution) is running on this machine.</summary>
|
||||
public bool MatchActive => _subPhase != MatchSubPhase.None;
|
||||
/// <summary>This machine's current sub-phase (mirror of the server's broadcast).</summary>
|
||||
@@ -566,7 +568,23 @@ public class MatchManager : MonoBehaviour
|
||||
_phaseDuration = duration;
|
||||
_phaseEndTime = Time.time + duration;
|
||||
_localMode = mode;
|
||||
if (changed) SubPhaseChanged?.Invoke(phase);
|
||||
if (changed)
|
||||
{
|
||||
SubPhaseChanged?.Invoke(phase);
|
||||
// Props staged only for the hide phase are gone the instant seek begins.
|
||||
if (phase == MatchSubPhase.Seek) DestroyPreMatchObjects();
|
||||
}
|
||||
}
|
||||
|
||||
// Scene props tagged "PreMatch" exist only while players hide; the moment seek starts they must be gone
|
||||
// on every machine. ApplyPhaseLocal runs on all of them (server directly, clients via the phase message),
|
||||
// so each destroys its own local copies -- these are plain scene geometry, not NetworkObjects, so there
|
||||
// is nothing to replicate.
|
||||
private static void DestroyPreMatchObjects()
|
||||
{
|
||||
var props = GameObject.FindGameObjectsWithTag(PreMatchTag);
|
||||
for (int i = 0; i < props.Length; i++)
|
||||
Destroy(props[i]);
|
||||
}
|
||||
|
||||
// Sends a sub-phase (byte) + its remaining duration (float) + the match mode (byte) to one client, or to
|
||||
|
||||
Reference in new issue
Block a user