References.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using UnityEngine;
  3. namespace DunGen.Graph
  4. {
  5. [Serializable]
  6. public abstract class FlowGraphObjectReference
  7. {
  8. public DungeonFlow Flow { get { return flow; } }
  9. [SerializeField]
  10. protected DungeonFlow flow;
  11. [SerializeField]
  12. protected int index;
  13. }
  14. [Serializable]
  15. public sealed class FlowNodeReference : FlowGraphObjectReference
  16. {
  17. public GraphNode Node
  18. {
  19. get { return flow.Nodes[index]; }
  20. set { index = flow.Nodes.IndexOf(value); }
  21. }
  22. public FlowNodeReference(DungeonFlow flowGraph, GraphNode node)
  23. {
  24. Debug.Assert(flowGraph != null);
  25. Debug.Assert(node != null);
  26. flow = flowGraph;
  27. Node = node;
  28. }
  29. }
  30. [Serializable]
  31. public sealed class FlowLineReference : FlowGraphObjectReference
  32. {
  33. public GraphLine Line
  34. {
  35. get { return flow.Lines[index]; }
  36. set { index = flow.Lines.IndexOf(value); }
  37. }
  38. public FlowLineReference(DungeonFlow flowGraph, GraphLine line)
  39. {
  40. Debug.Assert(flowGraph != null);
  41. Debug.Assert(line != null);
  42. flow = flowGraph;
  43. Line = line;
  44. }
  45. }
  46. }