@@ -79,7 +79,7 @@ function noAngleFetcher(connection, master, start, end) {
79
79
return 0 ;
80
80
}
81
81
82
- function interpolatedAngleFetcher ( connection , master , start , end ) {
82
+ function interpolatedAngleFetcher ( connection , master , dstMaster , start , end ) {
83
83
var index = - 1 ;
84
84
var totalPoints = connection . angles . length / 2 ;
85
85
var time = animator . reactiveDataStatus . time ;
@@ -110,19 +110,35 @@ function interpolatedAngleFetcher(connection, master, start, end) {
110
110
}
111
111
}
112
112
113
- function staticAngleFetcher ( connection , master , start , end ) {
113
+ function staticAngleFetcher ( connection , master , dstMaster , start , end ) {
114
114
var time = animator . reactiveDataStatus . time ;
115
115
var velocity = Math . min ( ( time - start ) / ( end - start ) , 1.0 ) ;
116
116
return connection . angles [ 0 ] + velocity * connection . angles [ 1 ] ;
117
117
}
118
118
119
- function masterRotationFetcher ( connection , master , start , end ) {
119
+ function masterRotationFetcher ( connection , master , dstMaster , start , end ) {
120
120
if ( ! master ) {
121
121
return null ;
122
122
}
123
123
return master . getRotation ( ) ;
124
124
}
125
125
126
+ function masterToMasterRotationFetcher ( connection , master , dstMaster , start , end ) {
127
+ if ( ! master || ! dstMaster ) {
128
+ return null ;
129
+ }
130
+ var origin = master . getPosition ( ) ;
131
+ var dst = dstMaster . getPosition ( ) ;
132
+ if ( ! origin || ! dst ) {
133
+ return null ;
134
+ }
135
+ var vector = {
136
+ x : dst . x - origin . x ,
137
+ y : dst . y - origin . y ,
138
+ }
139
+ return - ToDegrees ( Math . atan2 ( vector . y , vector . x ) ) ;
140
+ }
141
+
126
142
const RotationOffsetMode = {
127
143
addToMaster : 0 ,
128
144
absoluteOrientation : 1 ,
@@ -155,6 +171,8 @@ class MechanicDrawable {
155
171
this . rotationConnectedTo = interpolatedAngleFetcher ;
156
172
} else if ( rotationConnectedTo . angles ) {
157
173
this . rotationFetcher = staticAngleFetcher ;
174
+ } else if ( rotationConnectedTo . dstMasterId ) {
175
+ this . rotationFetcher = masterToMasterRotationFetcher ;
158
176
} else if ( rotationConnectedTo . masterId ) {
159
177
this . rotationFetcher = masterRotationFetcher ;
160
178
this . rotationOffset = rotationConnectedTo . rotationOffset ;
@@ -163,6 +181,7 @@ class MechanicDrawable {
163
181
}
164
182
this . master = null ;
165
183
this . rotationMaster = null ;
184
+ this . dstRotationMaster = null ;
166
185
// Skill mode
167
186
this . ownerID = null ;
168
187
this . owner = null ;
@@ -193,7 +212,7 @@ class MechanicDrawable {
193
212
if ( this . start !== - 1 && ( this . start > time || this . end < time ) ) {
194
213
return null ;
195
214
}
196
- return this . rotationFetcher ( this . rotationConnectedTo , this . rotationMaster , this . start , this . end ) ;
215
+ return this . rotationFetcher ( this . rotationConnectedTo , this . rotationMaster , this . dstRotationMaster , this . start , this . end ) ;
197
216
}
198
217
199
218
getPosition ( ) {
@@ -242,14 +261,23 @@ class MechanicDrawable {
242
261
return false ;
243
262
}
244
263
}
245
- if ( this . rotationFetcher === masterRotationFetcher ) {
264
+ if ( this . rotationFetcher === masterRotationFetcher || this . rotationFetcher === masterToMasterRotationFetcher ) {
246
265
if ( this . rotationMaster === null ) {
247
266
let masterId = this . rotationConnectedTo . masterId ;
248
267
this . rotationMaster = animator . getActorData ( masterId ) ;
249
268
}
250
269
if ( ! this . rotationMaster || ( ! this . rotationMaster . canDraw ( ) && ! this . ownerID ) ) {
251
270
return false ;
252
271
}
272
+ if ( this . rotationFetcher === masterToMasterRotationFetcher ) {
273
+ if ( this . dstRotationMaster === null ) {
274
+ let dstMasterId = this . rotationConnectedTo . dstMasterId ;
275
+ this . dstRotationMaster = animator . getActorData ( dstMasterId ) ;
276
+ }
277
+ if ( ! this . dstRotationMaster || ( ! this . dstRotationMaster . canDraw ( ) && ! this . ownerID ) ) {
278
+ return false ;
279
+ }
280
+ }
253
281
}
254
282
if ( this . ownerID !== null ) {
255
283
if ( this . owner === null ) {
0 commit comments