44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System;
|
|
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
|
using UnityEngine;
|
|
|
|
namespace EscapeRoomEngine.Engine.Runtime.Modules
|
|
{
|
|
public enum DoorType
|
|
{
|
|
Entrance = ModuleType.DoorEntrance, Exit = ModuleType.DoorExit
|
|
}
|
|
|
|
[Serializable]
|
|
public class DoorModule : Module
|
|
{
|
|
public bool IsEntrance => IsType((ModuleType)DoorType.Entrance);
|
|
public bool IsExit => IsType((ModuleType)DoorType.Exit);
|
|
|
|
internal DoorState DoorState => DoorState.FromState(State);
|
|
|
|
internal DoorModule(Space space, DoorModuleDescription description) : base(space, description) {}
|
|
|
|
internal override void InstantiateModule(Transform parent)
|
|
{
|
|
base.InstantiateModule(parent);
|
|
|
|
space.room.AddDoor(this);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{(IsEntrance ? "Entrance" : IsExit ? "Exit" : "Unknown")} door";
|
|
}
|
|
|
|
public static DoorModule FromModule(Module module)
|
|
{
|
|
if (module is DoorModule doorModule)
|
|
{
|
|
return doorModule;
|
|
}
|
|
|
|
throw new WrongTypeException(typeof(DoorModule), module.GetType(), typeof(Module));
|
|
}
|
|
}
|
|
} |