rework dimensions and orientation into Placement, optimise requirements to work on previous candidates, use vec3 for positions

This commit is contained in:
2022-11-24 11:34:11 +01:00
parent f13ba4cd95
commit 3e51410ade
36 changed files with 268 additions and 275 deletions

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic;
using EscapeRoomEngine.Engine.Runtime.Modules;
using NaughtyAttributes;
using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Requirements
@@ -8,21 +7,11 @@ namespace EscapeRoomEngine.Engine.Runtime.Requirements
[CreateAssetMenu(menuName = "Requirements/No Overlap")]
public class NoOverlap : PlacementRequirement
{
[InfoBox("A module relative position will be oriented with the module (e.g. (0, 1) is always in front of the module).")]
[Label("Reserved Positions (Module Relative)")]
public List<Vector2Int> mrReservedPositions;
protected override IEnumerable<Vector2Int> GenerateCandidates(Module module, Space space)
protected override List<Placement> FilterCandidates(List<Placement> candidates, Module module, Space space)
{
var candidates = space.rrDimensions.EveryPosition;
space.AllModules.ForEach(m =>
space.AllModules.ForEach(other =>
{
candidates.Remove(m.SrPosition);
m.description.placementRequirements
.FindAll(r => r is NoOverlap)
.ForEach(r => ((NoOverlap)r).mrReservedPositions
.ForEach(p => candidates.Remove(m.ToSpaceRelative(p))));
candidates.RemoveAll(candidate => candidate.position.Equals(other.SrPosition));
});
return candidates;