make sure every module is accessible

This commit is contained in:
2022-11-07 20:51:00 +01:00
parent aae5e78082
commit 648919cf5a
13 changed files with 100 additions and 30 deletions

View File

@@ -74,6 +74,24 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
Logger.Log($"{this} has been placed at {srPosition} (SR)", LogType.ModulePlacement);
}
/// <summary>
/// Convert a position relative to this module to one relative to its space.
/// <example>The module relative position <c>(0, 1)</c> should always be in front of the module, wherever it faces.</example>
/// </summary>
/// <param name="mrPosition">The module relative (<i>MR</i>) position that should be converted to a space relative (<i>SR</i>) position.</param>
/// <returns></returns>
internal Vector2Int ToSpaceRelative(Vector2Int mrPosition)
{
return srDimensions.Position + orientation switch
{
Orientation.North => mrPosition,
Orientation.East => new Vector2Int(mrPosition.y, -mrPosition.x),
Orientation.South => -mrPosition,
Orientation.West => new Vector2Int(-mrPosition.y, mrPosition.x),
_ => throw new ArgumentOutOfRangeException()
};
}
internal void InstantiateModule(Transform parent)
{
_moduleObject = new GameObject(ToString());