forked from Shardstone/trail-into-darkness
Some encounter testing and working
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Jovian.EncounterSystem.Editor {
|
||||
public static List<ValidationIssue> ValidateProject() {
|
||||
var issues = new List<ValidationIssue>();
|
||||
|
||||
ValidateRegistries(issues);
|
||||
|
||||
var tables = FindAssetsOfType<EncounterTable>();
|
||||
var idIndex = new Dictionary<string, (Encounter encounter, EncounterTable table)>();
|
||||
|
||||
@@ -36,6 +38,42 @@ namespace Jovian.EncounterSystem.Editor {
|
||||
return issues;
|
||||
}
|
||||
|
||||
private static void ValidateRegistries(List<ValidationIssue> issues) {
|
||||
var registries = FindAssetsOfType<EncounterRegistry>();
|
||||
if(registries.Count == 0) {
|
||||
issues.Add(new ValidationIssue {
|
||||
asset = null,
|
||||
path = "<project>",
|
||||
severity = ValidationSeverity.Error,
|
||||
message = "No EncounterRegistry asset exists. Create one via Jovian → Encounter System → Encounter Registry."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(var registry in registries) {
|
||||
if(registry.encounterCollections == null || registry.encounterCollections.Length == 0) {
|
||||
issues.Add(new ValidationIssue {
|
||||
asset = registry,
|
||||
path = "encounterCollections",
|
||||
severity = ValidationSeverity.Warning,
|
||||
message = "Registry has no collections assigned."
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int i = 0; i < registry.encounterCollections.Length; i++) {
|
||||
if(registry.encounterCollections[i] == null) {
|
||||
issues.Add(new ValidationIssue {
|
||||
asset = registry,
|
||||
path = $"encounterCollections[{i}]",
|
||||
severity = ValidationSeverity.Warning,
|
||||
message = "Null collection slot."
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ValidationIssue> ValidateEncounter(EncounterTable table, int index) {
|
||||
var issues = new List<ValidationIssue>();
|
||||
if(table?.encounters == null || index < 0 || index >= table.encounters.Count) {
|
||||
@@ -95,25 +133,26 @@ namespace Jovian.EncounterSystem.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
if(encounter.Kind == null) {
|
||||
if(encounter.EncounterDefinition?.Kind == null) {
|
||||
issues.Add(new ValidationIssue {
|
||||
asset = table,
|
||||
encounter = encounter,
|
||||
path = $"{pathPrefix}.Kind",
|
||||
path = $"{pathPrefix}.EncounterDefinition.Kind",
|
||||
severity = ValidationSeverity.Warning,
|
||||
message = "Encounter.Kind is null — pick a kind in the inspector."
|
||||
});
|
||||
}
|
||||
|
||||
if(encounter.Kind is QuestKind questKind) {
|
||||
ValidateEncounterLink(table, pathPrefix + ".Kind.nextEncounter", encounter, questKind.nextEncounter, issues);
|
||||
if(encounter.EncounterDefinition?.Kind is QuestKind questKind) {
|
||||
ValidateEncounterLink(table, pathPrefix + ".EncounterDefinition.Kind.nextEncounter", encounter, questKind.nextEncounter, issues);
|
||||
}
|
||||
|
||||
ValidateDialogEvents(table, index, encounter, issues);
|
||||
}
|
||||
|
||||
private static void ValidateEncounterLink(EncounterTable owningTable, string path, Encounter encounter, EncounterLink link, List<ValidationIssue> issues) {
|
||||
if(link.table == null && string.IsNullOrEmpty(link.internalId)) {
|
||||
// No id picked — terminal quest step / unset link. Not an error regardless of table value.
|
||||
if(string.IsNullOrEmpty(link.internalId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user