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
@@ -149,14 +149,30 @@ public class OnlineSessionManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private async void HostAsync()
|
||||
// Shared busy/sign-in/error skeleton around one session operation; the body carries the
|
||||
// op-specific statuses and state.
|
||||
private async System.Threading.Tasks.Task RunSessionOpAsync(string failLabel, Func<System.Threading.Tasks.Task> body)
|
||||
{
|
||||
if (_busy || IsConnected) return;
|
||||
SetBusy(true);
|
||||
try
|
||||
{
|
||||
SetStatus("Signing in…");
|
||||
await EnsureSignedInAsync();
|
||||
await body();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SetStatus($"{failLabel} failed: {e.Message}");
|
||||
Debug.LogException(e);
|
||||
}
|
||||
finally { SetBusy(false); }
|
||||
}
|
||||
|
||||
private async void HostAsync()
|
||||
{
|
||||
if (_busy || IsConnected) return;
|
||||
await RunSessionOpAsync("Host", async () =>
|
||||
{
|
||||
SetStatus("Creating session…");
|
||||
var options = new SessionOptions
|
||||
{
|
||||
@@ -165,55 +181,31 @@ public class OnlineSessionManager : MonoBehaviour
|
||||
}.WithRelayNetwork();
|
||||
_session = await MultiplayerService.Instance.CreateSessionAsync(options);
|
||||
SetStatus($"Hosting \"{_session.Name}\" (code {_session.Code})");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SetStatus($"Host failed: {e.Message}");
|
||||
Debug.LogException(e);
|
||||
}
|
||||
finally { SetBusy(false); }
|
||||
});
|
||||
}
|
||||
|
||||
private async void RefreshAsync()
|
||||
{
|
||||
if (_busy) return;
|
||||
SetBusy(true);
|
||||
try
|
||||
await RunSessionOpAsync("Refresh", async () =>
|
||||
{
|
||||
SetStatus("Signing in…");
|
||||
await EnsureSignedInAsync();
|
||||
SetStatus("Querying sessions…");
|
||||
var results = await MultiplayerService.Instance.QuerySessionsAsync(new QuerySessionsOptions());
|
||||
_sessions = new List<ISessionInfo>(results.Sessions);
|
||||
SessionsChanged?.Invoke();
|
||||
SetStatus($"{_sessions.Count} session(s) found");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SetStatus($"Refresh failed: {e.Message}");
|
||||
Debug.LogException(e);
|
||||
}
|
||||
finally { SetBusy(false); }
|
||||
});
|
||||
}
|
||||
|
||||
private async void JoinAsync(string sessionId)
|
||||
{
|
||||
if (_busy || IsConnected || string.IsNullOrEmpty(sessionId)) return;
|
||||
SetBusy(true);
|
||||
try
|
||||
await RunSessionOpAsync("Join", async () =>
|
||||
{
|
||||
SetStatus("Signing in…");
|
||||
await EnsureSignedInAsync();
|
||||
SetStatus("Joining session…");
|
||||
_session = await MultiplayerService.Instance.JoinSessionByIdAsync(sessionId);
|
||||
SetStatus($"Joined \"{_session.Name}\"");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SetStatus($"Join failed: {e.Message}");
|
||||
Debug.LogException(e);
|
||||
}
|
||||
finally { SetBusy(false); }
|
||||
});
|
||||
}
|
||||
|
||||
private async void DisconnectAsync()
|
||||
|
||||
Reference in new issue
Block a user