Core/Movement: add a velocity argument for the spline chain meta table
Port From (https://github.com/TrinityCore/TrinityCore/commit/a24a5e77786266ee9456fa8c422a173168804a1f)
This commit is contained in:
@@ -91,7 +91,7 @@ namespace Game.Movement
|
|||||||
|
|
||||||
owner.AddUnitState(UnitState.RoamingMove);
|
owner.AddUnitState(UnitState.RoamingMove);
|
||||||
Span<Vector3> partial = thisLink.Points.ToArray();
|
Span<Vector3> partial = thisLink.Points.ToArray();
|
||||||
SendPathSpline(owner, partial[(_nextFirstWP - 1)..]);
|
SendPathSpline(owner, thisLink.Velocity, partial[(_nextFirstWP - 1)..]);
|
||||||
|
|
||||||
Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::Initialize: resumed spline chain generator from resume state. ({owner.GetGUID()})");
|
Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::Initialize: resumed spline chain generator from resume state. ({owner.GetGUID()})");
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ namespace Game.Movement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint SendPathSpline(Unit owner, Span<Vector3> path)
|
uint SendPathSpline(Unit owner, float velocity, Span<Vector3> path)
|
||||||
{
|
{
|
||||||
int nodeCount = path.Length;
|
int nodeCount = path.Length;
|
||||||
Cypher.Assert(nodeCount > 1, $"SplineChainMovementGenerator::SendPathSpline: Every path must have source & destination (size > 1)! ({owner.GetGUID()})");
|
Cypher.Assert(nodeCount > 1, $"SplineChainMovementGenerator::SendPathSpline: Every path must have source & destination (size > 1)! ({owner.GetGUID()})");
|
||||||
@@ -188,6 +188,10 @@ namespace Game.Movement
|
|||||||
init.MovebyPath(path.ToArray());
|
init.MovebyPath(path.ToArray());
|
||||||
else
|
else
|
||||||
init.MoveTo(path[1], false, true);
|
init.MoveTo(path[1], false, true);
|
||||||
|
|
||||||
|
if (velocity > 0.0f)
|
||||||
|
init.SetVelocity(velocity);
|
||||||
|
|
||||||
init.SetWalk(_walk);
|
init.SetWalk(_walk);
|
||||||
return (uint)init.Launch();
|
return (uint)init.Launch();
|
||||||
}
|
}
|
||||||
@@ -198,7 +202,7 @@ namespace Game.Movement
|
|||||||
Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::SendSplineFor: sending spline on index: {index}. ({owner.GetGUID()})");
|
Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::SendSplineFor: sending spline on index: {index}. ({owner.GetGUID()})");
|
||||||
|
|
||||||
SplineChainLink thisLink = _chain[index];
|
SplineChainLink thisLink = _chain[index];
|
||||||
uint actualDuration = SendPathSpline(owner, new Span<Vector3>(thisLink.Points.ToArray()));
|
uint actualDuration = SendPathSpline(owner, thisLink.Velocity, new Span<Vector3>(thisLink.Points.ToArray()));
|
||||||
if (actualDuration != thisLink.ExpectedDuration)
|
if (actualDuration != thisLink.ExpectedDuration)
|
||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::SendSplineFor: sent spline on index: {index}, duration: {actualDuration} ms. Expected duration: {thisLink.ExpectedDuration} ms (delta {actualDuration - thisLink.ExpectedDuration} ms). Adjusting. ({owner.GetGUID()})");
|
Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::SendSplineFor: sent spline on index: {index}, duration: {actualDuration} ms. Expected duration: {thisLink.ExpectedDuration} ms (delta {actualDuration - thisLink.ExpectedDuration} ms). Adjusting. ({owner.GetGUID()})");
|
||||||
|
|||||||
@@ -386,22 +386,25 @@ namespace Game.Movement
|
|||||||
|
|
||||||
public class SplineChainLink
|
public class SplineChainLink
|
||||||
{
|
{
|
||||||
public SplineChainLink(Vector3[] points, uint expectedDuration, uint msToNext)
|
public List<Vector3> Points = new();
|
||||||
|
public uint ExpectedDuration;
|
||||||
|
public uint TimeToNext;
|
||||||
|
public float Velocity;
|
||||||
|
|
||||||
|
public SplineChainLink(Vector3[] points, uint expectedDuration, uint msToNext, float velocity)
|
||||||
{
|
{
|
||||||
Points.AddRange(points);
|
Points.AddRange(points);
|
||||||
ExpectedDuration = expectedDuration;
|
ExpectedDuration = expectedDuration;
|
||||||
TimeToNext = msToNext;
|
TimeToNext = msToNext;
|
||||||
|
Velocity = velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SplineChainLink(uint expectedDuration, uint msToNext)
|
public SplineChainLink(uint expectedDuration, uint msToNext, float velocity)
|
||||||
{
|
{
|
||||||
ExpectedDuration = expectedDuration;
|
ExpectedDuration = expectedDuration;
|
||||||
TimeToNext = msToNext;
|
TimeToNext = msToNext;
|
||||||
|
Velocity = velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Vector3> Points = new();
|
|
||||||
public uint ExpectedDuration;
|
|
||||||
public uint TimeToNext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SplineChainResumeInfo
|
public class SplineChainResumeInfo
|
||||||
|
|||||||
@@ -259,9 +259,9 @@ namespace Game.Scripting
|
|||||||
|
|
||||||
m_mSplineChainsMap.Clear();
|
m_mSplineChainsMap.Clear();
|
||||||
|
|
||||||
// 0 1 2 3 4
|
// 0 1 2 3 4 5
|
||||||
SQLResult resultMeta = DB.World.Query("SELECT entry, chainId, splineId, expectedDuration, msUntilNext FROM script_spline_chain_meta ORDER BY entry asc, chainId asc, splineId asc");
|
SQLResult resultMeta = DB.World.Query("SELECT entry, chainId, splineId, expectedDuration, msUntilNext, velocity FROM script_spline_chain_meta ORDER BY entry asc, chainId asc, splineId asc");
|
||||||
// 0 1 2 3 4 5 6
|
// 0 1 2 3 4 5 6
|
||||||
SQLResult resultWP = DB.World.Query("SELECT entry, chainId, splineId, wpId, x, y, z FROM script_spline_chain_waypoints ORDER BY entry asc, chainId asc, splineId asc, wpId asc");
|
SQLResult resultWP = DB.World.Query("SELECT entry, chainId, splineId, wpId, x, y, z FROM script_spline_chain_waypoints ORDER BY entry asc, chainId asc, splineId asc, wpId asc");
|
||||||
if (resultMeta.IsEmpty() || resultWP.IsEmpty())
|
if (resultMeta.IsEmpty() || resultWP.IsEmpty())
|
||||||
{
|
{
|
||||||
@@ -287,8 +287,10 @@ namespace Game.Scripting
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint expectedDuration = resultMeta.Read<uint>(3), msUntilNext = resultMeta.Read<uint>(4);
|
uint expectedDuration = resultMeta.Read<uint>(3);
|
||||||
chain.Add(new SplineChainLink(expectedDuration, msUntilNext));
|
uint msUntilNext = resultMeta.Read<uint>(4);
|
||||||
|
float velocity = resultMeta.Read<float>(5);
|
||||||
|
chain.Add(new SplineChainLink(expectedDuration, msUntilNext, velocity));
|
||||||
|
|
||||||
if (splineId == 0)
|
if (splineId == 0)
|
||||||
++chainCount;
|
++chainCount;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `script_spline_chain_meta` ADD COLUMN `velocity` FLOAT(5) UNSIGNED DEFAULT 0 AFTER `msUntilNext`;
|
||||||
Reference in New Issue
Block a user