Trim comments and use implicit null checks for Unity objects

Reduce comments to non-obvious "why" notes and convert UnityEngine.Object
null checks to implicit bool (if (obj) / if (!obj)). Input System devices
(Mouse.current, Keyboard.current) and plain arrays keep explicit != null.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-06-22 17:26:41 +02:00
1 parent 3da613e1a1
commit f758c96dc5
8 files changed
+220 -427

No files matched your search

+10 -24
View File
@@ -5,33 +5,21 @@ using UnityEngine.InputSystem;
#endif
/// <summary>
/// Central state manager that switches the game between high-level modes.
/// Currently two modes exist:
/// 0. Player Control - WASD movement, camera orbits freely with the mouse.
/// 1. Paint - player stands still, left mouse paints the mesh, the
/// camera orbits only while the right mouse button is held.
///
/// Pressing the switch key (Tab) cycles to the next registered mode, so adding
/// more modes later automatically extends the cycle.
///
/// The manager owns references to the systems a mode may toggle (player
/// controller, orbit camera input, mesh painter) and exposes them to the modes.
/// Modes are plain C# classes derived from <see cref="GameMode"/>; register
/// additional ones in <see cref="BuildModes"/>.
///
/// Attach this to a single, persistent GameObject in the scene.
/// Switches the game between high-level modes (Player Control, Paint). The switch
/// key (Tab) cycles to the next registered mode. Register additional modes in
/// <see cref="BuildModes"/>. Attach to a single, persistent scene GameObject.
/// </summary>
[DisallowMultipleComponent]
public class GameModeManager : MonoBehaviour
{
[Header("Controlled Systems")]
[Tooltip("Player movement controller. Empty = found automatically in the scene.")]
[Tooltip("Player movement controller. Empty = found automatically.")]
public PlayerCharacterController player;
[Tooltip("Third-person orbit camera input. Empty = found automatically in the scene.")]
[Tooltip("Third-person orbit camera input. Empty = found automatically.")]
public ThirdPersonOrbitInput cameraInput;
[Tooltip("Mesh painter. Empty = found automatically in the scene.")]
[Tooltip("Mesh painter. Empty = found automatically.")]
public MeshPainter painter;
[Header("Switching")]
@@ -42,10 +30,9 @@ public class GameModeManager : MonoBehaviour
public KeyCode switchKey = KeyCode.Tab;
#endif
[Tooltip("Index of the mode that is active at startup (0 = Player Control).")]
[Tooltip("Mode active at startup (0 = Player Control).")]
public int startModeIndex = 0;
// --- accessors used by the modes ---
public PlayerCharacterController Player => player;
public ThirdPersonOrbitInput CameraInput => cameraInput;
public MeshPainter Painter => painter;
@@ -59,10 +46,9 @@ public class GameModeManager : MonoBehaviour
private void Awake()
{
// Auto-resolve references so the manager works with minimal wiring.
if (player == null) player = FindFirstObjectByType<PlayerCharacterController>();
if (cameraInput == null) cameraInput = FindFirstObjectByType<ThirdPersonOrbitInput>();
if (painter == null) painter = FindFirstObjectByType<MeshPainter>();
if (!player) player = FindFirstObjectByType<PlayerCharacterController>();
if (!cameraInput) cameraInput = FindFirstObjectByType<ThirdPersonOrbitInput>();
if (!painter) painter = FindFirstObjectByType<MeshPainter>();
BuildModes();
}