Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
EliphasNUIT committed Sep 1, 2024
1 parent 121fd74 commit 8bd79e0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 36 deletions.
81 changes: 46 additions & 35 deletions GW2EIEvtcParser/EIData/Actors/AbstractSingleActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,25 @@ protected void SetMovements(ParsedEvtcLog log)
}
}

public bool HasPositions(ParsedEvtcLog log)
{
return GetCombatReplayNonPolledPositions(log).Count > 0;
}

public bool HasCombatReplayPositions(ParsedEvtcLog log)
{
return GetCombatReplayNonPolledPositions(log).Count > 0 && GetCombatReplayPolledPositions(log).Count > 0;
return HasPositions(log) && GetCombatReplayPolledPositions(log).Count > 0;
}


public bool HasRotations(ParsedEvtcLog log)
{
return GetCombatReplayNonPolledRotations(log).Count > 0;
}

public bool HasCombatReplayRotations(ParsedEvtcLog log)
{
return HasRotations(log) && GetCombatReplayPolledRotations(log).Count > 0;
}

public IReadOnlyList<ParametricPoint3D> GetCombatReplayNonPolledPositions(ParsedEvtcLog log)
Expand Down Expand Up @@ -648,7 +664,24 @@ protected virtual void InitAdditionalCombatReplayData(ParsedEvtcLog log)

public abstract AbstractSingleActorCombatReplayDescription GetCombatReplayDescription(CombatReplayMap map, ParsedEvtcLog log);


private Point3D GetCurrentPoint(IReadOnlyList<ParametricPoint3D> points, ParsedEvtcLog log, long time, long forwardWindow = 0)
{
if (forwardWindow != 0)
{
return points.FirstOrDefault(x => x.Time >= time && x.Time <= time + forwardWindow) ?? points.LastOrDefault(x => x.Time <= time);
}
int foundIndex = BinarySearchRecursive(points, time, 0, points.Count - 1);
if (foundIndex < 0)
{
return null;
}
ParametricPoint3D position = points[foundIndex];
if (position.Time > time)
{
return null;
}
return points[foundIndex];
}

/// <summary>
///
Expand All @@ -661,24 +694,13 @@ public Point3D GetCurrentPosition(ParsedEvtcLog log, long time, long forwardWind
{
if (!HasCombatReplayPositions(log))
{
if (HasPositions(log))
{
return GetCurrentPoint(GetCombatReplayNonPolledPositions(log), log, time, forwardWindow);
}
return null;
}
IReadOnlyList<ParametricPoint3D> positions = GetCombatReplayPolledPositions(log);
if (forwardWindow != 0)
{
return positions.FirstOrDefault(x => x.Time >= time && x.Time <= time + forwardWindow) ?? positions.LastOrDefault(x => x.Time <= time);
}
int foundIndex = BinarySearchRecursive(positions, time, 0, positions.Count - 1);
if (foundIndex < 0)
{
return null;
}
ParametricPoint3D position = positions[foundIndex];
if (position.Time > time)
{
return null;
}
return positions[foundIndex];
return GetCurrentPoint(GetCombatReplayPolledPositions(log), log, time, forwardWindow);
}

public Point3D GetCurrentInterpolatedPosition(ParsedEvtcLog log, long time)
Expand Down Expand Up @@ -720,26 +742,15 @@ public Point3D GetCurrentInterpolatedPosition(ParsedEvtcLog log, long time)
/// <returns></returns>
public Point3D GetCurrentRotation(ParsedEvtcLog log, long time, long forwardWindow = 0)
{
IReadOnlyList<ParametricPoint3D> rotations = GetCombatReplayPolledRotations(log);
if (!rotations.Any())
{
return null;
}
if (forwardWindow != 0)
{
return rotations.FirstOrDefault(x => x.Time >= time && x.Time <= time + forwardWindow) ?? rotations.LastOrDefault(x => x.Time <= time);
}
int foundIndex = BinarySearchRecursive(rotations, time, 0, rotations.Count - 1);
if (foundIndex < 0)
{
return null;
}
ParametricPoint3D rotation = rotations[foundIndex];
if (rotation.Time > time)
if (!HasCombatReplayRotations(log))
{
if (HasRotations(log))
{
return GetCurrentPoint(GetCombatReplayNonPolledRotations(log), log, time, forwardWindow);
}
return null;
}
return rotations[foundIndex];
return GetCurrentPoint(GetCombatReplayPolledRotations(log), log, time, forwardWindow);
}

#endregion COMBAT REPLAY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private void AddGlobuleDecorations(ParsedEvtcLog log)
AnimatedCastEvent lastCast = eparchCasts.LastOrDefault(x => x.Time < spawn.Time - globuleDelay);
if (lastCast != null && globuleColors.TryGetValue(lastCast.SkillId, out Color color))
{
ParametricPoint3D position = log.FindActor(gadget).GetCombatReplayNonPolledPositions(log).LastOrDefault();
Point3D position = gadget.GetCurrentPosition(log, gadget.LastAware);
if (position != null)
{
(long, long) lifespan = (spawn.Time, despawn.Time);
Expand Down

0 comments on commit 8bd79e0

Please sign in to comment.