59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace NightclubArcadia.Skills
|
|
{
|
|
[Serializable]
|
|
public sealed class CandidateClue
|
|
{
|
|
[SerializeField] string id;
|
|
[SerializeField] CandidateEvidenceType type;
|
|
[SerializeField] string sceneId;
|
|
[SerializeField] string unlockFlag;
|
|
[SerializeField] CandidateClueStatus status;
|
|
[SerializeField] string skillId;
|
|
[SerializeField] string notes;
|
|
|
|
public string Id => id;
|
|
public CandidateEvidenceType Type => type;
|
|
public string SceneId => sceneId;
|
|
public string UnlockFlag => unlockFlag;
|
|
public CandidateClueStatus Status => status;
|
|
public string SkillId => skillId;
|
|
public string Notes => notes;
|
|
|
|
#if UNITY_EDITOR
|
|
public void EditorSet(CandidateClueEntry entry)
|
|
{
|
|
if (entry == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(entry));
|
|
}
|
|
|
|
id = entry.id ?? string.Empty;
|
|
type = ParseEnumRequired<CandidateEvidenceType>(entry.type, nameof(entry.type), entry.id);
|
|
sceneId = entry.sceneId ?? string.Empty;
|
|
unlockFlag = entry.unlockFlag ?? string.Empty;
|
|
status = ParseEnumRequired<CandidateClueStatus>(
|
|
string.IsNullOrEmpty(entry.status) ? "Planned" : entry.status,
|
|
nameof(entry.status),
|
|
entry.id);
|
|
skillId = entry.skillId ?? string.Empty;
|
|
notes = entry.notes ?? string.Empty;
|
|
}
|
|
|
|
static TEnum ParseEnumRequired<TEnum>(string value, string fieldName, string clueId)
|
|
where TEnum : struct
|
|
{
|
|
if (!Enum.TryParse(value, ignoreCase: true, out TEnum parsed))
|
|
{
|
|
throw new ArgumentException(
|
|
$"Clue '{clueId}': invalid {fieldName} '{value}' for {typeof(TEnum).Name}.");
|
|
}
|
|
|
|
return parsed;
|
|
}
|
|
#endif
|
|
}
|
|
}
|