Core/AreaTriggers: Implemented SpeedIsTime parameter for areatrigger splines and orbit
Port From (https://github.com/TrinityCore/TrinityCore/commit/c1b8daa6390cf00a07ef30e5de8061e158adb439)
This commit is contained in:
@@ -124,9 +124,9 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
// 0 1 2 3 4
|
// 0 1 2 3 4
|
||||||
SQLResult areatriggerCreateProperties = DB.World.Query("SELECT Id, IsCustom, AreaTriggerId, IsAreatriggerCustom, Flags, " +
|
SQLResult areatriggerCreateProperties = DB.World.Query("SELECT Id, IsCustom, AreaTriggerId, IsAreatriggerCustom, Flags, " +
|
||||||
//5 6 7 8 9 10 11 12 13 14
|
//5 6 7 8 9 10 11 12 13 14 15
|
||||||
"MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTargetScale, Speed, " +
|
"MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTargetScale, Speed, SpeedIsTime, " +
|
||||||
//15 16 17 18 19 20 21 22 23 24
|
//16 17 18 19 20 21 22 23 24 25
|
||||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`");
|
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`");
|
||||||
if (!areatriggerCreateProperties.IsEmpty())
|
if (!areatriggerCreateProperties.IsEmpty())
|
||||||
{
|
{
|
||||||
@@ -141,7 +141,7 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
createProperties.Flags = (AreaTriggerCreatePropertiesFlag)areatriggerCreateProperties.Read<uint>(4);
|
createProperties.Flags = (AreaTriggerCreatePropertiesFlag)areatriggerCreateProperties.Read<uint>(4);
|
||||||
|
|
||||||
AreaTriggerShapeType shape = (AreaTriggerShapeType)areatriggerCreateProperties.Read<byte>(15);
|
AreaTriggerShapeType shape = (AreaTriggerShapeType)areatriggerCreateProperties.Read<byte>(16);
|
||||||
|
|
||||||
if (areaTriggerId.Id != 0 && createProperties.Template == null)
|
if (areaTriggerId.Id != 0 && createProperties.Template == null)
|
||||||
{
|
{
|
||||||
@@ -187,10 +187,11 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
createProperties.TimeToTargetScale = areatriggerCreateProperties.Read<uint>(13);
|
createProperties.TimeToTargetScale = areatriggerCreateProperties.Read<uint>(13);
|
||||||
createProperties.Speed = areatriggerCreateProperties.Read<float>(14);
|
createProperties.Speed = areatriggerCreateProperties.Read<float>(14);
|
||||||
|
createProperties.SpeedIsTime = areatriggerCreateProperties.Read<bool>(15);
|
||||||
|
|
||||||
float[] shapeData = new float[SharedConst.MaxAreatriggerEntityData];
|
float[] shapeData = new float[SharedConst.MaxAreatriggerEntityData];
|
||||||
for (byte i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i)
|
for (byte i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i)
|
||||||
shapeData[i] = areatriggerCreateProperties.Read<float>(16 + i);
|
shapeData[i] = areatriggerCreateProperties.Read<float>(17 + i);
|
||||||
|
|
||||||
switch (shape)
|
switch (shape)
|
||||||
{
|
{
|
||||||
@@ -235,7 +236,7 @@ namespace Game.DataStorage
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
createProperties.ScriptId = Global.ObjectMgr.GetScriptId(areatriggerCreateProperties.Read<string>(24));
|
createProperties.ScriptId = Global.ObjectMgr.GetScriptId(areatriggerCreateProperties.Read<string>(25));
|
||||||
|
|
||||||
var spline = splinesByCreateProperties.LookupByKey(createProperties.Id);
|
var spline = splinesByCreateProperties.LookupByKey(createProperties.Id);
|
||||||
if (spline != null)
|
if (spline != null)
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
GetCreateProperties().Movement.Switch(
|
GetCreateProperties().Movement.Switch(
|
||||||
_ => SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.PathType), (byte)AreaTriggerPathType.None),
|
_ => SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.PathType), (byte)AreaTriggerPathType.None),
|
||||||
splineInfo => InitSplineOffsets(splineInfo),
|
splineInfo => InitSplineOffsets(splineInfo, null, GetCreateProperties().SpeedIsTime),
|
||||||
orbitInfo =>
|
orbitInfo =>
|
||||||
{
|
{
|
||||||
AreaTriggerOrbitInfo orbit = orbitInfo;
|
AreaTriggerOrbitInfo orbit = orbitInfo;
|
||||||
@@ -231,7 +231,7 @@ namespace Game.Entities
|
|||||||
else
|
else
|
||||||
orbit.Center = pos;
|
orbit.Center = pos;
|
||||||
|
|
||||||
InitOrbit(orbit);
|
InitOrbit(orbit, null, GetCreateProperties().SpeedIsTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.Facing), _stationaryPosition.GetOrientation());
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.Facing), _stationaryPosition.GetOrientation());
|
||||||
@@ -1160,7 +1160,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitSplineOffsets(List<Vector3> offsets, float? overrideSpeed = null)
|
void InitSplineOffsets(List<Vector3> offsets, float? overrideSpeed = null, bool speedIsTimeInSeconds = false)
|
||||||
{
|
{
|
||||||
float angleSin = (float)Math.Sin(GetOrientation());
|
float angleSin = (float)Math.Sin(GetOrientation());
|
||||||
float angleCos = (float)Math.Cos(GetOrientation());
|
float angleCos = (float)Math.Cos(GetOrientation());
|
||||||
@@ -1179,10 +1179,10 @@ namespace Game.Entities
|
|||||||
rotatedPoints.Add(new Vector3(x, y, z));
|
rotatedPoints.Add(new Vector3(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
InitSplines(rotatedPoints.ToArray(), overrideSpeed);
|
InitSplines(rotatedPoints.ToArray(), overrideSpeed, speedIsTimeInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitSplines(Vector3[] splinePoints, float? overrideSpeed = null)
|
public void InitSplines(Vector3[] splinePoints, float? overrideSpeed = null, bool speedIsTimeInSeconds = false)
|
||||||
{
|
{
|
||||||
if (splinePoints.Length < 2)
|
if (splinePoints.Length < 2)
|
||||||
return;
|
return;
|
||||||
@@ -1195,7 +1195,7 @@ namespace Game.Entities
|
|||||||
if (speed <= 0.0f)
|
if (speed <= 0.0f)
|
||||||
speed = 1.0f;
|
speed = 1.0f;
|
||||||
|
|
||||||
uint timeToTarget = _spline.Length() / speed * (float)Time.InMilliseconds;
|
uint timeToTarget = (speedIsTimeInSeconds ? speed : _spline.Length() / speed) * Time.InMilliseconds;
|
||||||
|
|
||||||
var areaTriggerData = m_values.ModifyValue(m_areaTriggerData);
|
var areaTriggerData = m_values.ModifyValue(m_areaTriggerData);
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
|
||||||
@@ -1220,7 +1220,7 @@ namespace Game.Entities
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitOrbit(AreaTriggerOrbitInfo orbit, float? overrideSpeed = null)
|
void InitOrbit(AreaTriggerOrbitInfo orbit, float? overrideSpeed = null, bool speedIsTimeInSeconds = false)
|
||||||
{
|
{
|
||||||
// Circular movement requires either a center position or an attached unit
|
// Circular movement requires either a center position or an attached unit
|
||||||
Cypher.Assert(orbit.Center.HasValue || orbit.PathTarget.HasValue);
|
Cypher.Assert(orbit.Center.HasValue || orbit.PathTarget.HasValue);
|
||||||
@@ -1229,7 +1229,7 @@ namespace Game.Entities
|
|||||||
if (speed <= 0.0f)
|
if (speed <= 0.0f)
|
||||||
speed = 1.0f;
|
speed = 1.0f;
|
||||||
|
|
||||||
uint timeToTarget = (uint)(orbit.Radius * 2.0f * MathF.PI * (float)Time.InMilliseconds / speed);
|
uint timeToTarget = (uint)(speedIsTimeInSeconds ? speed : (uint)(orbit.Radius * 2.0f * MathF.PI / speed)) * Time.InMilliseconds;
|
||||||
|
|
||||||
var areaTriggerData = m_values.ModifyValue(m_areaTriggerData);
|
var areaTriggerData = m_values.ModifyValue(m_areaTriggerData);
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ namespace Game.Entities
|
|||||||
public AreaTriggerShapeInfo Shape = new();
|
public AreaTriggerShapeInfo Shape = new();
|
||||||
|
|
||||||
public float Speed = 1.0f;
|
public float Speed = 1.0f;
|
||||||
|
public bool SpeedIsTime;
|
||||||
public OneOf<EmptyStruct, List<Vector3>, AreaTriggerOrbitInfo> Movement;
|
public OneOf<EmptyStruct, List<Vector3>, AreaTriggerOrbitInfo> Movement;
|
||||||
|
|
||||||
public uint ScriptId;
|
public uint ScriptId;
|
||||||
|
|||||||
Reference in New Issue
Block a user