Refactor: extract shared helpers across scripts, trim remaining doc redundancy
Deduplication pass (44 extractions): - New SmoothedLook: shared smoothed yaw/pitch look tick + view seeding (FirstPersonController, FreeCamController) - New CharacterTeleport: disable-CC-around-teleport idiom (rescue, owner position apply, free-cam sync) - New GeometryUtil: RescaleToUnitScale + TransformBounds (concealment meter/volume, skinned collider baker) - Paint family: canonical map read/write shared between Net and Persistence, snapshot decode, backend stroke dispatch, RebuildBackend, ResolveSeed, chunked RPC send/gate/copy, CamoKnobs/HeightKnobs aggregates, SanitizeFileKey, NewMaskTexture, AdoptAlbedo, FindSlider - Player/modes: GameMode SetPlayerControl/SetPainting/SetOrbitInputEnabled, InputUtil.GameplayKeyPressed, NearestClimbHit, ComputeXRay delegates to ComputeResolutionFreeze, FingerIK TryInPlaneAngle - Match/misc: UnhookSessionCallbacks, SendEmptyNamedMessage, SwapScenes, RunSessionOpAsync, CovarianceEigen, CollectClusterPoints, MatchHud GUIStyle cache, HsvColorPicker rehook, VoxelCenter Documentation pass: remove 6 triplicated doc blocks and 2 restating inline comments left after the previous reduction. Behavior-neutral; hot-path rasterizer loops intentionally untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
066e308cde
commit
2243cc823e
40 files changed
+681
-724
No files matched your search
@@ -486,17 +486,12 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kill-plane rescue: snap the avatar back to its captured spawn point and clear all momentum. The
|
||||
/// CharacterController overrides direct transform writes, so it is toggled around the move (same
|
||||
/// pattern as <see cref="NetworkPlayerSetup.PlaceOnSpawnRing"/>). Owner-only; the authoritative
|
||||
/// NetworkTransform replicates the new position to remotes.
|
||||
/// Kill-plane rescue: snap the avatar back to its captured spawn point and clear all momentum.
|
||||
/// Owner-only; the authoritative NetworkTransform replicates the new position to remotes.
|
||||
/// </summary>
|
||||
private void RescueToSpawn()
|
||||
{
|
||||
bool reenable = _controller && _controller.enabled;
|
||||
if (_controller) _controller.enabled = false;
|
||||
transform.position = _spawnPosition;
|
||||
if (_controller) _controller.enabled = reenable;
|
||||
CharacterTeleport.Move(_controller, transform, _spawnPosition);
|
||||
|
||||
_verticalVelocity = 0f;
|
||||
_horizontalVelocity = Vector3.zero;
|
||||
@@ -800,12 +795,12 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
}
|
||||
else if (_climbLeftGround && vEff > 0f)
|
||||
{
|
||||
TopOutDetach(); // topped out upward onto walkable ground: hop over the lip (holding the up key carries on)
|
||||
TopOutDetach();
|
||||
return;
|
||||
}
|
||||
else if (_climbLeftGround || vEff < 0f)
|
||||
{
|
||||
ExitWallClimb(); // descended to the floor, or pulling down/away at the base: let go, no hop
|
||||
ExitWallClimb();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -989,34 +984,16 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
/// </summary>
|
||||
private bool ProbeWall(out Vector3 normal, out float gap)
|
||||
{
|
||||
normal = _wallNormal;
|
||||
gap = 0f;
|
||||
|
||||
Vector3 origin = WorldCapsuleCenter;
|
||||
Vector3 dir = -_wallNormal;
|
||||
float extent = CapsuleExtent(dir);
|
||||
float maxDist = extent + wallMaxOffset + ProbeReachSlack * CapsuleScale;
|
||||
|
||||
int count = Physics.RaycastNonAlloc(
|
||||
origin, dir, _wallProbe, maxDist, ~0, QueryTriggerInteraction.Ignore);
|
||||
if (NearestClimbHit(origin, dir, maxDist, extent, ceilingOnly: false, out normal, out gap))
|
||||
return true;
|
||||
|
||||
float best = float.MaxValue;
|
||||
bool found = false;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (IsPlayerCollider(_wallProbe[i].collider) || IsNoClimb(_wallProbe[i].collider)) // skip self, other player avatars, and no-climb surfaces
|
||||
continue;
|
||||
if (_wallProbe[i].distance < best)
|
||||
{
|
||||
best = _wallProbe[i].distance;
|
||||
normal = _wallProbe[i].normal;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
gap = Mathf.Max(0f, best - extent);
|
||||
return found;
|
||||
normal = _wallNormal;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1035,15 +1012,32 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
/// </summary>
|
||||
private bool ProbeCeiling(out Vector3 normal, out float gap)
|
||||
{
|
||||
normal = Vector3.down;
|
||||
gap = 0f;
|
||||
|
||||
Vector3 origin = WorldCapsuleCenter;
|
||||
float half = WorldHalfHeight;
|
||||
float maxDist = half + wallMaxOffset + ProbeReachSlack * CapsuleScale;
|
||||
|
||||
if (NearestClimbHit(origin, Vector3.up, maxDist, half, ceilingOnly: true, out normal, out gap))
|
||||
return true;
|
||||
|
||||
normal = Vector3.down;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raycasts along <paramref name="dir"/> and returns the nearest hit that a climb probe accepts
|
||||
/// (player avatars and no-climb surfaces never count; <paramref name="ceilingOnly"/> additionally
|
||||
/// rejects non-ceiling normals). <paramref name="gap"/> is the clearance beyond the capsule's
|
||||
/// support <paramref name="extent"/> along the probe direction. False = no valid hit
|
||||
/// (<paramref name="normal"/>/<paramref name="gap"/> are then zero; callers supply their fallback).
|
||||
/// </summary>
|
||||
private bool NearestClimbHit(Vector3 origin, Vector3 dir, float maxDist, float extent,
|
||||
bool ceilingOnly, out Vector3 normal, out float gap)
|
||||
{
|
||||
normal = Vector3.zero;
|
||||
gap = 0f;
|
||||
|
||||
int count = Physics.RaycastNonAlloc(
|
||||
origin, Vector3.up, _wallProbe, maxDist, ~0, QueryTriggerInteraction.Ignore);
|
||||
origin, dir, _wallProbe, maxDist, ~0, QueryTriggerInteraction.Ignore);
|
||||
|
||||
float best = float.MaxValue;
|
||||
bool found = false;
|
||||
@@ -1051,7 +1045,7 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
{
|
||||
if (IsPlayerCollider(_wallProbe[i].collider) || IsNoClimb(_wallProbe[i].collider))
|
||||
continue;
|
||||
if (_wallProbe[i].normal.y >= CeilingNormalThreshold) // not a ceiling
|
||||
if (ceilingOnly && _wallProbe[i].normal.y >= CeilingNormalThreshold) // not a ceiling
|
||||
continue;
|
||||
if (_wallProbe[i].distance < best)
|
||||
{
|
||||
@@ -1062,7 +1056,7 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
}
|
||||
|
||||
if (found)
|
||||
gap = Mathf.Max(0f, best - half);
|
||||
gap = Mathf.Max(0f, best - extent);
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user