Misc updates/fixes

This commit is contained in:
hondacrx
2022-01-27 12:36:56 -05:00
parent 169abc1531
commit 6c0e21b4de
36 changed files with 415 additions and 354 deletions
@@ -52,14 +52,24 @@ namespace Game.Movement
owner.CombatStopWithPets();
owner.AddUnitFlag(UnitFlags.RemoveClientControl | UnitFlags.TaxiFlight);
MoveSplineInit init = new(owner);
uint end = GetPathAtMapEnd();
init.args.path = new Vector3[end];
for (int i = (int)GetCurrentNode(); i != end; ++i)
uint currentNodeId = GetCurrentNode();
if (currentNodeId == end)
{
Log.outDebug(LogFilter.Movement, $"FlightPathMovementGenerator::DoReset: trying to start a flypath from the end point. {owner.GetDebugInfo()}");
return;
}
MoveSplineInit init = new(owner);
// Providing a starting vertex since the taxi paths do not provide such
init.Path().Add(new Vector3(owner.GetPositionX(), owner.GetPositionY(), owner.GetPositionZ()));
for (int i = (int)currentNodeId; i != (uint)end; ++i)
{
Vector3 vertice = new(_path[i].Loc.X, _path[i].Loc.Y, _path[i].Loc.Z);
init.args.path[i] = vertice;
init.Path().Add(vertice);
}
init.SetFirstPointId((int)GetCurrentNode());
init.SetFly();
init.SetSmooth();
+4 -5
View File
@@ -798,11 +798,10 @@ namespace Game.Movement
MoveSplineInit init = new(_owner);
init.args.path = new Vector3[stepCount + 1];
// add the owner's current position as starting point as it gets removed after entering the cycle
init.args.path[0] = new Vector3(_owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ());
for (byte i = 1; i < stepCount; angle += step, ++i)
init.Path().Add(new Vector3(_owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ()));
for (byte i = 0; i < stepCount; angle += step, ++i)
{
Vector3 point = new();
point.X = (float)(x + radius * Math.Cos(angle));
@@ -813,7 +812,7 @@ namespace Game.Movement
else
point.Z = _owner.GetMapHeight(point.X, point.Y, z) + _owner.GetHoverOffset();
init.args.path[i] = point;
init.Path().Add(point);
}
if (_owner.IsFlying())
+4 -4
View File
@@ -52,7 +52,7 @@ namespace Game.Movement
effect_start_time = 0;
spell_effect_extra = args.spellEffectExtra;
anim_tier = args.animTier;
splineIsFacingOnly = args.path.Length == 2 && args.facing.type != MonsterMoveType.Normal && ((args.path[1] - args.path[0]).Length() < 0.1f);
splineIsFacingOnly = args.path.Count == 2 && args.facing.type != MonsterMoveType.Normal && ((args.path[1] - args.path[0]).Length() < 0.1f);
// Check if its a stop spline
if (args.flags.HasFlag(SplineFlag.Done))
@@ -91,11 +91,11 @@ namespace Game.Movement
int cyclic_point = 0;
if (splineflags.HasFlag(SplineFlag.EnterCycle))
cyclic_point = 1; // shouldn't be modified, came from client
spline.InitCyclicSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())], cyclic_point, args.initialOrientation);
spline.InitCyclicSpline(args.path.ToArray(), args.path.Count, modes[Convert.ToInt32(args.flags.IsSmooth())], cyclic_point, args.initialOrientation);
}
else
{
spline.InitSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())], args.initialOrientation);
spline.InitSpline(args.path.ToArray(), args.path.Count, modes[Convert.ToInt32(args.flags.IsSmooth())], args.initialOrientation);
}
// init spline timestamps
@@ -298,7 +298,7 @@ namespace Game.Movement
splineflags.SetUnsetFlag(SplineFlag.EnterCycle, false);
MoveSplineInitArgs args = new(spline.GetPointCount());
args.path = spline.GetPoints().AsSpan().Slice(spline.First() + 1, spline.Last()).ToArray();
args.path.AddRange(spline.GetPoints().AsSpan().Slice(spline.First() + 1, spline.Last()).ToArray());
args.facing = facing;
args.flags = splineflags;
args.path_Idx_offset = point_Idx_offset;
+6 -6
View File
@@ -19,6 +19,7 @@ using Framework.Constants;
using Game.Entities;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Numerics;
namespace Game.Movement
@@ -94,7 +95,7 @@ namespace Game.Movement
}
// should i do the things that user should do? - no.
if (args.path.Length == 0)
if (args.path.Count == 0)
return 0;
// correct first vertex
@@ -246,9 +247,9 @@ namespace Game.Movement
}
args.path_Idx_offset = 0;
args.path = new Vector3[2];
args.path.Add(default);
TransportPathTransform transform = new(unit, args.TransformForTransport);
args.path[1] = transform.Calc(dest);
args.path.Add(transform.Calc(dest));
}
public void SetFall()
@@ -282,10 +283,9 @@ namespace Game.Movement
public void MovebyPath(Vector3[] controls, int path_offset = 0)
{
args.path_Idx_offset = path_offset;
args.path = new Vector3[controls.Length];
TransportPathTransform transform = new(unit, args.TransformForTransport);
for (var i = 0; i < controls.Length; i++)
args.path[i] = transform.Calc(controls[i]);
args.path.Add(transform.Calc(controls[i]));
}
@@ -333,7 +333,7 @@ namespace Game.Movement
args.spellEffectExtra.Set(spellEffectExtraData);
}
public Vector3[] Path() { return args.path; }
public List<Vector3> Path() { return args.path; }
public MoveSplineInitArgs args = new();
Unit unit;
+5 -5
View File
@@ -17,6 +17,7 @@
using Framework.Dynamic;
using Game.Entities;
using System.Collections.Generic;
using System.Numerics;
namespace Game.Movement
@@ -33,10 +34,9 @@ namespace Game.Movement
initialOrientation = 0.0f;
HasVelocity = false;
TransformForTransport = true;
path = new Vector3[path_capacity];
}
public Vector3[] path;
public List<Vector3> path = new();
public FacingInfo facing = new();
public MoveSplineFlag flags = new();
public int path_Idx_offset;
@@ -65,7 +65,7 @@ namespace Game.Movement
return true;
}
if (!CHECK(path.Length > 1))
if (!CHECK(path.Count > 1))
return false;
if (!CHECK(velocity >= 0.01f))
return false;
@@ -78,8 +78,8 @@ namespace Game.Movement
bool _checkPathLengths()
{
if (path.Length > 2 || facing.type == Framework.Constants.MonsterMoveType.Normal)
for (uint i = 0; i < path.Length - 1; ++i)
if (path.Count > 2 || facing.type == Framework.Constants.MonsterMoveType.Normal)
for (int i = 0; i < path.Count - 1; ++i)
if ((path[i + 1] - path[i]).Length() < 0.1f)
return false;
return true;