47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
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
|
|
{
|
|
get
|
|
{
|
|
if (State is DoorState doorState)
|
|
{
|
|
return doorState;
|
|
}
|
|
|
|
throw new Exception("DoorModule must contain a DoorState");
|
|
}
|
|
}
|
|
|
|
internal DoorModule(Space space, DoorModuleDescription description) : base(space, description)
|
|
{
|
|
srDimensions.Size = Vector2Int.one; // door always has size 1x1
|
|
}
|
|
|
|
internal override void InstantiateModule(Transform parent)
|
|
{
|
|
base.InstantiateModule(parent);
|
|
|
|
space.room.AddDoor(this);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{(IsEntrance ? "Entrance" : IsExit ? "Exit" : "Unknown")} door";
|
|
}
|
|
}
|
|
} |