93 lines
4.0 KiB
C#
93 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Jovian.EncounterSystem {
|
|
/// <summary>
|
|
/// Runtime contract for any encounter authored in the system.
|
|
/// An encounter aggregates designer-facing metadata, visuals, dialog, and a polymorphic
|
|
/// <see cref="IEncounterKind"/> payload that expresses its type-specific data.
|
|
/// </summary>
|
|
public interface IEncounter {
|
|
/// <summary>Stable identity, display name, and designer description.</summary>
|
|
EncounterDefinition EncounterDefinition { get; set; }
|
|
|
|
/// <summary>Numeric configuration shared by every encounter kind.</summary>
|
|
EncounterProperties EncounterProperties { get; set; }
|
|
|
|
/// <summary>Visual assets displayed when the encounter is presented.</summary>
|
|
EncounterVisuals EncounterVisuals { get; set; }
|
|
|
|
/// <summary>Dialog options shown to the player, or <c>null</c> if the encounter has no dialog.</summary>
|
|
EncounterDialogOptionSet EncounterDialogOptionSet { get; set; }
|
|
|
|
/// <summary>Type-specific payload (combat, quest, social, ...). Authored via the SubclassSelector drawer.</summary>
|
|
IEncounterKind Kind { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Default concrete encounter. Holds the shared fields and a polymorphic <see cref="IEncounterKind"/>.
|
|
/// Prefer adding new behaviour by introducing a new <see cref="IEncounterKind"/> rather than subclassing this type.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class Encounter : IEncounter {
|
|
[field: SerializeField] public EncounterDefinition EncounterDefinition { get; set; }
|
|
[field: SerializeField] public EncounterProperties EncounterProperties { get; set; }
|
|
[field: SerializeField] public EncounterVisuals EncounterVisuals { get; set; }
|
|
[field: SerializeField] public EncounterDialogOptionSet EncounterDialogOptionSet { get; set; }
|
|
|
|
[field: SerializeReference, SubclassSelector]
|
|
public IEncounterKind Kind { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Designer-facing identity for an encounter. <see cref="internalId"/> is the stable GUID used for
|
|
/// cross-references (<see cref="EncounterLink"/>, quest progress, save data); <see cref="id"/> is a
|
|
/// human-readable slug; <see cref="name"/> and <see cref="description"/> are display strings.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class EncounterDefinition {
|
|
/// <summary>Stable GUID, assigned once at creation. Never edit manually.</summary>
|
|
[HideInInspector]
|
|
public string internalId = Guid.NewGuid().ToString();
|
|
|
|
/// <summary>Designer-authored short slug (e.g. "goblin_ambush").</summary>
|
|
public string id;
|
|
|
|
/// <summary>Display name shown to the player.</summary>
|
|
public string name;
|
|
|
|
/// <summary>Flavour text shown when the encounter opens.</summary>
|
|
public string description;
|
|
}
|
|
|
|
/// <summary>
|
|
/// A single choice presented to the player inside an <see cref="EncounterDialogOptionSet"/>.
|
|
/// Events fire in order when the option is picked and are dispatched through <see cref="EncounterResolver"/>.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class EncounterDialogOption {
|
|
/// <summary>Option text shown in the UI. Resolved through a shared
|
|
/// <see cref="DialogLineLibrary"/> or falls back to inline text.</summary>
|
|
public DialogLineRef text;
|
|
|
|
/// <summary>Ordered events executed by the resolver when this option is chosen.</summary>
|
|
[SerializeReference, SubclassSelector]
|
|
public List<IEncounterEvent> events;
|
|
}
|
|
|
|
/// <summary>Visual assets for an encounter.</summary>
|
|
[Serializable]
|
|
public class EncounterVisuals {
|
|
public Sprite icon;
|
|
public Color encounterColor;
|
|
public Sprite encounterArt;
|
|
}
|
|
|
|
/// <summary>Numeric/tuning configuration shared across every encounter kind.</summary>
|
|
[Serializable]
|
|
public class EncounterProperties {
|
|
public int difficulty;
|
|
}
|
|
}
|