orientation requirements
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using Escape_Room_Engine.Engine.Scripts.Modules;
|
||||
using Unity.XR.CoreUtils;
|
||||
using UnityEngine;
|
||||
using Logger = Escape_Room_Engine.Engine.Scripts.Utilities.Logger;
|
||||
using LogType = Escape_Room_Engine.Engine.Scripts.Utilities.LogType;
|
||||
|
||||
namespace Escape_Room_Engine.Engine.Scripts.Requirements
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Requirements/Face Space Center")]
|
||||
public class FaceSpaceCenter : OrientationRequirement
|
||||
{
|
||||
public override IEnumerable<Orientation> OrientationCandidates(Module module, Space space)
|
||||
{
|
||||
var orientation = new HashSet<Orientation>(1);
|
||||
float width = space.rrDimensions.width;
|
||||
float length = space.rrDimensions.length;
|
||||
var xRel = module.SrPosition.x / (width - 1);
|
||||
var zRel = module.SrPosition.y / (length - 1);
|
||||
|
||||
Debug.Log($"{xRel}, {zRel}, {1 - xRel}");
|
||||
|
||||
if (zRel > xRel)
|
||||
{
|
||||
orientation.Add(zRel > 1 - xRel ? Orientation.South : Orientation.East);
|
||||
}
|
||||
else
|
||||
{
|
||||
orientation.Add(zRel > 1 - xRel ? Orientation.West : Orientation.North);
|
||||
}
|
||||
|
||||
return orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 872da92bb04647e3bd6e741e6bb0a976
|
||||
timeCreated: 1667878978
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using Escape_Room_Engine.Engine.Scripts.Modules;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Escape_Room_Engine.Engine.Scripts.Requirements
|
||||
{
|
||||
public abstract class OrientationRequirement : Requirement
|
||||
{
|
||||
public abstract IEnumerable<Orientation> OrientationCandidates(Module module, Space space);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0704ea5393394baf921f68d2dcbdfaec
|
||||
timeCreated: 1667878220
|
||||
@@ -7,19 +7,19 @@ namespace Escape_Room_Engine.Engine.Scripts.Requirements
|
||||
[CreateAssetMenu(menuName = "Requirements/Place Along Space Edges")]
|
||||
public class PlaceAlongSpaceEdges : PlacementRequirement
|
||||
{
|
||||
public override HashSet<Vector2Int> PlacementCandidates(Module module, Space space)
|
||||
public override IEnumerable<Vector2Int> PlacementCandidates(Module module, Space space)
|
||||
{
|
||||
var edgePositions = new HashSet<Vector2Int>();
|
||||
|
||||
for (var x = 0; x < space.rrDimensions.width; x++)
|
||||
{
|
||||
edgePositions.Add(new Vector2Int(x, 0));
|
||||
edgePositions.Add(new Vector2Int(x, space.rrDimensions.length));
|
||||
edgePositions.Add(new Vector2Int(x, space.rrDimensions.length - 1));
|
||||
}
|
||||
for (var z = 0; z < space.rrDimensions.length; z++)
|
||||
{
|
||||
edgePositions.Add(new Vector2Int(0, z));
|
||||
edgePositions.Add(new Vector2Int(space.rrDimensions.width, z));
|
||||
edgePositions.Add(new Vector2Int(space.rrDimensions.width - 1, z));
|
||||
}
|
||||
|
||||
return edgePositions;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Escape_Room_Engine.Engine.Scripts.Requirements
|
||||
[CreateAssetMenu(menuName = "Requirements/Place Anywhere")]
|
||||
public class PlaceAnywhere : PlacementRequirement
|
||||
{
|
||||
public override HashSet<Vector2Int> PlacementCandidates(Module module, Space space)
|
||||
public override IEnumerable<Vector2Int> PlacementCandidates(Module module, Space space)
|
||||
{
|
||||
return space.rrDimensions.EveryPosition;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ namespace Escape_Room_Engine.Engine.Scripts.Requirements
|
||||
{
|
||||
public abstract class PlacementRequirement : Requirement
|
||||
{
|
||||
public abstract HashSet<Vector2Int> PlacementCandidates(Module module, Space space);
|
||||
public abstract IEnumerable<Vector2Int> PlacementCandidates(Module module, Space space);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user