Skip to content

feat(phase2): architecture layer — state machine, combat, traits, death messages, editor setup - #3

Merged
Sen1F merged 27 commits into
mainfrom
feature/phase2-architecture
Jun 12, 2026
Merged

Sen1F merged 27 commits into
mainfrom
feature/phase2-architecture

Conversation

@Sen1F

@Sen1F Sen1F commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

Full Phase 2 architecture layer on top of the Phase 1 scaffold.

Core systems

  • SceneRouter — async typed scene navigation, owns AppState/GameState
  • AppStateMachine — PlayerState with validated transition table
  • GameLoop — pause/resume, debounced auto-save on app background, scoped bus clear on full scene transitions only (additive sub-zone unloads don't wipe trait subscriptions)
  • Bootstrap — StreamingAssets JSON config loading, re-subscribes TraitAccumulator after every scene load

Combat

  • CombatContext — live aggroed-enemy count via EnemyAI.IsAwareOfPlayer, damage-dealt tracking per enemy
  • CombatSystem — boss detection via EnemyArchetype.Boss, lazy PlayerCombat lookup
  • AttackResolver — uses GameConfig constants, no duplicated magic numbers
  • EnemyAI — player cached in Start(), EnemyCombat cached in Awake(), IsAwareOfPlayer public property

Death system

  • 5 classified death types: Ambush, PatternFail, Sacrifice, Reckless, Overwhelmed
  • DeathSacrificeEvent — triggers when player attacked at low HP and (group ≥ 2 aggroed enemies OR dealt < 25% of any enemy's max HP)
  • DeathMessageProvider — dramatic two-line contextual messages per death type with group/minor-damage variant split for Sacrifice
  • All thresholds in GameConfig — zero hardcoded numbers

Fixes across 4 audit passes

  • ISaveManager.IsDirty missing from interface
  • BehaviorEventBus double-emit on HitTakenNoDodgeEvent
  • DateTime fields not serializable by JsonUtility → long Unix timestamps
  • WorldManager static singleton → ServiceLocator
  • EnemyAI.FindPlayer() in Update loop → cached in Start
  • Touch input killed by Keyboard.current == null guard on device
  • AwakeningSequencer used SceneManager directly instead of SceneRouter
  • Journal evolution keys mismatched EvolutionChecker IDs
  • EnemyCombat passed enemy element as player defender element
  • _consecutiveDeathsVsSameEnemy not keyed by enemy ID
  • 13 further bugs across audit passes 2–4

Editor tooling

  • FenrirSetup.cs — single Fenrir → Setup Project replaces 7 separate scripts. Registers tags, configures all 3 scenes, wires all references, spawns Ash Wolf, bakes NavMesh. Idempotent.
  • FenrirEditorUtils.cs — EnsureTag() writes directly to TagManager.asset via SerializedObject

Test plan

  • Fenrir → Setup Project in Unity Editor — 0 errors, all scenes saved
  • Press Play in EmberForest — player moves, Cinemachine follows
  • Spawn Wolf aggros when player enters detection range
  • Dodge in combat → Console shows [Traits] DodgeUsedEvent Patience: +2.0
  • Die to wolf → death message displays on screen
  • Die 3× to same enemy → DeathPatternFailEvent in Console

Sen1F added 27 commits June 2, 2026 17:07
…me, double-emit, pattern-fail, optimistic-emit, lazy lookup, boss detection, state divergence, GameConfig constants, Invoke cancel
…ameConfig constants, ServiceLocator registration
…journal keys, trait delta logging, Bootstrap setup script
…sSortMode obsolete, _shrineId wired to WorldManager
…e, FindObjectsSortMode, Finalize name, ShrineId wired
…field names (_maxHp, _attackDamage), extract shared EnsureTag utility
…ported in CI

Unity 6 Personal dropped .ulf manual activation and Hub OAuth cannot
be scripted. Unity build + EditMode tests run locally via Test Runner.
Lint-docs gate remains. Job skeleton preserved in comments for future
Pro/serial upgrade path.
…avMeshAgent push

Enemy was spawning at (5,5) — 7.07u from player, inside 8f detection
radius. Immediate aggro on frame 1 caused the enemy to run into the
player's CharacterController. Moved to (0,0,14) so the player can move
freely before engaging. Added LowQuality obstacle avoidance to prevent
agent from physically pushing the CharacterController.
…ics layers

SpawnAshWolf early-return guard was keeping the old (5,5) position across
re-runs. Now destroys and recreates every run so position stays in sync.

Added EnsureLayer + SetLayerCollision to FenrirEditorUtils. Player and
Enemy are on separate physics layers with collision ignored — prevents
the NavMeshAgent CapsuleCollider from pushing the CharacterController.
Physics.IgnoreLayerCollision called before TagManager refreshes returns
layer index -1, throwing ArgumentException. Removed layer machinery.

Instead mark the enemy CapsuleCollider as isTrigger=true so the
NavMeshAgent never physically pushes the player CharacterController.
Hit detection works via trigger overlap, not solid collision.
Library wipe disconnects Graphics Settings from Mobile_RPAsset, causing
999+ shader-not-found errors and a black scene. EnsureURPAsset() now
reassigns it as step 0 of Setup Project so it self-heals without manual
intervention in Project Settings → Graphics.
@Sen1F
Sen1F merged commit 732cfaa into main Jun 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant