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
|
||||
SQLResult areatriggerCreateProperties = DB.World.Query("SELECT Id, IsCustom, AreaTriggerId, IsAreatriggerCustom, Flags, " +
|
||||
//5 6 7 8 9 10 11 12 13 14
|
||||
"MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTargetScale, Speed, " +
|
||||
//15 16 17 18 19 20 21 22 23 24
|
||||
//5 6 7 8 9 10 11 12 13 14 15
|
||||
"MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTargetScale, Speed, SpeedIsTime, " +
|
||||
//16 17 18 19 20 21 22 23 24 25
|
||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`");
|
||||
if (!areatriggerCreateProperties.IsEmpty())
|
||||
{
|
||||
@@ -141,7 +141,7 @@ namespace Game.DataStorage
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -187,10 +187,11 @@ namespace Game.DataStorage
|
||||
|
||||
createProperties.TimeToTargetScale = areatriggerCreateProperties.Read<uint>(13);
|
||||
createProperties.Speed = areatriggerCreateProperties.Read<float>(14);
|
||||
createProperties.SpeedIsTime = areatriggerCreateProperties.Read<bool>(15);
|
||||
|
||||
float[] shapeData = new float[SharedConst.MaxAreatriggerEntityData];
|
||||
for (byte i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i)
|
||||
shapeData[i] = areatriggerCreateProperties.Read<float>(16 + i);
|
||||
shapeData[i] = areatriggerCreateProperties.Read<float>(17 + i);
|
||||
|
||||
switch (shape)
|
||||
{
|
||||
@@ -235,7 +236,7 @@ namespace Game.DataStorage
|
||||
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);
|
||||
if (spline != null)
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace Game.Entities
|
||||
|
||||
GetCreateProperties().Movement.Switch(
|
||||
_ => SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.PathType), (byte)AreaTriggerPathType.None),
|
||||
splineInfo => InitSplineOffsets(splineInfo),
|
||||
splineInfo => InitSplineOffsets(splineInfo, null, GetCreateProperties().SpeedIsTime),
|
||||
orbitInfo =>
|
||||
{
|
||||
AreaTriggerOrbitInfo orbit = orbitInfo;
|
||||
@@ -231,7 +231,7 @@ namespace Game.Entities
|
||||
else
|
||||
orbit.Center = pos;
|
||||
|
||||
InitOrbit(orbit);
|
||||
InitOrbit(orbit, null, GetCreateProperties().SpeedIsTime);
|
||||
});
|
||||
|
||||
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 angleCos = (float)Math.Cos(GetOrientation());
|
||||
@@ -1179,10 +1179,10 @@ namespace Game.Entities
|
||||
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)
|
||||
return;
|
||||
@@ -1195,7 +1195,7 @@ namespace Game.Entities
|
||||
if (speed <= 0.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);
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
|
||||
@@ -1220,7 +1220,7 @@ namespace Game.Entities
|
||||
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
|
||||
Cypher.Assert(orbit.Center.HasValue || orbit.PathTarget.HasValue);
|
||||
@@ -1229,7 +1229,7 @@ namespace Game.Entities
|
||||
if (speed <= 0.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);
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTarget), timeToTarget);
|
||||
|
||||
@@ -248,6 +248,7 @@ namespace Game.Entities
|
||||
public AreaTriggerShapeInfo Shape = new();
|
||||
|
||||
public float Speed = 1.0f;
|
||||
public bool SpeedIsTime;
|
||||
public OneOf<EmptyStruct, List<Vector3>, AreaTriggerOrbitInfo> Movement;
|
||||
|
||||
public uint ScriptId;
|
||||
|
||||
Reference in New Issue
Block a user