29e90a5008
Teaches the deep, interlocking loop — especially the inverted win condition (you win by CLEARING EXPEDITIONS, not by surviving base sieges; DR-042/DR-043). - OnboardingSystem: client-only observe-only PresentationSystemGroup overlay (own UIDocument @ sortingOrder 60), soft-gated 10-beat coach-mark sequence with a world-space ▶ pointer; never mutates sim / never destroys a ghost. - OnboardingStepMath: pure, unit-tested step machine (snapshot + IsSatisfied + scheme-aware prompts + pointer kinds + persisted-mask helpers). - HowToPlayPanel: tabbed reference card (Controls / The Loop / Build / Threats / Win-Lose), reachable from the main menu and the pause overlay. - Per-client client-local state in GameSettings (TutorialHints + OnboardingMask bitmask, additive) — a Join client keeps its own; a host save-wipe never re-teaches. Settings toggle + menu "Replay Tutorial". - Dev "Force Each Launch" toggle (GameSettings.ForceOnboardingEachLaunch): SettingsService.Boot wipes the mask + forces hints on in-memory every launch so the tutorial always replays fresh. - HudSystem suppresses its own location hint while onboarding is active (single prompt voice), via OnboardingState + [UpdateAfter(OnboardingSystem)]. Validated green: 20/20 EditMode; Play smoke confirmed overlay render, clean U+25B6 pointer glyph, no system sort-cycle, and the force-wipe end-to-end. Docs: DR-043 + session log; reusable lesson archived in the build-gotchas note. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
85 lines
3.8 KiB
C#
85 lines
3.8 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Client
|
|
{
|
|
/// <summary>
|
|
/// Serializable client settings model (Graphics + Audio) persisted to JSON by <see cref="SettingsService"/>.
|
|
/// Flat fields only (an enum stored as an int) so <c>JsonUtility</c> round-trips it without Newtonsoft.
|
|
/// <see cref="Version"/> gates forward-compatible migration. Purely client-local — never replicated (the
|
|
/// server has no opinion on a player's resolution or volume).
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct GameSettings
|
|
{
|
|
public const int CurrentVersion = 2;
|
|
|
|
public int Version;
|
|
|
|
// ---- Graphics ----
|
|
public int ResWidth;
|
|
public int ResHeight;
|
|
public int RefreshHz; // 0 = platform default
|
|
public int FullScreenMode; // (int)UnityEngine.FullScreenMode (0 Exclusive,1 FullScreenWindow,2 Maximized,3 Windowed)
|
|
public int QualityLevel;
|
|
public int VSync; // QualitySettings.vSyncCount: 0/1/2
|
|
public int TargetFps; // Application.targetFrameRate: -1 = uncapped
|
|
|
|
// ---- Audio (0..1) ----
|
|
public float Master;
|
|
public float Music;
|
|
public float Sfx;
|
|
|
|
// ---- Onboarding (client-local first-run state; NEVER replicated — a Join client keeps its own,
|
|
// unlike the host-only SaveData) ----
|
|
public int TutorialHints; // 0 = first-run coach-marks off, 1 = on
|
|
public int OnboardingMask; // bitmask of completed coach-mark steps (0 = nothing seen; bit i = step i done)
|
|
public int ForceOnboardingEachLaunch; // DEV: 1 = wipe OnboardingMask + force hints on at every launch so the
|
|
// first-run coach-marks always replay fresh (additive; 0-default off)
|
|
|
|
/// <summary>Sensible defaults derived from the current display + active quality level.</summary>
|
|
public static GameSettings Defaults()
|
|
{
|
|
var r = Screen.currentResolution;
|
|
return new GameSettings
|
|
{
|
|
Version = CurrentVersion,
|
|
ResWidth = r.width > 0 ? r.width : 1920,
|
|
ResHeight = r.height > 0 ? r.height : 1080,
|
|
RefreshHz = 0,
|
|
FullScreenMode = (int)UnityEngine.FullScreenMode.FullScreenWindow,
|
|
QualityLevel = QualitySettings.GetQualityLevel(),
|
|
VSync = 1,
|
|
TargetFps = -1,
|
|
Master = 1f,
|
|
Music = 1f,
|
|
Sfx = 1f,
|
|
TutorialHints = 1,
|
|
OnboardingMask = 0,
|
|
ForceOnboardingEachLaunch = 0,
|
|
};
|
|
}
|
|
|
|
/// <summary>Clamp every field into a safe range (defensive against hand-edited / corrupt JSON).</summary>
|
|
public GameSettings Clamped()
|
|
{
|
|
var s = this;
|
|
s.ResWidth = Mathf.Clamp(s.ResWidth <= 0 ? 1920 : s.ResWidth, 640, 7680);
|
|
s.ResHeight = Mathf.Clamp(s.ResHeight <= 0 ? 1080 : s.ResHeight, 480, 4320);
|
|
s.RefreshHz = Mathf.Max(0, s.RefreshHz);
|
|
s.FullScreenMode = Mathf.Clamp(s.FullScreenMode, 0, 3);
|
|
int qn = (QualitySettings.names != null && QualitySettings.names.Length > 0) ? QualitySettings.names.Length : 1;
|
|
s.QualityLevel = Mathf.Clamp(s.QualityLevel, 0, qn - 1);
|
|
s.VSync = Mathf.Clamp(s.VSync, 0, 2);
|
|
s.TargetFps = s.TargetFps <= 0 ? -1 : Mathf.Clamp(s.TargetFps, 20, 1000);
|
|
s.Master = Mathf.Clamp01(s.Master);
|
|
s.Music = Mathf.Clamp01(s.Music);
|
|
s.Sfx = Mathf.Clamp01(s.Sfx);
|
|
s.TutorialHints = s.TutorialHints != 0 ? 1 : 0;
|
|
s.ForceOnboardingEachLaunch = s.ForceOnboardingEachLaunch != 0 ? 1 : 0;
|
|
// OnboardingMask is an opaque bitmask — deliberately NOT clamped.
|
|
return s;
|
|
}
|
|
}
|
|
}
|