implemented skill system according to designdocuments

This commit is contained in:
2026-08-15 08:09:29 +02:00
parent f8def361fa
commit 063e94f6eb
95 changed files with 2924 additions and 4 deletions
@@ -0,0 +1,75 @@
using UnityEngine;
using Yarn.Unity;
namespace NightclubArcadia.Skills
{
/// <summary>
/// Composition root and singleton that static Yarn commands route through.
/// </summary>
public sealed class SkillRuntime : MonoBehaviour
{
public static SkillRuntime Instance { get; private set; }
[SerializeField] SkillDatabase database;
[SerializeField] DialogueRunner dialogueRunner;
[SerializeField] SkillCheckResultView resultView;
[SerializeField] CommentarySystem commentary;
[SerializeField] int rollSeed;
[SerializeField] string debugContextId = "Entrance_Queue";
public SkillDatabase Database => database;
public DialogueRunner DialogueRunner => dialogueRunner;
public SkillCheckResultView ResultView => resultView;
public CommentarySystem Commentary => commentary;
public PlayerSkills Skills { get; private set; }
public SkillStateModifiers States { get; private set; }
public SkillCheckSystem Checks { get; private set; }
public IRollSource Rolls { get; private set; }
void Awake()
{
if (Instance != null && Instance != this)
{
Debug.LogError($"[{nameof(SkillRuntime)}] Duplicate instance on '{name}'. Destroying this component.", this);
Destroy(this);
return;
}
Instance = this;
if (database == null)
{
Debug.LogError($"[{nameof(SkillRuntime)}] SkillDatabase is not assigned.", this);
}
Skills = database != null ? new PlayerSkills(database) : null;
States = new SkillStateModifiers();
Rolls = rollSeed != 0 ? (IRollSource)new SeededRollSource(rollSeed) : new UnityRollSource();
if (Skills != null)
{
Checks = new SkillCheckSystem(database, Skills, States, Rolls);
}
}
void OnDestroy()
{
if (Instance == this)
{
Instance = null;
}
}
[ContextMenu("Fire Commentary (debug)")]
void FireCommentaryDebug()
{
if (commentary == null)
{
Debug.LogWarning($"[{nameof(SkillRuntime)}] No CommentarySystem assigned.", this);
return;
}
commentary.RequestCommentary(debugContextId);
}
}
}