validation and dialogue system

This commit is contained in:
Sebastian Bularca
2026-04-19 12:27:13 +02:00
parent 89e36b4df9
commit 8ce041e2d8
3 changed files with 188 additions and 3 deletions

View File

@@ -11,7 +11,9 @@ Packages/com.jovian.encounter-system/
│ ├── IEncounterKind.cs ← marker interface + Combat/Quest/Social/Puzzle/...
│ ├── EncounterTable.cs ← ScriptableObject: list of encounters + roll helpers
│ ├── EncountersCollection.cs ← ScriptableObject: group of tables
│ ├── EncounterDialogOptionSet.cs ← ScriptableObject: shared option list
│ ├── EncounterDialogOptionSet.cs ← ScriptableObject: shared option list (auto-renames to id)
│ ├── DialogLineLibrary.cs ← ScriptableObject: id → text registry for reusable lines
│ ├── DialogLineRef.cs ← struct: library+id reference with inline fallback
│ ├── EncounterLink.cs ← cross-table reference (table + internalId)
│ ├── EncounterReference.cs ← MonoBehaviour scaffold wiring common UI fields
│ ├── EncounterRegistry.cs ← id → encounter lookup cache
@@ -26,6 +28,8 @@ Packages/com.jovian.encounter-system/
└── Editor/
├── SubclassSelectorDrawer.cs ← dropdown + inline children for [SerializeReference] fields
├── EncounterLinkDrawer.cs ← two-row table + encounter picker
├── DialogLineRefDrawer.cs ← library+id picker with inline fallback and live preview
├── EncounterDrawer.cs ← list element label shows encounter id
├── EncounterValidator.cs ← project-wide scan + "Validate All" menu + browser badges
└── EncounterBrowserWindow.cs ← Jovian → Encounters → Encounter Browser
```
@@ -90,6 +94,21 @@ resolver.Register<GiveRewardEvent>((evt, ctx) => rewardApplier.Apply(evt.reward,
`rewardApplier` lives in game code — the package ships only the data types.
### Reusable dialog lines via `DialogLineLibrary` + `DialogLineRef`
A single `DialogLineLibrary` asset (or a handful split by topic) holds `{ id → text }` entries. Every `EncounterDialogOption.text` is a `DialogLineRef` struct that resolves in this order:
1. If the library reference + id resolves, use that.
2. Otherwise fall back to `inlineText`.
The drawer shows all three inputs plus a live preview of the final text — WYSIWYG survives. Designers prototype inline and promote common lines to the library later without changing the field's type.
```csharp
resolver.Register<SomeEvent>((evt, ctx) => {
var text = option.text.Resolve(); // library lookup, inline fallback, null if both empty
});
```
### Cross-table references via `EncounterLink`
`EncounterLink` stores a table asset + stable `internalId` GUID. Rename-safe (the GUID doesn't change) and diffable. The custom drawer renders two dropdowns: first pick a table, then pick an encounter inside it.
@@ -141,7 +160,8 @@ encounterRegistry.GetEncounters().TryGetValue(id, out var encounter);
|-----------|-------------|
| Assets → Create → Jovian → Encounter System → Encounter Table | New table asset |
| Assets → Create → Jovian → Encounter System → Encounters Collection | New collection asset |
| Assets → Create → Jovian → Encounter System → Dialog Option Set | New dialog option set |
| Assets → Create → Jovian → Encounter System → Dialog Option Set | New dialog option set (auto-renames to id) |
| Assets → Create → Jovian → Encounter System → Dialog Line Library | New shared dialog line library |
| Assets → Create → Jovian → Encounter System → Encounter Registry | New registry asset |
| Jovian → Encounters → Encounter Browser | Searchable designer browser |
| Jovian → Encounters → Validate All | Scan all tables/rewards for issues, print click-through report |