updated Candidate System with Voice System
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NightclubArcadia.Skills
|
||||
{
|
||||
// Generated from Assets/Candidates/candidates.json by CandidateSystemSetup.
|
||||
// Hand-edits to .asset files are overwritten on script reload — edit the JSON.
|
||||
[CreateAssetMenu(menuName = "Nightclub Arcadia/Candidate Definition", fileName = "NewCandidate")]
|
||||
public sealed class CandidateDefinition : ScriptableObject
|
||||
{
|
||||
[SerializeField] string id;
|
||||
[SerializeField] string displayName;
|
||||
[TextArea(2, 6)] [SerializeField] string reading;
|
||||
[SerializeField] SkillAxis intuitionAxis;
|
||||
[SerializeField] List<CandidateClue> clues = new List<CandidateClue>();
|
||||
|
||||
public string Id => id;
|
||||
public string DisplayName => displayName;
|
||||
public string Reading => reading;
|
||||
public SkillAxis IntuitionAxis => intuitionAxis;
|
||||
public IReadOnlyList<CandidateClue> Clues => clues;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void EditorSet(CandidateEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entry));
|
||||
}
|
||||
|
||||
id = entry.id;
|
||||
displayName = entry.displayName ?? string.Empty;
|
||||
reading = entry.reading ?? string.Empty;
|
||||
intuitionAxis = ParseEnumRequired<SkillAxis>(entry.intuitionAxis, nameof(entry.intuitionAxis), entry.id);
|
||||
|
||||
clues = new List<CandidateClue>();
|
||||
if (entry.clues == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var clueEntry in entry.clues)
|
||||
{
|
||||
if (clueEntry == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var clue = new CandidateClue();
|
||||
clue.EditorSet(clueEntry);
|
||||
clues.Add(clue);
|
||||
}
|
||||
}
|
||||
|
||||
static TEnum ParseEnumRequired<TEnum>(string value, string fieldName, string candidateId)
|
||||
where TEnum : struct
|
||||
{
|
||||
if (!Enum.TryParse(value, ignoreCase: true, out TEnum parsed))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"Candidate '{candidateId}': invalid {fieldName} '{value}' for {typeof(TEnum).Name}.");
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user