comment pass

This commit is contained in:
2022-12-29 16:16:49 +01:00
parent 643e03192a
commit ff01a700bd
75 changed files with 634 additions and 65 deletions

View File

@@ -3,9 +3,14 @@ using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// A <see cref="StepPuzzle"/> whose steps are considered a cycle that can be started anywhere and must be stepped through once.
/// </summary>
public class CyclicStepPuzzle : StepPuzzle
{
[BoxGroup("Step Puzzle")] [Min(0)] public int cycleStep;
[Tooltip("The current step in the cycle.")]
[BoxGroup("Step Puzzle")] [Min(0)]
public int cycleStep;
protected override void CheckStep(int step)
{

View File

@@ -9,13 +9,22 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
Entrance = ModuleType.DoorEntrance, Exit = ModuleType.DoorExit
}
/// <summary>
/// The main component of any door module.
/// </summary>
[Serializable]
public class DoorModule : Module
{
public bool IsEntrance => IsType((ModuleType)DoorType.Entrance);
public bool IsExit => IsType((ModuleType)DoorType.Exit);
/// <summary>
/// The module state of this door as a <see cref="DoorState"/>.
/// </summary>
public DoorState DoorState => DoorState.FromState(State);
/// <summary>
/// The module state of the connected door as a <see cref="DoorState"/>.
/// </summary>
public DoorState ConnectedDoorState => Passage.Other(this).DoorState;
/// <summary>
@@ -47,6 +56,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
{
base.InstantiateModule(parent);
// the room needs to know about this door
space.room.AddDoor(this);
}

View File

@@ -2,6 +2,9 @@
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The <see cref="ModuleDescription"/> for a <see cref="DoorModule"/>. Includes the description of the connected door.
/// </summary>
[CreateAssetMenu(menuName = "Modules/Door")]
public class DoorModuleDescription : ModuleDescription
{

View File

@@ -10,10 +10,19 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
public delegate void DoorEventHandler(DoorModule source, DoorEventType e);
/// <summary>
/// The <see cref="ModuleState"/> of a <see cref="DoorModule"/>. Handles all events that can occur for a door.
/// </summary>
public class DoorState : ModuleState
{
/// <summary>
/// Add event handlers to this hook to receive all events concerning this door.
/// </summary>
public event DoorEventHandler DoorEvent;
/// <summary>
/// The door module this state belongs to.
/// </summary>
protected DoorModule Module { get; set; }
public bool Unlocked
{

View File

@@ -10,6 +10,9 @@ using Object = UnityEngine.Object;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The main representation of a module. Contains references to the module description, state and handles its placement.
/// </summary>
public class Module
{
public readonly List<Module> relatedModules = new();

View File

@@ -5,9 +5,13 @@ using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The description of a specific module variant. Includes any requirements, the types and the module state that should be initialised with the module.
/// </summary>
[CreateAssetMenu(menuName = "Modules/Generic Module")]
public class ModuleDescription : ScriptableObject
{
[Tooltip("The module types decide how this module can be used.")]
public List<ModuleType> types = new();
public ModuleState modulePrefab;
[BoxGroup("Requirements")]

View File

@@ -2,8 +2,12 @@
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// An abstract module state. Example implementations are <see cref="DoorState"/> and <see cref="PuzzleState"/>.
/// </summary>
public abstract class ModuleState : MonoBehaviour
{
[Tooltip("The size of this module in meters.")]
public Vector2Int size = Vector2Int.one;
public abstract void SetModule(Module module);

View File

@@ -1,5 +1,8 @@
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// A module can have one or multiple types.
/// </summary>
public enum ModuleType
{
DoorEntrance, DoorExit, // door types

View File

@@ -3,8 +3,14 @@ using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The main component of any puzzle module.
/// </summary>
public class PuzzleModule : Module
{
/// <summary>
/// The module state of this puzzle as a <see cref="PuzzleState"/>.
/// </summary>
internal PuzzleState PuzzleState => PuzzleState.FromState(State);
internal PuzzleModule(Space space, PuzzleModuleDescription description) : base(space, description) {}
@@ -13,6 +19,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
{
base.InstantiateModule(parent);
// the room needs to know about this puzzle
space.room.AddPuzzle(this);
}

View File

@@ -3,13 +3,21 @@ using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The <see cref="ModuleDescription"/> for a <see cref="DoorModule"/>. Includes the description of the connected door.
/// </summary>
[CreateAssetMenu(menuName = "Modules/Puzzle")]
public class PuzzleModuleDescription : ModuleDescription
{
[Tooltip("Each puzzle has a name that will be used to display it to the game master.")]
[InfoBox("Changes to the name or version of the puzzle change its ID, which means it will not be connected with any of its previous measures any more.", EInfoBoxType.Warning)]
public string puzzleName;
[InfoBox("Puzzle measurements will only be combined for the same puzzle with the same version. If large changes are made to the puzzle that might influence its measurements, the version should be incremented.")]
public int puzzleVersion = 1;
/// <summary>
/// The ID of the puzzle is used in the database.
/// </summary>
public int Id => puzzleName.GetHashCode() + puzzleVersion;
public override string ToString()

View File

@@ -1,5 +1,6 @@
using System;
using EscapeRoomEngine.Engine.Runtime.Utilities;
using JetBrains.Annotations;
using NaughtyAttributes;
using UnityEngine;
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
@@ -28,11 +29,20 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
public delegate void PuzzleEventHandler(PuzzleModule source, PuzzleEventType e);
/// <summary>
/// The <see cref="ModuleState"/> of a <see cref="PuzzleModule"/>. Handles all events that can occur for a door.
/// </summary>
[SelectionBase]
public class PuzzleState : ModuleState
{
/// <summary>
/// Add event handlers to this hook to receive all events concerning this puzzle.
/// </summary>
public event PuzzleEventHandler PuzzleEvent;
/// <summary>
/// The puzzle module this state belongs to.
/// </summary>
protected PuzzleModule Module { get; private set; }
public bool Solved
{
@@ -69,8 +79,11 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
#region Debug Buttons
[Button(enabledMode: EButtonEnableMode.Playmode)] public void Solve() => Solved = true;
[Button(enabledMode: EButtonEnableMode.Playmode)] public void Restart() => Solved = false;
[Button(enabledMode: EButtonEnableMode.Playmode)]
public void Solve() => Solved = true;
[UsedImplicitly]
[Button(enabledMode: EButtonEnableMode.Playmode)]
public void Restart() => Solved = false;
[Button("Trigger Wrong Input", EButtonEnableMode.Playmode)]
public void WrongInput()
{

View File

@@ -1,5 +1,8 @@
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The spawn door is used in the first room.
/// </summary>
internal class Spawn : DoorState
{
private void Start()

View File

@@ -6,11 +6,20 @@ using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The <see cref="PuzzleState"/> of a puzzle that requires a specific state to be solved.
/// </summary>
public class StatePuzzle : PuzzleState
{
[Tooltip("The state this puzzle starts at.")]
[BoxGroup("State Puzzle")]
[SerializeField]
protected List<int> states, solution;
protected List<int> states;
[Tooltip("The state that needs to be reached for this puzzle to be solved.")]
[BoxGroup("State Puzzle")]
[SerializeField]
protected List<int> solution;
[Tooltip("Set this to the total number of states this puzzle has.")]
[BoxGroup("State Puzzle")]
[SerializeField]
[ValidateInput("CorrectStateCount", "States count must be equal to the number of states and the length of the solution.")]
@@ -76,7 +85,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
}
}
[UsedImplicitly]
[UsedImplicitly] // used for field validation
private bool CorrectStateCount(int count) =>
states != null && count == states.Count &&
solution != null && count == solution.Count;

View File

@@ -6,12 +6,16 @@ using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
/// <summary>
/// The <see cref="PuzzleState"/> of a puzzle that includes a number of steps that need to be completed to solve it.
/// </summary>
public abstract class StepPuzzle : PuzzleState
{
[BoxGroup("Step Puzzle")]
[InfoBox("In easy mode, the step puzzle will not reset if a wrong input is made.")]
public bool easyMode;
[BoxGroup("Step Puzzle")] [Min(0)] public int totalSteps;
[BoxGroup("Step Puzzle")] [Min(0)]
public int totalSteps;
[BoxGroup("Step Puzzle")] [ProgressBar("Step", "totalSteps", EColor.Orange)]
public int currentStep;