PuzzleMeasurement, add Realm, door ExitedFrom event
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
10
Assets/Engine/Runtime/Modules/Spawn.cs
Normal file
10
Assets/Engine/Runtime/Modules/Spawn.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
{
|
||||
internal class Spawn : DoorState
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
ExitFrom();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Engine/Runtime/Modules/Spawn.cs.meta
Normal file
3
Assets/Engine/Runtime/Modules/Spawn.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 404f750726904ea98f8a85feaca0df66
|
||||
timeCreated: 1670779750
|
||||
Reference in New Issue
Block a user