Refactor scripts: dedup remainder, remove dead code, perf hardening

Iteration 4 over Assets/Scripts (no component/file splits, no Unity assets touched):

Dedup:
- Route inline cursor-release, material guards, Ctrl-held and undo/redo
  input through existing InputUtil / SetMatFloat helpers
- Add ungated InputUtil.KeyPressedThisFrame; GameplayKeyPressed builds on it
- Unify FindDeep/FindDeepChild into GeometryUtil.FindDeep

Dead code / stale docs:
- Remove unused code-gen bake path (HsvColorPicker.Build, PaintHud factory)
- Drop unreferenced symbols (SubPhaseChanged event, LocalPhaseDuration,
  IsLocalSceneMain, MouseSensitivity.Changed, IsPaused, InSession,
  NetworkControlled, PreviousPose, JointCount, voxel-count accessors)
- Fix incorrect PlayerRole / PaintHud / Pick / PlayerPose docs

Perf / robustness (behaviour-neutral):
- ConcealmentMeter.Evaluate: reuse vertex/topology buffers, two-pointer
  crossing count
- BuildMeshCaches: alloc-free vertex copy, cached topology/UVs
- Guard all PlayerPaintSync LogSync sites behind logSync
- Cache LocalViewerIsHunter / controller / CanShoot / TypingGuard lookups;
  dedup LocalIsHunter with MatchHud
- Change-guard RefreshEmissionColor and HeroCutout.Disarm
- Cache scene/countdown string comparisons per frame
- Grow NonAlloc buffers and log-once on saturation

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-07-02 13:33:18 +02:00
1 parent 2243cc823e
commit 382bfb36df
32 files changed
+292 -348

No files matched your search

+17 -9
View File
@@ -108,6 +108,7 @@ public class NetworkPlayerSetup : NetworkBehaviour
private MeshPainter _painter; // owns the per-avatar material instance carrying _XRayColor
private ConcealmentMeter _concealment; // owner-only embedded-percent source (disabled on remotes)
private PlayerCharacterController _controller; // sibling, cached (the freeze re-asserts per frame)
private bool _xrayApplied;
private bool _lastXRay;
private bool _frozenApplied;
@@ -125,7 +126,7 @@ public class NetworkPlayerSetup : NetworkBehaviour
if (IsServer && _conversionSpawnPos.HasValue)
_spawnOverride.Value = _conversionSpawnPos.Value;
var controller = GetComponent<PlayerCharacterController>();
var controller = _controller = GetComponent<PlayerCharacterController>();
if (IsOwner)
{
@@ -236,11 +237,8 @@ public class NetworkPlayerSetup : NetworkBehaviour
{
bool freeze = ComputeResolutionFreeze();
if (freeze && IsOwner)
{
var controller = GetComponent<PlayerCharacterController>();
if (controller) controller.ControlEnabled = false;
}
if (freeze && IsOwner && _controller)
_controller.ControlEnabled = false;
if (_frozenApplied && freeze == _lastFrozen) return;
_lastFrozen = freeze;
@@ -362,14 +360,24 @@ public class NetworkPlayerSetup : NetworkBehaviour
}
// True if THIS machine's local player is a Hunter role variant (so it must not see hiders during hide).
private static bool LocalViewerIsHunter()
// Shared with MatchHud. Called per frame per avatar during hide/seek, so the GetComponent result is
// cached per local PlayerObject; a respawn/conversion swaps the object and refreshes the cache.
private static NetworkObject _localViewerPo;
private static bool _localViewerIsHunter;
internal static bool LocalViewerIsHunter()
{
var nm = NetworkManager.Singleton;
if (!nm || nm.LocalClient == null) return false;
var po = nm.LocalClient.PlayerObject;
if (!po) return false;
var setup = po.GetComponent<NetworkPlayerSetup>();
return setup && setup.ScopedModes && setup.Role == PlayerRole.Hunter;
if (po != _localViewerPo)
{
_localViewerPo = po;
var setup = po.GetComponent<NetworkPlayerSetup>();
_localViewerIsHunter = setup && setup.ScopedModes && setup.Role == PlayerRole.Hunter;
}
return _localViewerIsHunter;
}
/// <summary>