Skip to content

Commit b3ff085

Browse files
committed
added AgentFacingAgentConnector
1 parent 6517520 commit b3ff085

File tree

3 files changed

+67
-5
lines changed

3 files changed

+67
-5
lines changed

GW2EIBuilders/Resources/JS/CR-JS/animator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ facingIcon.onload = function () {
3131
function ToRadians(degrees) {
3232
return degrees * (Math.PI / 180);
3333
}
34+
function ToDegrees(radians) {
35+
return radians / (Math.PI / 180);
36+
}
3437

3538
const resolutionMultiplier = 2.0;
3639

GW2EIBuilders/Resources/JS/CR-JS/decorations.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function noAngleFetcher(connection, master, start, end) {
7979
return 0;
8080
}
8181

82-
function interpolatedAngleFetcher(connection, master, start, end) {
82+
function interpolatedAngleFetcher(connection, master, dstMaster, start, end) {
8383
var index = -1;
8484
var totalPoints = connection.angles.length / 2;
8585
var time = animator.reactiveDataStatus.time;
@@ -110,19 +110,35 @@ function interpolatedAngleFetcher(connection, master, start, end) {
110110
}
111111
}
112112

113-
function staticAngleFetcher(connection, master, start, end) {
113+
function staticAngleFetcher(connection, master, dstMaster, start, end) {
114114
var time = animator.reactiveDataStatus.time;
115115
var velocity = Math.min((time - start) / (end - start), 1.0);
116116
return connection.angles[0] + velocity * connection.angles[1];
117117
}
118118

119-
function masterRotationFetcher(connection, master, start, end) {
119+
function masterRotationFetcher(connection, master, dstMaster, start, end) {
120120
if (!master) {
121121
return null;
122122
}
123123
return master.getRotation();
124124
}
125125

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+
126142
const RotationOffsetMode = {
127143
addToMaster: 0,
128144
absoluteOrientation: 1,
@@ -155,6 +171,8 @@ class MechanicDrawable {
155171
this.rotationConnectedTo = interpolatedAngleFetcher;
156172
} else if (rotationConnectedTo.angles) {
157173
this.rotationFetcher = staticAngleFetcher;
174+
} else if (rotationConnectedTo.dstMasterId) {
175+
this.rotationFetcher = masterToMasterRotationFetcher;
158176
} else if (rotationConnectedTo.masterId) {
159177
this.rotationFetcher = masterRotationFetcher;
160178
this.rotationOffset = rotationConnectedTo.rotationOffset;
@@ -163,6 +181,7 @@ class MechanicDrawable {
163181
}
164182
this.master = null;
165183
this.rotationMaster = null;
184+
this.dstRotationMaster = null;
166185
// Skill mode
167186
this.ownerID = null;
168187
this.owner = null;
@@ -193,7 +212,7 @@ class MechanicDrawable {
193212
if (this.start !== -1 && (this.start > time || this.end < time)) {
194213
return null;
195214
}
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);
197216
}
198217

199218
getPosition() {
@@ -242,14 +261,23 @@ class MechanicDrawable {
242261
return false;
243262
}
244263
}
245-
if (this.rotationFetcher === masterRotationFetcher) {
264+
if (this.rotationFetcher === masterRotationFetcher || this.rotationFetcher === masterToMasterRotationFetcher) {
246265
if (this.rotationMaster === null) {
247266
let masterId = this.rotationConnectedTo.masterId;
248267
this.rotationMaster = animator.getActorData(masterId);
249268
}
250269
if (!this.rotationMaster || (!this.rotationMaster.canDraw() && !this.ownerID)) {
251270
return false;
252271
}
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+
}
253281
}
254282
if (this.ownerID !== null) {
255283
if (this.owner === null) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using GW2EIEvtcParser.ParsedData;
2+
3+
namespace GW2EIEvtcParser.EIData
4+
{
5+
internal class AgentFacingAgentConnector : AgentFacingConnector
6+
{
7+
public AgentItem DstAgent { get; }
8+
9+
public AgentFacingAgentConnector(AbstractSingleActor agent, AbstractSingleActor dstAgent) : this(agent.AgentItem, dstAgent.AgentItem)
10+
{
11+
}
12+
13+
public AgentFacingAgentConnector(AgentItem agent, AgentItem dstAgent) : base(agent)
14+
{
15+
DstAgent = dstAgent;
16+
}
17+
public class AgentFacingAgentConnectorDescriptor : AgentFacingConnectorDescriptor
18+
{
19+
public int DstMasterId { get; private set; }
20+
public AgentFacingAgentConnectorDescriptor(AgentFacingAgentConnector connector, CombatReplayMap map) : base(connector, map)
21+
{
22+
DstMasterId = connector.DstAgent.UniqueID;
23+
}
24+
}
25+
26+
public override object GetConnectedTo(CombatReplayMap map, ParsedEvtcLog log)
27+
{
28+
return new AgentFacingAgentConnectorDescriptor(this, map);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)