Files
VOIDRPG/Assets/90 - Scripts/Generic/World/AreaConnection.cs
T
2026-07-09 21:33:33 +02:00

47 lines
1.4 KiB
C#

using System;
using System.Collections;
using System.Linq;
using Sirenix.OdinInspector;
using VOID.Generic.Dict;
using VOID.ScriptableObjects.World;
namespace VOID.Generic.World
{
[Serializable]
public class AreaConnection
{
[HorizontalGroup("Row1")]
[ReadOnly]
public Direction2D direction;
[HorizontalGroup("Row1")]
[DisableIf(nameof(type), AreaConnectionType.Inner)]
[OnValueChanged(nameof(OnConnectionTypeChange))]
[ValueDropdown(nameof(GetConnectionTypes))]
public AreaConnectionType type;
[HorizontalGroup("Row2")]
[DisableIf(nameof(IsNotEditable))]
public AreaConnectionTag tag;
[HorizontalGroup("Row2")]
[DisableIf(nameof(IsNotEditable))]
[MinValue(0)]
public int floor;
private void OnConnectionTypeChange()
{
if (IsNotEditable())
{
tag = null;
floor = 0;
}
}
private bool IsNotEditable() => type is AreaConnectionType.Inner or AreaConnectionType.None;
private IEnumerable GetConnectionTypes() => Enum.GetValues(typeof(AreaConnectionType)).Cast<AreaConnectionType>()
.Where(ct => ct != AreaConnectionType.Inner)
.Select(ct => new ValueDropdownItem(Enum.GetName(typeof(AreaConnectionType), ct), (int)ct));
}
}