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

33
Runtime/EncounterLink.cs Normal file
View File

@@ -0,0 +1,33 @@
using System;
namespace Jovian.EncounterSystem {
/// <summary>
/// Cross-table reference to an <see cref="IEncounter"/>. Stores the owning
/// <see cref="EncounterTable"/> asset and the target encounter's <see cref="EncounterDefinition.internalId"/>.
/// Rename-safe because the stored key is a GUID.
/// </summary>
[Serializable]
public struct EncounterLink {
/// <summary>The table that owns the linked encounter.</summary>
public EncounterTable table;
/// <summary>The target encounter's stable GUID (<see cref="EncounterDefinition.internalId"/>).</summary>
public string internalId;
/// <summary>Look up the referenced encounter, or <c>null</c> if the table is missing or the id
/// no longer exists in it.</summary>
public IEncounter Resolve() {
if(table == null || table.encounters == null || string.IsNullOrEmpty(internalId)) {
return null;
}
foreach(var encounter in table.encounters) {
if(encounter?.EncounterDefinition?.internalId == internalId) {
return encounter;
}
}
return null;
}
}
}