orient entrance to reflect previous exit orientation
This commit is contained in:
@@ -77,6 +77,7 @@ namespace Escape_Room_Engine.Engine.Scripts
|
|||||||
Random.Range(0, rrDimensions.width),
|
Random.Range(0, rrDimensions.width),
|
||||||
Random.Range(0, rrDimensions.length)
|
Random.Range(0, rrDimensions.length)
|
||||||
));
|
));
|
||||||
|
exitDoor.orientation = Module.EveryOrientation.RandomElement();
|
||||||
var exit = new Passage(exitDoor);
|
var exit = new Passage(exitDoor);
|
||||||
space.AddModule(exitDoor);
|
space.AddModule(exitDoor);
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ namespace Escape_Room_Engine.Engine.Scripts
|
|||||||
|
|
||||||
// place puzzle
|
// place puzzle
|
||||||
var placementCandidates = space.rrDimensions.EveryPosition;
|
var placementCandidates = space.rrDimensions.EveryPosition;
|
||||||
puzzle._description.RequirementsOfType<PlacementRequirement>().ForEach(requirement =>
|
puzzle.description.RequirementsOfType<PlacementRequirement>().ForEach(requirement =>
|
||||||
placementCandidates.IntersectWith(requirement.PlacementCandidates(puzzle, space)));
|
placementCandidates.IntersectWith(requirement.PlacementCandidates(puzzle, space)));
|
||||||
|
|
||||||
Logger.Log($"placement candidates: {string.Join(", ", placementCandidates.ToList().ConvertAll(c => c.ToString()))}", LogType.RequirementResolution);
|
Logger.Log($"placement candidates: {string.Join(", ", placementCandidates.ToList().ConvertAll(c => c.ToString()))}", LogType.RequirementResolution);
|
||||||
@@ -112,15 +113,14 @@ namespace Escape_Room_Engine.Engine.Scripts
|
|||||||
|
|
||||||
// orient puzzle
|
// orient puzzle
|
||||||
var orientationCandidates = Module.EveryOrientation;
|
var orientationCandidates = Module.EveryOrientation;
|
||||||
Logger.Log($"orientation candidatesA: {string.Join(",", orientationCandidates.ToList().ConvertAll(c => c.ToString()))}", LogType.RequirementResolution);
|
puzzle.description.RequirementsOfType<OrientationRequirement>().ForEach(requirement =>
|
||||||
puzzle._description.RequirementsOfType<OrientationRequirement>().ForEach(requirement =>
|
|
||||||
orientationCandidates.IntersectWith(requirement.OrientationCandidates(puzzle, space)));
|
orientationCandidates.IntersectWith(requirement.OrientationCandidates(puzzle, space)));
|
||||||
|
|
||||||
Logger.Log($"orientation candidates: {string.Join(",", orientationCandidates.ToList().ConvertAll(c => c.ToString()))}", LogType.RequirementResolution);
|
Logger.Log($"orientation candidates: {string.Join(",", orientationCandidates.ToList().ConvertAll(c => c.ToString()))}", LogType.RequirementResolution);
|
||||||
|
|
||||||
if (orientationCandidates.Count > 0)
|
if (orientationCandidates.Count > 0)
|
||||||
{
|
{
|
||||||
puzzle.Orient(orientationCandidates.RandomElement());
|
puzzle.orientation = orientationCandidates.RandomElement();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,25 +30,26 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal Vector2Int RrPosition => _space.ToRoomRelative(SrPosition);
|
internal Vector2Int RrPosition => _space.ToRoomRelative(SrPosition);
|
||||||
|
|
||||||
internal readonly ModuleDescription _description;
|
internal readonly ModuleDescription description;
|
||||||
protected GameObject _moduleObject;
|
internal Orientation orientation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The space relative (<i>SR</i>) dimensions of this module.
|
/// The space relative (<i>SR</i>) dimensions of this module.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Dimensions srDimensions;
|
protected Dimensions srDimensions;
|
||||||
protected Orientation orientation;
|
|
||||||
|
|
||||||
|
private GameObject _moduleObject, _orientationObject;
|
||||||
private readonly Space _space;
|
private readonly Space _space;
|
||||||
|
|
||||||
internal Module(Space space, ModuleDescription description)
|
internal Module(Space space, ModuleDescription description)
|
||||||
{
|
{
|
||||||
_space = space;
|
_space = space;
|
||||||
_description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool IsType(ModuleType type)
|
internal bool IsType(ModuleType type)
|
||||||
{
|
{
|
||||||
return _description.types.Contains(type);
|
return description.types.Contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -73,24 +74,22 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
|
|||||||
Logger.Log($"{this} has been placed at {srPosition} (SR)", LogType.ModulePlacement);
|
Logger.Log($"{this} has been placed at {srPosition} (SR)", LogType.ModulePlacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Orient(Orientation o)
|
|
||||||
{
|
|
||||||
orientation = o;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void InstantiateModule(Transform parent)
|
internal void InstantiateModule(Transform parent)
|
||||||
{
|
{
|
||||||
_moduleObject = new GameObject(ToString());
|
_moduleObject = new GameObject(ToString());
|
||||||
_moduleObject.transform.SetParent(parent, false);
|
_moduleObject.transform.SetParent(parent, false);
|
||||||
_moduleObject.transform.localPosition = new Vector3(srDimensions.x + .5f, 0, srDimensions.z + .5f);
|
_moduleObject.transform.localPosition = new Vector3(srDimensions.x + .5f, 0, srDimensions.z + .5f);
|
||||||
_moduleObject.transform.Rotate(Vector3.up, (float)orientation);
|
|
||||||
|
|
||||||
Object.Instantiate(_description.modulePrefab, _moduleObject.transform, false);
|
_orientationObject = new GameObject("Orientation");
|
||||||
|
_orientationObject.transform.SetParent(_moduleObject.transform, false);
|
||||||
|
_orientationObject.transform.Rotate(Vector3.up, (float)orientation);
|
||||||
|
|
||||||
|
Object.Instantiate(description.modulePrefab, _orientationObject.transform, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"Module ({string.Join(", ", _description.types.ToList().ConvertAll(type => type.ToString()))})";
|
return $"Module ({string.Join(", ", description.types.ToList().ConvertAll(type => type.ToString()))})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ namespace Escape_Room_Engine.Engine.Scripts
|
|||||||
{
|
{
|
||||||
toIn = door;
|
toIn = door;
|
||||||
|
|
||||||
// to make sure the origin of the player doesn't move, the two doors must be placed in the same location
|
// to make sure the origin of the player doesn't move, the two doors must be placed in the same location in the same orientation
|
||||||
toIn.PlaceRoomRelative(rrPosition);
|
toIn.PlaceRoomRelative(rrPosition);
|
||||||
|
toIn.orientation = fromOut.orientation;
|
||||||
|
|
||||||
Logger.Log($"Connected passage to {door} at {rrPosition} (RR)", LogType.PassageConnection);
|
Logger.Log($"Connected passage to {door} at {rrPosition} (RR)", LogType.PassageConnection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace Escape_Room_Engine.Engine.Scripts
|
|||||||
|
|
||||||
// connect the space to its passage
|
// connect the space to its passage
|
||||||
entrance.ConnectTo(new DoorModule(this,
|
entrance.ConnectTo(new DoorModule(this,
|
||||||
((DoorModuleDescription)entrance.fromOut._description).connectedDoorDescription));
|
((DoorModuleDescription)entrance.fromOut.description).connectedDoorDescription));
|
||||||
AddModule(entrance.toIn);
|
AddModule(entrance.toIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user