DoorwaySocket.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using UnityEngine;
  3. namespace DunGen
  4. {
  5. /// <summary>
  6. /// LEGACY - This used to determine which doorways could connect
  7. /// It now exists only to allow DunGen to attempt to update to the new system
  8. /// </summary>
  9. public enum DoorwaySocketType
  10. {
  11. Default,
  12. Large,
  13. Vertical,
  14. }
  15. public delegate bool SocketConnectionDelegate(DoorwaySocket a, DoorwaySocket b);
  16. /// <summary>
  17. /// A class used to determine which doorways can connect to one another
  18. /// </summary>
  19. [CreateAssetMenu(fileName = "New Doorway Socket", menuName = "DunGen/Doorway Socket", order = 700)]
  20. public class DoorwaySocket : ScriptableObject
  21. {
  22. public Vector2 Size { get { return size; } }
  23. [SerializeField]
  24. private Vector2 size = new Vector2(1, 2);
  25. #region Static Methods
  26. [Obsolete("Use DoorwayPairFinder.CustomConnectionRules instead")]
  27. public static SocketConnectionDelegate CustomSocketConnectionDelegate = null;
  28. /// <summary>
  29. /// Checks if two doorway sockets can connect
  30. /// </summary>
  31. public static bool CanSocketsConnect(DoorwaySocket a, DoorwaySocket b)
  32. {
  33. #pragma warning disable 0618
  34. if (CustomSocketConnectionDelegate != null)
  35. return CustomSocketConnectionDelegate(a, b);
  36. else
  37. return a == b; // By default, sockets can only connect if they match
  38. #pragma warning restore 0618
  39. }
  40. #endregion
  41. }
  42. }