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
@@ -145,14 +145,25 @@ public class GameModeManager : MonoBehaviour
|
||||
_paused = false;
|
||||
_resumeIndex = -1;
|
||||
|
||||
ClearPlayerBindings();
|
||||
TearDownActiveMode();
|
||||
BuildSpectatorModes();
|
||||
SwitchTo(0);
|
||||
}
|
||||
|
||||
/// <summary>Drops the player/painter bindings and notifies painter-following UI.</summary>
|
||||
private void ClearPlayerBindings()
|
||||
{
|
||||
player = null;
|
||||
painter = null;
|
||||
PainterChanged?.Invoke(null);
|
||||
}
|
||||
|
||||
/// <summary>Exits the active mode and marks no mode active.</summary>
|
||||
private void TearDownActiveMode()
|
||||
{
|
||||
ActiveMode?.Exit();
|
||||
_activeIndex = -1;
|
||||
BuildSpectatorModes();
|
||||
SwitchTo(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -197,8 +208,7 @@ public class GameModeManager : MonoBehaviour
|
||||
firstPerson.SetPlayer(localPlayer);
|
||||
|
||||
// Tear down the pre-spawn (player-less) mode and rebuild scoped to this avatar's role.
|
||||
ActiveMode?.Exit();
|
||||
_activeIndex = -1;
|
||||
TearDownActiveMode();
|
||||
|
||||
// Lobby avatar -> full set; match variant -> its role's modes. Scope is baked per prefab
|
||||
// variant, so it follows the spawned avatar with no replicated-phase timing race.
|
||||
@@ -224,12 +234,9 @@ public class GameModeManager : MonoBehaviour
|
||||
_paused = false;
|
||||
_resumeIndex = -1;
|
||||
|
||||
ActiveMode?.Exit();
|
||||
_activeIndex = -1;
|
||||
TearDownActiveMode();
|
||||
_modes.Clear();
|
||||
player = null;
|
||||
painter = null;
|
||||
PainterChanged?.Invoke(null);
|
||||
ClearPlayerBindings();
|
||||
|
||||
// The cycle is empty (no SwitchTo runs), so notify mode-following UI explicitly - otherwise the
|
||||
// paint HUD (hides only via ModeChanged) would stay open after a shutdown during PaintMode.
|
||||
@@ -308,7 +315,7 @@ public class GameModeManager : MonoBehaviour
|
||||
else if (painter) painter.PaintingEnabled = false; // degenerate paint-only set: at least stop painting
|
||||
}
|
||||
|
||||
if (WasSwitchPressed())
|
||||
if (InputUtil.GameplayKeyPressed(switchKey))
|
||||
{
|
||||
int next = (_activeIndex + 1) % _modes.Count;
|
||||
if (suppressPaint && _modes[next] is PaintMode)
|
||||
@@ -355,14 +362,4 @@ public class GameModeManager : MonoBehaviour
|
||||
Debug.Log($"[GameModeManager] Mode -> {ActiveMode.DisplayName}", this);
|
||||
ModeChanged?.Invoke(ActiveMode);
|
||||
}
|
||||
|
||||
private bool WasSwitchPressed()
|
||||
{
|
||||
if (TypingGuard.IsTyping) return false;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
return Keyboard.current != null && Keyboard.current[switchKey].wasPressedThisFrame;
|
||||
#else
|
||||
return Input.GetKeyDown(switchKey);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user