LethalCompany/Lethal Company/ExportedProject/Assets/Scripts/Assembly-CSharp/DunGen/Door.cs

92 lines
1.3 KiB
C#
Raw Normal View History

2023-12-22 22:51:17 +00:00
using System;
using UnityEngine;
namespace DunGen
{
[Serializable]
public class Door : MonoBehaviour
{
public delegate void DoorStateChangedDelegate(Door door, bool isOpen);
[HideInInspector]
public Dungeon Dungeon;
[HideInInspector]
public Doorway DoorwayA;
[HideInInspector]
public Doorway DoorwayB;
[HideInInspector]
public Tile TileA;
[HideInInspector]
public Tile TileB;
[SerializeField]
private bool dontCullBehind;
[SerializeField]
private bool isOpen;
public bool DontCullBehind
{
get
{
return dontCullBehind;
}
set
{
if (dontCullBehind != value)
{
dontCullBehind = value;
SetDoorState(isOpen);
}
}
}
public bool ShouldCullBehind
{
get
{
if (DontCullBehind)
{
return false;
}
return !isOpen;
}
}
public virtual bool IsOpen
{
get
{
return isOpen;
}
set
{
if (isOpen != value)
{
SetDoorState(value);
}
}
}
public event DoorStateChangedDelegate OnDoorStateChanged;
private void OnDestroy()
{
this.OnDoorStateChanged = null;
}
public void SetDoorState(bool isOpen)
{
this.isOpen = isOpen;
if (this.OnDoorStateChanged != null)
{
this.OnDoorStateChanged(this, isOpen);
}
}
}
}