Refactor Assets/Scripts: trim restating comments, minor structure cleanups

Sweep over 48 files (Editor/ excluded): remove comments that restate the
code, condense class summaries, fix three stale doc statements
(HsvColorPicker alpha bar, PaintHud layoutPrefab, MasterVolume
FallbackDefault). Inline two single-use wrappers (IsPointerOverUi,
BuildModes), drop an unused using, replace a magic literal with the
existing ParallaxBase constant, and convert ~10 UnityEngine.Object null
checks to the implicit-bool convention. No serialized fields, signatures,
RPC/NetworkVariable names, defaults, or #if blocks touched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Fable 5 committed 2026-07-08 08:29:18 +02:00
1 parent eeee5fc2f0
commit 6c03e5d3f6
48 files changed
+289 -481

No files matched your search

+32 -41
View File
@@ -307,7 +307,7 @@ public class MatchManager : MonoBehaviour
// Disable NGO auto-spawn (decided purely by PlayerPrefab != null); keep the reference and spawn
// manually once a floored scene exists. Runtime-only mutation - no asset diff.
if (_net != null)
if (_net)
{
_playerPrefab = _net.NetworkConfig.PlayerPrefab;
_net.NetworkConfig.PlayerPrefab = null;
@@ -337,7 +337,6 @@ public class MatchManager : MonoBehaviour
if (Instance == this) Instance = null;
}
// Unhooks the per-session callbacks and named-message handlers (shared by OnDisable and OnNetStopped).
private void UnhookSessionCallbacks()
{
_net.OnClientConnectedCallback -= OnClientConnected;
@@ -455,7 +454,7 @@ public class MatchManager : MonoBehaviour
private void HookSceneManager()
{
if (_hooked || _net == null || _net.SceneManager == null) return;
if (_hooked || !_net || _net.SceneManager == null) return;
_net.SceneManager.OnSceneEvent += OnSceneEvent;
_hooked = true;
}
@@ -483,7 +482,7 @@ public class MatchManager : MonoBehaviour
// the load/respawn routine covers it (the PlayerObject guard in SpawnFor prevents a double spawn).
private void OnClientConnected(ulong clientId)
{
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
// Dedicated-server case: the first client to connect becomes the match authority (a host already
// claimed it at server start). Told via named message so it reads Esc locally.
@@ -514,7 +513,7 @@ public class MatchManager : MonoBehaviour
// dedicated-server match stays controllable.
private void OnClientDisconnected(ulong clientId)
{
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
// A hider that leaves mid-match can never be found - drop it so "all hiders found" can still trigger.
_pendingHiders.Remove(clientId);
@@ -545,7 +544,7 @@ public class MatchManager : MonoBehaviour
// the server, so it records its own identity directly; a pure client reports it to the server by message.
private void OnLocalClientConnected(ulong clientId)
{
if (_net == null || clientId != _net.LocalClientId) return;
if (!_net || clientId != _net.LocalClientId) return;
if (_net.IsServer) RegisterIdentity(_net.LocalClientId, PersistentPlayerId.Value);
else SendIdentityToServer(PersistentPlayerId.Value);
@@ -554,7 +553,7 @@ public class MatchManager : MonoBehaviour
// Client -> server: report this install's persistent id so the server can map it to our ephemeral clientId.
private void SendIdentityToServer(string persistentId)
{
var cmm = _net != null ? _net.CustomMessagingManager : null;
var cmm = _net ? _net.CustomMessagingManager : null;
if (cmm == null || string.IsNullOrEmpty(persistentId)) return;
// Grows up to the cap if a future id source is longer than the initial buffer (persistent ids are short).
using (var writer = new FastBufferWriter(256, Allocator.Temp, 1024))
@@ -568,7 +567,7 @@ public class MatchManager : MonoBehaviour
private void OnIdentityMessage(ulong senderClientId, FastBufferReader reader)
{
reader.ReadValueSafe(out string persistentId);
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
RegisterIdentity(senderClientId, persistentId);
}
@@ -605,8 +604,8 @@ public class MatchManager : MonoBehaviour
/// Safe to call repeatedly (only acts once, while still in the lobby phase).</summary>
public void StartMatch()
{
if (_net == null || !_net.IsServer) return;
if (Phase != MatchPhase.Lobby) return; // double-start / not-in-lobby guard
if (!_net || !_net.IsServer) return;
if (Phase != MatchPhase.Lobby) return;
if (!hunterPrefab || !hiderPrefab)
{
Debug.LogError("[MatchManager] Role prefabs not assigned - cannot start match.", this);
@@ -730,7 +729,6 @@ public class MatchManager : MonoBehaviour
}
}
// Waits up to 'seconds' of server real time, returning early the moment 'until' (if supplied) is true.
private IEnumerator WaitPhase(float seconds, System.Func<bool> until)
{
_skipPhase = false; // drop a stale debug-skip from the previous phase; only this phase may set it
@@ -760,7 +758,7 @@ public class MatchManager : MonoBehaviour
[ContextMenu("Next Sub-Phase (Debug)")]
public void DebugSkipToNextSubPhase()
{
if (_net == null) return;
if (!_net) return;
if (_net.IsServer) { DebugSkipServer(); return; }
if (_isLocalAuthority) SendEmptyNamedMessage(MsgDebugSkip, NetworkManager.ServerClientId);
}
@@ -768,7 +766,7 @@ public class MatchManager : MonoBehaviour
// Server-only. Flags the running phase-wait loop to break early so RunMatchPhases moves to the next sub-phase.
private void DebugSkipServer()
{
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
if (_subPhase == MatchSubPhase.None) return; // nothing running to skip
_skipPhase = true;
Debug.Log($"[MatchManager] DEBUG: skipping the rest of {_subPhase}.", this);
@@ -777,7 +775,7 @@ public class MatchManager : MonoBehaviour
// Server handler: an authority client asked to skip to the next sub-phase.
private void OnDebugSkipMessage(ulong senderClientId, FastBufferReader reader)
{
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
if (!IsMatchAuthority(senderClientId)) return;
DebugSkipServer();
}
@@ -859,7 +857,7 @@ public class MatchManager : MonoBehaviour
// applied paint cutoff - exactly the condition the per-client reveal uses to un-hide the body.
private bool LocalClientReady(List<ulong> ids)
{
var sm = _net != null ? _net.SpawnManager : null;
var sm = _net ? _net.SpawnManager : null;
if (sm == null) return false;
for (int i = 0; i < ids.Count; i++)
{
@@ -873,7 +871,7 @@ public class MatchManager : MonoBehaviour
// Server -> every other client: the target ids + holding phase + generation for this barrier round.
private void BroadcastBeginLoad(MatchSubPhase activePhase)
{
var cmm = _net != null ? _net.CustomMessagingManager : null;
var cmm = _net ? _net.CustomMessagingManager : null;
if (cmm == null) return;
_loadRecipients.Clear();
@@ -932,7 +930,7 @@ public class MatchManager : MonoBehaviour
// Client -> server: this machine finished loading (echoes the generation so a stale reply is ignored).
private void SendReadyToServer(int generation)
{
var cmm = _net != null ? _net.CustomMessagingManager : null;
var cmm = _net ? _net.CustomMessagingManager : null;
if (cmm == null) return;
using (var writer = new FastBufferWriter(sizeof(int), Allocator.Temp))
{
@@ -945,19 +943,17 @@ public class MatchManager : MonoBehaviour
private void OnReadyMessage(ulong senderClientId, FastBufferReader reader)
{
reader.ReadValueSafe(out int generation);
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
if (generation != _loadGeneration) return; // stale ack from a previous barrier round
_readyClients.Add(senderClientId);
}
// Server-only. Applies the sub-phase to the server's own mirror and broadcasts it to every other client.
private void SetPhaseServer(MatchSubPhase phase, float duration)
{
ApplyPhaseLocal(phase, duration, matchMode);
BroadcastPhase(phase, duration, matchMode, 0, true);
}
// Sets this machine's sub-phase mirror + countdown + mode (followers poll LocalSubPhase).
// Shared by the server's SetPhaseServer and a client's OnPhaseMessage handler.
private void ApplyPhaseLocal(MatchSubPhase phase, float duration, MatchMode mode)
{
@@ -987,7 +983,7 @@ public class MatchManager : MonoBehaviour
// (which applied it directly in SetPhaseServer, so it must not double-apply via loopback).
private void BroadcastPhase(MatchSubPhase phase, float duration, MatchMode mode, ulong targetClient, bool toAll)
{
var cmm = _net != null ? _net.CustomMessagingManager : null;
var cmm = _net ? _net.CustomMessagingManager : null;
if (cmm == null) return;
using (var writer = new FastBufferWriter(sizeof(byte) + sizeof(float) + sizeof(byte), Allocator.Temp))
{
@@ -1023,7 +1019,7 @@ public class MatchManager : MonoBehaviour
// locally (no loopback message, mirroring SetPhaseServer). Hiders and spectators never receive a ping.
private void BroadcastRadarPings()
{
if (_net == null || !_net.IsServer || _pendingHiders.Count == 0) return;
if (!_net || !_net.IsServer || _pendingHiders.Count == 0) return;
_radarPingIds.Clear();
foreach (ulong hiderClientId in _pendingHiders)
@@ -1067,7 +1063,7 @@ public class MatchManager : MonoBehaviour
/// directly. No-op outside the Seek phase.</summary>
public void RequestManualPing()
{
if (_net == null || _subPhase != MatchSubPhase.Seek) return;
if (!_net || _subPhase != MatchSubPhase.Seek) return;
if (_net.IsServer) { ServerManualPing(_net.LocalClientId); return; }
SendEmptyNamedMessage(MsgManualPing, NetworkManager.ServerClientId);
@@ -1077,7 +1073,7 @@ public class MatchManager : MonoBehaviour
// ServerManualPing validates it is a live hider during Seek.
private void OnManualPingMessage(ulong senderClientId, FastBufferReader reader)
{
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
ServerManualPing(senderClientId);
}
@@ -1099,7 +1095,7 @@ public class MatchManager : MonoBehaviour
private void SpawnRadarBlipsLocal()
{
var radar = Radar.Instance;
var spawnMgr = _net != null ? _net.SpawnManager : null;
var spawnMgr = _net ? _net.SpawnManager : null;
if (!radar || spawnMgr == null) return;
for (int i = 0; i < _radarPingIds.Count; i++)
if (spawnMgr.SpawnedObjects.TryGetValue(_radarPingIds[i], out var no) && no)
@@ -1113,7 +1109,7 @@ public class MatchManager : MonoBehaviour
reader.ReadValueSafe(out float lifetime);
reader.ReadValueSafe(out int count);
var radar = Radar.Instance;
var spawnMgr = _net != null ? _net.SpawnManager : null;
var spawnMgr = _net ? _net.SpawnManager : null;
for (int i = 0; i < count; i++)
{
reader.ReadValueSafe(out ulong netObjId);
@@ -1128,7 +1124,7 @@ public class MatchManager : MonoBehaviour
/// applies directly. No-op outside the seek phase.</summary>
public void ReportHit(ulong targetClientId)
{
if (_net == null || _subPhase != MatchSubPhase.Seek) return;
if (!_net || _subPhase != MatchSubPhase.Seek) return;
if (_net.IsServer)
{
@@ -1152,7 +1148,7 @@ public class MatchManager : MonoBehaviour
private void OnReportHitMessage(ulong senderClientId, FastBufferReader reader)
{
reader.ReadValueSafe(out ulong targetClientId);
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
if (_subPhase != MatchSubPhase.Seek) return;
if (!_pendingHiders.Contains(targetClientId)) return; // not a live (un-found) hider
if (!IsHunter(senderClientId)) return; // only a hunter may shoot
@@ -1186,7 +1182,7 @@ public class MatchManager : MonoBehaviour
if (hitRevealDelay > 0f) yield return new WaitForSeconds(hitRevealDelay);
_revealingHiders.Remove(hiderClientId);
if (_net == null || !_net.IsServer) yield break;
if (!_net || !_net.IsServer) yield break;
_pendingHiders.Remove(hiderClientId);
@@ -1280,7 +1276,6 @@ public class MatchManager : MonoBehaviour
_conversionRecords.Clear();
}
// Server-only. Despawns every live conversion statue (match ending / back to lobby) and drops the list.
private void DespawnConversionStatues()
{
for (int i = 0; i < _statues.Count; i++)
@@ -1291,7 +1286,6 @@ public class MatchManager : MonoBehaviour
_statues.Clear();
}
// True if the client's current avatar is a Hunter role variant (used to gate shooting server-side).
private bool IsHunter(ulong clientId)
{
if (!_net.ConnectedClients.TryGetValue(clientId, out var c) || !c.PlayerObject) return false;
@@ -1303,7 +1297,7 @@ public class MatchManager : MonoBehaviour
/// neutral lobby Player (including any spectator-held mid-match joiners). Only acts while in a match.</summary>
public void EndMatch()
{
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
if (Phase != MatchPhase.InMatch) return; // only endable mid-match
// Stop the sub-phase machine if the match is being ended early (authority's Back-to-Lobby) and clear
@@ -1329,8 +1323,6 @@ public class MatchManager : MonoBehaviour
Debug.Log("[MatchManager] Back in lobby.", this);
}
// Unloads one gameplay scene (if loaded), then additively loads the next (shared by the match
// start/end sequences).
private IEnumerator SwapScenes(string unloadSceneName, string loadSceneName)
{
var sm = _net.SceneManager;
@@ -1366,9 +1358,8 @@ public class MatchManager : MonoBehaviour
_net.SceneManager.OnSceneEvent -= OnEvt;
}
// Despawns each connected client's current avatar (if any) and spawns the prefab chosen by
// prefabFor at the given position. Used for both lobby->match (role variants) and match->lobby
// (neutral Player); the latter also gives spectator-held joiners their first avatar.
// Used for both lobby->match (role variants) and match->lobby (neutral Player); the latter also
// gives spectator-held joiners their first avatar.
private void RespawnAll(System.Func<ulong, GameObject> prefabFor, Vector3 at)
{
var ids = new List<ulong>(_net.ConnectedClientsIds);
@@ -1437,7 +1428,7 @@ public class MatchManager : MonoBehaviour
{
get
{
if (_net == null) return false;
if (!_net) return false;
if (_net.IsServer) return IsMatchAuthority(_net.LocalClientId);
return _isLocalAuthority;
}
@@ -1448,7 +1439,7 @@ public class MatchManager : MonoBehaviour
/// the authority or no match is running.</summary>
public void RequestEndMatch()
{
if (_net == null) return;
if (!_net) return;
if (_net.IsServer) { EndMatch(); return; } // EndMatch itself guards Phase == InMatch
if (_isLocalAuthority) RequestEndMatchFromServer();
}
@@ -1480,7 +1471,7 @@ public class MatchManager : MonoBehaviour
// so a single dummy byte is written).
private void SendEmptyNamedMessage(string messageName, ulong targetClientId)
{
var cmm = _net != null ? _net.CustomMessagingManager : null;
var cmm = _net ? _net.CustomMessagingManager : null;
if (cmm == null) return;
using (var writer = new FastBufferWriter(sizeof(byte), Allocator.Temp))
{
@@ -1506,7 +1497,7 @@ public class MatchManager : MonoBehaviour
// Server handler: an authority client asked to end the match.
private void OnRequestEndMatchMessage(ulong senderClientId, FastBufferReader reader)
{
if (_net == null || !_net.IsServer) return;
if (!_net || !_net.IsServer) return;
if (!IsMatchAuthority(senderClientId)) return;
EndMatch(); // guards Phase == InMatch itself
}