station 46 room

This commit is contained in:
2023-05-14 18:13:02 +02:00
parent f03d723119
commit eba953b844
31 changed files with 978 additions and 672 deletions

View File

@@ -0,0 +1,46 @@
using System.Collections.Generic;
using EscapeRoomEngine.Engine.Runtime.Modules;
using EscapeRoomEngine.Engine.Runtime.Modules.State;
using EscapeRoomEngine.Engine.Runtime.Utilities;
using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Requirements.Placement
{
/// <summary>
/// This requirement guarantees that the back side of the module is placed on the bottom row of an even-numbered space or on the top row of an odd-numbered space.
/// </summary>
[CreateAssetMenu(menuName = "Requirements/Place On Bottom Or Top Row Alternating")]
public class PlaceOnBottomOrTopRowAlternating : PlacementRequirement
{
protected override List<Utilities.Placement> FilterCandidates(List<Utilities.Placement> candidates, Module module, Space space)
{
if (!module.description.HasType(ModuleType.DoorExit))
{
throw new WrongTypeException(module.description.types[0], ModuleType.DoorExit);
}
var number = FindObjectsByType<DoorState>(FindObjectsInactive.Include, FindObjectsSortMode.None).Length;
if (number / 2 % 2 == 0)
{
candidates.RemoveAll(candidate =>
{
var (left, right) = candidate.BackCorners;
return !(left.z == 0 && right.z == 0);
});
}
else
{
var sizeMinusOne = space.rrPlacement.size - Vector2Int.one;
candidates.RemoveAll(candidate =>
{
var (left, right) = candidate.BackCorners;
return !(left.z == sizeMinusOne.y && right.z == sizeMinusOne.y);
});
}
return candidates;
}
}
}

View File

@@ -1,24 +0,0 @@
using System.Collections.Generic;
using EscapeRoomEngine.Engine.Runtime.Modules;
using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Requirements.Placement
{
/// <summary>
/// This requirement guarantees that the back side of the module is placed on the bottom row of the space.
/// </summary>
[CreateAssetMenu(menuName = "Requirements/Place On Bottom Row")]
public class PlaceOnBottomRow : PlacementRequirement
{
protected override List<Utilities.Placement> FilterCandidates(List<Utilities.Placement> candidates, Module module, Space space)
{
candidates.RemoveAll(candidate =>
{
var (left, right) = candidate.BackCorners;
return !(left.z == 0 && right.z == 0);
});
return candidates;
}
}
}