Added the system from trail

This commit is contained in:
Sebastian Bularca
2026-04-19 12:25:49 +02:00
parent 47ee77f272
commit 89e36b4df9
57 changed files with 2160 additions and 15 deletions

36
Runtime/DialogLineRef.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
using UnityEngine;
namespace Jovian.EncounterSystem {
/// <summary>
/// Reference to a dialog line. Looks up <see cref="id"/> inside <see cref="library"/> when both
/// are set; otherwise falls back to <see cref="inlineText"/>. This lets designers prototype
/// one-off lines inline and promote common ones to the shared library later without changing
/// the field's type.
/// </summary>
[Serializable]
public struct DialogLineRef {
/// <summary>Shared library to resolve <see cref="id"/> against. Optional.</summary>
public DialogLineLibrary library;
/// <summary>Line id inside <see cref="library"/>. Ignored if <see cref="library"/> is null.</summary>
public string id;
/// <summary>Fallback text used when the library reference is missing or fails to resolve.
/// Authored directly in the inspector for one-off lines.</summary>
[TextArea(2, 6)]
public string inlineText;
/// <summary>Resolve to final text. Returns <see cref="inlineText"/> if no library reference
/// resolves, or <c>null</c> if both paths yield nothing.</summary>
public string Resolve() {
if(library != null && !string.IsNullOrEmpty(id)) {
var text = library.Resolve(id);
if(!string.IsNullOrEmpty(text)) {
return text;
}
}
return inlineText;
}
}
}