rework dimensions and orientation into Placement, optimise requirements to work on previous candidates, use vec3 for positions
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user