validation and dialogue system
This commit is contained in:
@@ -160,7 +160,13 @@ namespace Jovian.EncounterSystem.Editor {
|
||||
|
||||
for(int o = 0; o < optionSet.options.Count; o++) {
|
||||
var option = optionSet.options[o];
|
||||
if(option?.events == null) {
|
||||
if(option == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ValidateDialogLineRef(optionSet, encounter, $"options[{o}].text", option.text, issues);
|
||||
|
||||
if(option.events == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -190,6 +196,43 @@ namespace Jovian.EncounterSystem.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateDialogLineRef(EncounterDialogOptionSet optionSet, Encounter encounter, string path, DialogLineRef lineRef, List<ValidationIssue> issues) {
|
||||
var hasLibrary = lineRef.library != null;
|
||||
var hasId = !string.IsNullOrEmpty(lineRef.id);
|
||||
var hasInline = !string.IsNullOrEmpty(lineRef.inlineText);
|
||||
|
||||
if(!hasLibrary && !hasInline) {
|
||||
issues.Add(new ValidationIssue {
|
||||
asset = optionSet,
|
||||
encounter = encounter,
|
||||
path = path,
|
||||
severity = ValidationSeverity.Warning,
|
||||
message = "Dialog line is empty (no library reference and no inline text)."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if(hasLibrary && hasId && string.IsNullOrEmpty(lineRef.library.Resolve(lineRef.id))) {
|
||||
issues.Add(new ValidationIssue {
|
||||
asset = optionSet,
|
||||
encounter = encounter,
|
||||
path = path,
|
||||
severity = ValidationSeverity.Error,
|
||||
message = $"DialogLineRef id '{lineRef.id}' not found in library '{lineRef.library.name}'."
|
||||
});
|
||||
}
|
||||
|
||||
if(hasLibrary && !hasId && !hasInline) {
|
||||
issues.Add(new ValidationIssue {
|
||||
asset = optionSet,
|
||||
encounter = encounter,
|
||||
path = path,
|
||||
severity = ValidationSeverity.Warning,
|
||||
message = "Library assigned but no id picked; will fall back to empty inline text."
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateReward(Reward reward, List<ValidationIssue> issues) {
|
||||
if(reward == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user