PuzzleMeasurement, add Realm, door ExitedFrom event

This commit is contained in:
2022-12-05 18:11:00 +01:00
parent 5449283e5d
commit b776e6744e
34 changed files with 344 additions and 63 deletions

View File

@@ -5,7 +5,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
{
public enum DoorEventType
{
Locked, Unlocked, Connected
Locked, Unlocked, Connected, ExitedFrom
}
public delegate void DoorEventHandler(DoorModule source, DoorEventType e);
@@ -31,7 +31,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
private bool _unlocked;
private void OnDoorEvent(DoorEventType type)
protected void OnDoorEvent(DoorEventType type)
{
Logger.Log($"{Module} has been {type}", LogType.PuzzleFlow);
@@ -52,6 +52,9 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
[Button(enabledMode: EButtonEnableMode.Playmode)]
internal void Lock() => Unlocked = false;
[Button(enabledMode: EButtonEnableMode.Playmode)]
internal void ExitFrom() => OnDoorEvent(DoorEventType.ExitedFrom);
#endregion

View File

@@ -9,5 +9,12 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
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;
public int Id => puzzleName.GetHashCode() + puzzleVersion;
public override string ToString()
{
return $"{puzzleName} v{puzzleVersion} ({Id})";
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using EscapeRoomEngine.Engine.Runtime.Measurements;
using EscapeRoomEngine.Engine.Runtime.Utilities;
using NaughtyAttributes;
using UnityEngine;
@@ -53,6 +54,14 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
protected virtual void Start()
{
OnPuzzleEvent(PuzzleEventType.Restarted);
PuzzleEvent += (_, type) =>
{
if (type == PuzzleEventType.Solved)
{
Measure.Solve((PuzzleModuleDescription)Module.description);
}
};
}
private void OnPuzzleEvent(PuzzleEventType type)

View File

@@ -0,0 +1,10 @@
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
internal class Spawn : DoorState
{
private void Start()
{
ExitFrom();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 404f750726904ea98f8a85feaca0df66
timeCreated: 1670779750