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
@@ -215,10 +215,10 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
private float _verticalVelocity;
|
||||
private Vector3 _horizontalVelocity; // smoothed horizontal move velocity (accel/decel ramp)
|
||||
private Vector3 _climbVelocity; // smoothed along-surface climb velocity (accel ramp for precise placement)
|
||||
private bool _sprinting; // sprint key state this frame (exposed via IsSprinting)
|
||||
private bool _isIdle; // snapshot: player essentially still this frame (exposed via IsIdle)
|
||||
private bool _movingOnGround; // snapshot: grounded & moving above the run threshold (exposed via IsMovingOnGround)
|
||||
private bool _isFalling; // snapshot: airborne & descending past the fall threshold (exposed via IsFalling)
|
||||
private bool _sprinting; // exposed via IsSprinting
|
||||
private bool _isIdle; // exposed via IsIdle
|
||||
private bool _movingOnGround; // exposed via IsMovingOnGround
|
||||
private bool _isFalling; // exposed via IsFalling
|
||||
private float _groundOffset; // signed vertical mesh raise from the ground mouse pose-adjust (+ up / - down); folded into SetMeshLean
|
||||
private Vector3 _spawnPosition; // world position this avatar spawned at; the rescue (kill-plane) teleport target
|
||||
private bool _spawnCaptured; // false until the first Update captures the spawn position (after OnNetworkSpawn's ring offset has landed)
|
||||
@@ -256,7 +256,8 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
private float _cameraYOffset; // last camera-target local-up offset written (cached so an unchanged value skips the transform write)
|
||||
private float _meshOffsetResidual; // leftover mesh lean still easing back to 0 after leaving the wall (no longer climbing)
|
||||
private Vector3 _meshOffsetExitNormal; // wall normal latched at exit; the residual eases along it (live _wallNormal may shift on stray contact)
|
||||
private readonly RaycastHit[] _wallProbe = new RaycastHit[8];
|
||||
private readonly RaycastHit[] _wallProbe = new RaycastHit[16];
|
||||
private bool _wallProbeSaturated; // log-once: a full buffer can hide the nearest valid wall/ground
|
||||
|
||||
// Mantle (top-out) state.
|
||||
private const float TopOutRegrabCooldown = 0.3f; // blocks re-grab right after any top-out so holding W tops out cleanly instead of detach/re-grab buzzing
|
||||
@@ -1038,6 +1039,7 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
|
||||
int count = Physics.RaycastNonAlloc(
|
||||
origin, dir, _wallProbe, maxDist, ~0, QueryTriggerInteraction.Ignore);
|
||||
WarnIfProbeSaturated(count);
|
||||
|
||||
float best = float.MaxValue;
|
||||
bool found = false;
|
||||
@@ -1060,6 +1062,13 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
return found;
|
||||
}
|
||||
|
||||
private void WarnIfProbeSaturated(int hitCount)
|
||||
{
|
||||
if (hitCount != _wallProbe.Length || _wallProbeSaturated) return;
|
||||
_wallProbeSaturated = true;
|
||||
Debug.LogWarning($"PlayerCharacterController: climb probe buffer saturated ({hitCount}); the nearest surface may be missed.", this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulls the character up and over the wall's top edge: phase 1 rises until the
|
||||
/// capsule clears the edge, phase 2 moves forward onto the surface, then exits.
|
||||
@@ -1113,6 +1122,7 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
|
||||
int count = Physics.RaycastNonAlloc(
|
||||
origin, -_wallNormal, _wallProbe, maxDist, ~0, QueryTriggerInteraction.Ignore);
|
||||
WarnIfProbeSaturated(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (IsPlayerCollider(_wallProbe[i].collider) || IsNoClimb(_wallProbe[i].collider))
|
||||
@@ -1135,6 +1145,7 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
|
||||
int count = Physics.RaycastNonAlloc(
|
||||
origin, Vector3.down, _wallProbe, maxDist, ~0, QueryTriggerInteraction.Ignore);
|
||||
WarnIfProbeSaturated(count);
|
||||
|
||||
float best = float.MaxValue;
|
||||
Vector3 normal = Vector3.up;
|
||||
|
||||
Reference in new issue
Block a user