orient entrance to reflect previous exit orientation
This commit is contained in:
@@ -30,25 +30,26 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
|
||||
/// </summary>
|
||||
internal Vector2Int RrPosition => _space.ToRoomRelative(SrPosition);
|
||||
|
||||
internal readonly ModuleDescription _description;
|
||||
protected GameObject _moduleObject;
|
||||
internal readonly ModuleDescription description;
|
||||
internal Orientation orientation;
|
||||
|
||||
/// <summary>
|
||||
/// The space relative (<i>SR</i>) dimensions of this module.
|
||||
/// </summary>
|
||||
protected Dimensions srDimensions;
|
||||
protected Orientation orientation;
|
||||
|
||||
private GameObject _moduleObject, _orientationObject;
|
||||
private readonly Space _space;
|
||||
|
||||
internal Module(Space space, ModuleDescription description)
|
||||
{
|
||||
_space = space;
|
||||
_description = description;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
internal bool IsType(ModuleType type)
|
||||
{
|
||||
return _description.types.Contains(type);
|
||||
return description.types.Contains(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,24 +74,22 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
|
||||
Logger.Log($"{this} has been placed at {srPosition} (SR)", LogType.ModulePlacement);
|
||||
}
|
||||
|
||||
internal void Orient(Orientation o)
|
||||
{
|
||||
orientation = o;
|
||||
}
|
||||
|
||||
internal void InstantiateModule(Transform parent)
|
||||
{
|
||||
_moduleObject = new GameObject(ToString());
|
||||
_moduleObject.transform.SetParent(parent, false);
|
||||
_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()
|
||||
{
|
||||
return $"Module ({string.Join(", ", _description.types.ToList().ConvertAll(type => type.ToString()))})";
|
||||
return $"Module ({string.Join(", ", description.types.ToList().ConvertAll(type => type.ToString()))})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user