Refactor: dedupe input reads, material-property guards, button hooks

Extract byte-identical duplicated code into shared helpers (behaviour-neutral):
- New InputUtil.cs: single source for mouse-delta/scroll/cursor-lock, modifier
  and mouse-button reads, previously copied verbatim across camera controllers,
  MeshPainter, FirstPersonMode and PlayerCharacterController.
- GetMatFloat/SetMatFloat replace the 12x material-instance + HasProperty guard
  pattern for the camo/height float properties.
- Route two inline button hooks through the existing Hook() helper.

Bespoke variants deliberately kept local (FreeCam SprintHeld = LeftShift only,
MeshPainter.TryGetMouse with out-params).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-07-02 09:20:40 +02:00
1 parent 626dcc1bdf
commit 882d30797e
11 files changed
+158 -222

No files matched your search

+2 -2
View File
@@ -152,8 +152,8 @@ public partial class MeshPainter
// A = smoothness. G = 128 (= 0.5) is the NEUTRAL height: no parallax/relief and AO =
// saturate(2*0.5) = 1 (no darkening), so the unpainted look is unchanged. Painting G
// below 0.5 carves a hole (and darkens), above 0.5 raises a hill (see PlayerCamoLit).
float metallic0 = _materialInstance.HasProperty(MetallicId) ? _materialInstance.GetFloat(MetallicId) : 0f;
float smoothness0 = _materialInstance.HasProperty(SmoothnessId) ? _materialInstance.GetFloat(SmoothnessId) : 0.5f;
float metallic0 = GetMatFloat(MetallicId, 0f);
float smoothness0 = GetMatFloat(SmoothnessId, 0.5f);
_seedCanonical[MAP_MSO] = FillCanonical(new Color32(
(byte)(Mathf.Clamp01(metallic0) * 255f), 128, 0, (byte)(Mathf.Clamp01(smoothness0) * 255f)));