11using System ;
22using System . Collections . Generic ;
33using UnityEngine ;
4+ using UnityEngine . Serialization ;
45
56namespace Descant . Editor
67{
@@ -139,6 +140,11 @@ public class DescantConnectionData
139140 /// </summary>
140141 public int FromID ;
141142
143+ /// <summary>
144+ /// The index of the port that this connection is coming from (base 1)
145+ /// </summary>
146+ public int FromIndex ;
147+
142148 /// <summary>
143149 /// The name of the node the connection is going to
144150 /// </summary>
@@ -148,11 +154,6 @@ public class DescantConnectionData
148154 /// The ID of the node the connection is going to
149155 /// </summary>
150156 public int ToID ;
151-
152- /// <summary>
153- /// The index of the port that this connection is coming from (base 1 for ChoiceNodes and ResponseNodes)
154- /// </summary>
155- public int ChoiceIndex ;
156157
157158 /// <summary>
158159 /// Parameterized constructor
@@ -161,31 +162,29 @@ public class DescantConnectionData
161162 /// <param name="fromID">The ID of the node the connection is coming from</param>
162163 /// <param name="to">The name of the node the connection is going to</param>
163164 /// <param name="toID">The ID of the node the connection is going to</param>
164- /// <param name="choiceIndex ">
165+ /// <param name="fromIndex ">
165166 /// The index of the port that this connection is coming from (base 1 for ChoiceNodes and ResponseNodes)
166167 /// </param>
167- public DescantConnectionData ( string from , int fromID , string to , int toID , int choiceIndex = 0 )
168+ public DescantConnectionData ( string from , int fromID , string to , int toID , int fromIndex = 0 )
168169 {
169170 From = from ;
170171 FromID = fromID ;
172+ FromIndex = fromIndex ;
171173 To = to ;
172174 ToID = toID ;
173- ChoiceIndex = choiceIndex ;
174175 }
175176
176177 /// <summary>
177- /// Checks to make sure that the connection isn't an illegal one coming from a Choice node's input port
178+ /// Checks to make sure that the connection isn't an illegal one coming from a Choice or If node's input port
178179 /// </summary>
179- /// <returns>Whether this connection is illegally coming from a Choice node's input port</returns>
180- public bool IllegalChoiceFrom ( )
180+ public bool IllegalChoiceOrIf ( )
181181 {
182- return From . Trim ( ) == "Choice" && ChoiceIndex == 0 ;
182+ return ( From . Equals ( "Choice" ) || From . Equals ( "If" ) ) && FromIndex == 0 ;
183183 }
184184
185185 /// <summary>
186186 /// Determines whether the connection points to itself
187187 /// </summary>
188- /// <returns></returns>
189188 public bool ToItself ( )
190189 {
191190 return From == To && FromID == ToID ;
@@ -212,7 +211,7 @@ public override bool Equals(object other)
212211
213212 public override int GetHashCode ( )
214213 {
215- return HashCode . Combine ( From , FromID , To , ToID , ChoiceIndex ) ;
214+ return HashCode . Combine ( From , FromID , FromIndex , To , ToID ) ;
216215 }
217216
218217 #if UNITY_EDITOR
@@ -225,8 +224,8 @@ public bool Equals(DescantConnectionData other)
225224 {
226225 return
227226 From == other . From && FromID == other . FromID &&
228- To == other . To && ToID == other . ToID &&
229- ChoiceIndex == other . ChoiceIndex ;
227+ FromIndex == other . FromIndex &&
228+ To == other . To && ToID == other . ToID ;
230229 }
231230 #endif
232231
@@ -235,7 +234,7 @@ public bool Equals(DescantConnectionData other)
235234 /// </summary>
236235 public override string ToString ( )
237236 {
238- return GetType ( ) + " (" + FromID + From + " " + ToID + To + " " + ChoiceIndex + ")" ;
237+ return GetType ( ) + " (" + FromID + From + " " + FromIndex + " " + ToID + To + ")" ;
239238 }
240239 }
241240
0 commit comments