forked from aly/qstbak
muffin v7.5.5
This commit is contained in:
parent
a8f2c1df37
commit
6266f9e6b7
110 changed files with 14907 additions and 6073 deletions
|
|
@ -0,0 +1,61 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Questionable.Model;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.Validation.Validators;
|
||||
|
||||
internal sealed class LandingZoneValidator : IQuestValidator
|
||||
{
|
||||
public IEnumerable<ValidationIssue> Validate(Quest quest)
|
||||
{
|
||||
foreach (var stepInfo in quest.AllSteps().Where<(QuestSequence, int, QuestStep)>(delegate((QuestSequence Sequence, int StepId, QuestStep Step) x)
|
||||
{
|
||||
List<LandingZone> landingZones = x.Step.LandingZones;
|
||||
return landingZones != null && landingZones.Count > 0;
|
||||
}))
|
||||
{
|
||||
for (int z = 0; z < stepInfo.Item3.LandingZones.Count; z++)
|
||||
{
|
||||
LandingZone zone = stepInfo.Item3.LandingZones[z];
|
||||
if (zone.Vertices.Count < 3)
|
||||
{
|
||||
yield return new ValidationIssue
|
||||
{
|
||||
ElementId = quest.Id,
|
||||
Sequence = stepInfo.Item1.Sequence,
|
||||
Step = stepInfo.Item2,
|
||||
Type = EIssueType.InvalidLandingZone,
|
||||
Severity = EIssueSeverity.Error,
|
||||
Description = $"Landing zone {z} has fewer than 3 vertices"
|
||||
};
|
||||
continue;
|
||||
}
|
||||
if (!LandingZoneMath.IsConvex(zone.Vertices))
|
||||
{
|
||||
yield return new ValidationIssue
|
||||
{
|
||||
ElementId = quest.Id,
|
||||
Sequence = stepInfo.Item1.Sequence,
|
||||
Step = stepInfo.Item2,
|
||||
Type = EIssueType.InvalidLandingZone,
|
||||
Severity = EIssueSeverity.Error,
|
||||
Description = $"Landing zone {z} is not convex"
|
||||
};
|
||||
}
|
||||
if (LandingZoneMath.CalculatePolygonArea(zone.Vertices) < 0.01f)
|
||||
{
|
||||
yield return new ValidationIssue
|
||||
{
|
||||
ElementId = quest.Id,
|
||||
Sequence = stepInfo.Item1.Sequence,
|
||||
Step = stepInfo.Item2,
|
||||
Type = EIssueType.InvalidLandingZone,
|
||||
Severity = EIssueSeverity.Error,
|
||||
Description = $"Landing zone {z} has zero area (collinear vertices)"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue