laser puzzle platform and elevated platform module
This commit is contained in:
@@ -3,7 +3,6 @@ using System.Linq;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules.Description;
|
||||
using EscapeRoomEngine.Engine.Runtime.UI;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using UnityEngine;
|
||||
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
|
||||
using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
|
||||
srPlacement = placement;
|
||||
|
||||
Logger.Log($"{this} has been placed at {placement.position} (SR)", LogType.ModulePlacement);
|
||||
Logger.Log($"{this} has been placed at {placement.ToStringShort()} (SR)", LogType.ModulePlacement);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,7 +111,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
Logger.Log($"Instantiating {this}", LogType.ModuleInstantiation);
|
||||
|
||||
State = Object.Instantiate(description.modulePrefab, parent, false);
|
||||
State.transform.localPosition = new Vector3(SrPosition.x + .5f, 0, SrPosition.z + .5f);
|
||||
State.transform.localPosition = new Vector3(SrPosition.x + .5f, SrPosition.y, SrPosition.z + .5f);
|
||||
State.transform.Rotate(Vector3.up, Orientation.Angle());
|
||||
State.name = ToString();
|
||||
State.SetModule(this);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.Requirements.Placement
|
||||
{
|
||||
/// <summary>
|
||||
/// This requirement places a module in the same position as its first related module.
|
||||
/// Accepts an optional offset to the module.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Requirements/Place With First Related Module")]
|
||||
public class PlaceWithFirstRelatedModule : PlacementRequirement
|
||||
{
|
||||
public Vector3Int offset;
|
||||
|
||||
protected override List<Utilities.Placement> FilterCandidates(List<Utilities.Placement> candidates, Module module, Space space)
|
||||
{
|
||||
var placement = module.relatedModules[0].srPlacement;
|
||||
placement.position += offset;
|
||||
return new List<Utilities.Placement> { placement };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.Requirements.Placement
|
||||
{
|
||||
/// <summary>
|
||||
/// This requirement places a module exactly in the same position as its first related module.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Requirements/Place With Related Module")]
|
||||
public class PlaceWithRelatedModule : PlacementRequirement
|
||||
{
|
||||
protected override List<Utilities.Placement> FilterCandidates(List<Utilities.Placement> candidates, Module module, Space space)
|
||||
{
|
||||
return new List<Utilities.Placement> { module.relatedModules[0].srPlacement };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,35 +93,14 @@ namespace EscapeRoomEngine.Engine.Runtime.Utilities
|
||||
var sizeMinusOne = size - Vector2Int.one;
|
||||
var spaceSize = space.rrPlacement.size;
|
||||
|
||||
foreach (var o in OrientationExtensions.EveryOrientation())
|
||||
{
|
||||
Range x;
|
||||
Range z;
|
||||
|
||||
switch (o)
|
||||
{
|
||||
case Orientation.North:
|
||||
x = new Range(0, spaceSize.x - sizeMinusOne.x);
|
||||
z = new Range(0, spaceSize.y - sizeMinusOne.y);
|
||||
break;
|
||||
case Orientation.East:
|
||||
x = new Range(0, spaceSize.x - sizeMinusOne.y);
|
||||
z = new Range(sizeMinusOne.x, spaceSize.y);
|
||||
break;
|
||||
case Orientation.South:
|
||||
x = new Range(sizeMinusOne.x, spaceSize.x);
|
||||
z = new Range(sizeMinusOne.y, spaceSize.y);
|
||||
break;
|
||||
case Orientation.West:
|
||||
x = new Range(sizeMinusOne.y, spaceSize.x);
|
||||
z = new Range(0, spaceSize.y - sizeMinusOne.x);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
placements.AddRange(ConstrainedPlacements(o, size, x, z));
|
||||
}
|
||||
placements.AddRange(ConstrainedPlacements(Orientation.North, size,
|
||||
new Range(0, spaceSize.x - sizeMinusOne.x), new Range(0, spaceSize.y - sizeMinusOne.y)));
|
||||
placements.AddRange(ConstrainedPlacements(Orientation.East, size,
|
||||
new Range(0, spaceSize.x - sizeMinusOne.y), new Range(sizeMinusOne.x, spaceSize.y)));
|
||||
placements.AddRange(ConstrainedPlacements(Orientation.South, size,
|
||||
new Range(sizeMinusOne.x, spaceSize.x), new Range(sizeMinusOne.y, spaceSize.y)));
|
||||
placements.AddRange(ConstrainedPlacements(Orientation.West, size,
|
||||
new Range(sizeMinusOne.y, spaceSize.x), new Range(0, spaceSize.y - sizeMinusOne.x)));
|
||||
|
||||
return placements;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user