using System;

namespace Jovian.EncounterSystem {
    /// <summary>Cross-table reference. Rename-safe — the stored key is a GUID.</summary>
    [Serializable]
    public struct EncounterLink {
        public EncounterTable table;
        public string internalId;

        /// <summary>O(1) lookup via <see cref="EncounterTable.Resolve"/>. Returns <c>null</c> if the
        /// table is missing or the id can't be found.</summary>
        public IEncounter Resolve() {
            if(table == null || string.IsNullOrEmpty(internalId)) {
                return null;
            }
            return table.Resolve(internalId);
        }
    }
}
