Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UILinkPage.cs
Go to the documentation of this file.
1using System;
3
4namespace Terraria.UI.Gamepad;
5
6public class UILinkPage
7{
8 public int ID;
9
10 public int PageOnLeft = -1;
11
12 public int PageOnRight = -1;
13
14 public int DefaultPoint;
15
16 public int CurrentPoint;
17
19
21
22 public event Action TravelEvent;
23
24 public event Action LeaveEvent;
25
26 public event Action EnterEvent;
27
28 public event Action UpdateEvent;
29
31
33
35
37
38 public UILinkPage()
39 {
40 }
41
42 public UILinkPage(int id)
43 {
44 ID = id;
45 }
46
47 public void Update()
48 {
49 if (this.UpdateEvent != null)
50 {
51 this.UpdateEvent();
52 }
53 }
54
55 public void Leave()
56 {
57 if (this.LeaveEvent != null)
58 {
59 this.LeaveEvent();
60 }
61 }
62
63 public void Enter()
64 {
65 if (this.EnterEvent != null)
66 {
67 this.EnterEvent();
68 }
69 }
70
71 public bool IsValid()
72 {
73 if (this.IsValidEvent != null)
74 {
75 return this.IsValidEvent();
76 }
77 return true;
78 }
79
80 public bool CanEnter()
81 {
82 if (this.CanEnterEvent != null)
83 {
84 return this.CanEnterEvent();
85 }
86 return true;
87 }
88
89 public void TravelUp()
90 {
91 Travel(LinkMap[CurrentPoint].Up);
92 }
93
94 public void TravelDown()
95 {
97 }
98
99 public void TravelLeft()
100 {
102 }
103
104 public void TravelRight()
105 {
107 }
108
109 public void SwapPageLeft()
110 {
111 if (this.OnPageMoveAttempt != null)
112 {
113 this.OnPageMoveAttempt(-1);
114 }
116 }
117
118 public void SwapPageRight()
119 {
120 if (this.OnPageMoveAttempt != null)
121 {
122 this.OnPageMoveAttempt(1);
123 }
125 }
126
127 private void Travel(int next)
128 {
129 if (next < 0)
130 {
131 if (this.ReachEndEvent != null)
132 {
133 this.ReachEndEvent(CurrentPoint, next);
134 if (this.TravelEvent != null)
135 {
136 this.TravelEvent();
137 }
138 }
139 }
140 else
141 {
143 if (this.TravelEvent != null)
144 {
145 this.TravelEvent();
146 }
147 }
148 }
149
150 public string SpecialInteractions()
151 {
152 if (this.OnSpecialInteracts != null)
153 {
154 return this.OnSpecialInteracts();
155 }
156 return string.Empty;
157 }
158}
Action< int, int > ReachEndEvent
Definition UILinkPage.cs:20
Dictionary< int, UILinkPoint > LinkMap
Definition UILinkPage.cs:18
Func< string > OnSpecialInteracts
Definition UILinkPage.cs:36