TileConnectionRule.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. namespace DunGen
  3. {
  4. public sealed class TileConnectionRule
  5. {
  6. /// <summary>
  7. /// The result of evaluating a TileConnectionRule
  8. /// </summary>
  9. public enum ConnectionResult
  10. {
  11. /// <summary>
  12. /// The connection is allowed
  13. /// </summary>
  14. Allow,
  15. /// <summary>
  16. /// The connection is not allowed
  17. /// </summary>
  18. Deny,
  19. /// <summary>
  20. /// Let any lower priority rules decide whether this connection is allowed or not
  21. /// </summary>
  22. Passthrough,
  23. }
  24. public delegate ConnectionResult CanTilesConnectDelegate(Tile previousTile, Tile nextTile, Doorway previousDoorway, Doorway nextDoorway);
  25. public delegate ConnectionResult TileConnectionDelegate(ProposedConnection connection);
  26. /// <summary>
  27. /// This rule's prioty. Higher priority rules are evaluated first. Lower priority rules are
  28. /// only evaluated if the delegate returns 'Passthrough' as the result
  29. /// </summary>
  30. public int Priority = 0;
  31. /// <summary>
  32. /// The delegate to evaluate to determine if two tiles can connect using a given doorway pairing.
  33. /// Returning 'Passthrough' will allow lower priority rules to evaluate. If no rule handles the connection,
  34. /// the default method is used (only matching doorways are allowed to connect).
  35. /// </summary>
  36. [Obsolete("Use ConnectionDelegate instead")]
  37. public CanTilesConnectDelegate Delegate;
  38. /// <summary>
  39. /// The delegate to evaluate to determine if two tiles can connect using a given doorway pairing.
  40. /// Returning 'Passthrough' will allow lower priority rules to evaluate. If no rule handles the connection,
  41. /// the default method is used (only matching doorways are allowed to connect).
  42. /// </summary>
  43. public TileConnectionDelegate ConnectionDelegate;
  44. [Obsolete("Use the constructor that takes a delegate of type 'TileConnectionDelegate' instead")]
  45. public TileConnectionRule(CanTilesConnectDelegate connectionDelegate, int priority = 0)
  46. {
  47. Delegate = connectionDelegate;
  48. Priority = priority;
  49. }
  50. public TileConnectionRule(TileConnectionDelegate connectionDelegate, int priority = 0)
  51. {
  52. ConnectionDelegate = connectionDelegate;
  53. Priority = priority;
  54. }
  55. }
  56. }