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:
1 parent
2243cc823e
commit
382bfb36df
32 files changed
+292
-348
No files matched your search
+11
-18
@@ -12,6 +12,8 @@ public class MatchHud : MonoBehaviour
|
||||
{
|
||||
private GUIStyle _phaseStyle;
|
||||
private GUIStyle _timeStyle;
|
||||
private int _lastSecond = -1; // countdown text cache: OnGUI runs 2+ times per frame,
|
||||
private string _timeText = ""; // so the string is only rebuilt when the displayed second changes
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
@@ -20,13 +22,20 @@ public class MatchHud : MonoBehaviour
|
||||
|
||||
EnsureStyles();
|
||||
|
||||
int s = Mathf.CeilToInt(Mathf.Max(0f, match.LocalPhaseRemaining));
|
||||
if (s != _lastSecond)
|
||||
{
|
||||
_lastSecond = s;
|
||||
_timeText = $"{s / 60:0}:{s % 60:00}";
|
||||
}
|
||||
|
||||
const float w = 360f;
|
||||
var phaseRect = new Rect((Screen.width - w) * 0.5f, 12f, w, 30f);
|
||||
var timeRect = new Rect(phaseRect.x, phaseRect.y + 28f, w, 36f);
|
||||
DrawShadowed(phaseRect, PhaseLabel(match.LocalSubPhase), _phaseStyle);
|
||||
DrawShadowed(timeRect, FormatTime(match.LocalPhaseRemaining), _timeStyle);
|
||||
DrawShadowed(timeRect, _timeText, _timeStyle);
|
||||
|
||||
if (match.LocalSubPhase == MatchManager.MatchSubPhase.Seek && LocalIsHunter())
|
||||
if (match.LocalSubPhase == MatchManager.MatchSubPhase.Seek && NetworkPlayerSetup.LocalViewerIsHunter())
|
||||
DrawCrosshair();
|
||||
}
|
||||
|
||||
@@ -41,22 +50,6 @@ public class MatchHud : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatTime(float seconds)
|
||||
{
|
||||
int s = Mathf.CeilToInt(Mathf.Max(0f, seconds));
|
||||
return $"{s / 60:0}:{s % 60:00}";
|
||||
}
|
||||
|
||||
private static bool LocalIsHunter()
|
||||
{
|
||||
var nm = Unity.Netcode.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;
|
||||
}
|
||||
|
||||
private static void DrawCrosshair()
|
||||
{
|
||||
float cx = Screen.width * 0.5f;
|
||||
|
||||
Reference in new issue
Block a user