using System;
namespace Jovian.EncounterSystem {
///
/// Cross-table reference to an . Stores the owning
/// asset and the target encounter's .
/// Rename-safe because the stored key is a GUID.
///
[Serializable]
public struct EncounterLink {
/// The table that owns the linked encounter.
public EncounterTable table;
/// The target encounter's stable GUID ().
public string internalId;
/// Look up the referenced encounter, or null if the table is missing or the id
/// no longer exists in it.
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;
}
}
}