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
+17
-18
@@ -155,11 +155,7 @@ public partial class PaintHud : MonoBehaviour
|
||||
{
|
||||
if (!newPainter || newPainter == painter || !_panel) return;
|
||||
|
||||
if (painter)
|
||||
{
|
||||
painter.Picked -= SyncFromPainter;
|
||||
painter.BrushSizeChanged -= SyncBrushSize;
|
||||
}
|
||||
UnhookPainterEvents();
|
||||
painter = newPainter;
|
||||
_camoSynced = false; // re-seed the camo sliders once this painter's material instance is ready
|
||||
|
||||
@@ -184,13 +180,13 @@ public partial class PaintHud : MonoBehaviour
|
||||
UpdateButtonStates(); // enable Save now that a painter is bound
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
private void OnDestroy() => UnhookPainterEvents();
|
||||
|
||||
private void UnhookPainterEvents()
|
||||
{
|
||||
if (painter)
|
||||
{
|
||||
painter.Picked -= SyncFromPainter;
|
||||
painter.BrushSizeChanged -= SyncBrushSize;
|
||||
}
|
||||
if (!painter) return;
|
||||
painter.Picked -= SyncFromPainter;
|
||||
painter.BrushSizeChanged -= SyncBrushSize;
|
||||
}
|
||||
|
||||
private void OnModeChanged(GameMode mode)
|
||||
@@ -383,8 +379,7 @@ public partial class PaintHud : MonoBehaviour
|
||||
|
||||
private static void SetSlider(Transform panel, string name, float value)
|
||||
{
|
||||
var cell = FindDeep(panel, name);
|
||||
var slider = cell ? cell.GetComponentInChildren<Slider>() : null;
|
||||
var slider = FindSlider(panel, name, out _);
|
||||
if (!slider) return;
|
||||
var curve = slider.GetComponent<SliderCurve>();
|
||||
if (curve) curve.SetOutput(value); // inverts the value onto the handle, then fires the slider listener
|
||||
@@ -470,8 +465,7 @@ public partial class PaintHud : MonoBehaviour
|
||||
{
|
||||
if (!tex) return null;
|
||||
if (_maskSprites.TryGetValue(tex, out var cached) && cached) return cached;
|
||||
var s = Sprite.Create(tex, new Rect(0f, 0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100f);
|
||||
s.hideFlags = HideFlags.HideAndDontSave;
|
||||
var s = ToSprite(tex);
|
||||
_maskSprites[tex] = s;
|
||||
return s;
|
||||
}
|
||||
@@ -525,11 +519,16 @@ public partial class PaintHud : MonoBehaviour
|
||||
toggle.onValueChanged.AddListener(v => group.alpha = v ? 1f : 0.5f);
|
||||
}
|
||||
|
||||
/// <summary>Finds a slider cell by name and the Slider inside it (null when either is missing).</summary>
|
||||
private static Slider FindSlider(Transform panel, string name, out Transform cell)
|
||||
{
|
||||
cell = FindDeep(panel, name);
|
||||
return cell ? cell.GetComponentInChildren<Slider>() : null;
|
||||
}
|
||||
|
||||
private static void WireSlider(Transform panel, string name, float value, Action<float> onChanged)
|
||||
{
|
||||
var cell = FindDeep(panel, name);
|
||||
if (!cell) return;
|
||||
var slider = cell.GetComponentInChildren<Slider>();
|
||||
var slider = FindSlider(panel, name, out Transform cell);
|
||||
if (!slider) return;
|
||||
var curve = slider.GetComponent<SliderCurve>(); // optional non-linear response on the same object
|
||||
var valueRt = cell.Find("Value");
|
||||
|
||||
Reference in new issue
Block a user