Core/AreaTriggers: Remove unused fields from AreaTriggerCreateProperties and merge movement data into a variant
Port From (https://github.com/TrinityCore/TrinityCore/commit/b6acd368e0bca632d8742c9b5d0ef7f385cf1318)
This commit is contained in:
@@ -157,7 +157,7 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
uint ValidateAndSetCurve(uint value)
|
uint ValidateAndSetCurve(uint value)
|
||||||
{
|
{
|
||||||
if (value != 0 && !CliDB.CurveStorage.ContainsKey(value))
|
if (value != 0 && !CliDB.CurveStorage.HasRecord(value))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` has listed AreaTrigger (Id: {areaTriggerId.Id}, IsCustom: {areaTriggerId.IsCustom}) for AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with invalid Curve ({value}), set to 0!");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` has listed AreaTrigger (Id: {areaTriggerId.Id}, IsCustom: {areaTriggerId.IsCustom}) for AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with invalid Curve ({value}), set to 0!");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -215,7 +215,9 @@ namespace Game.DataStorage
|
|||||||
createProperties.Shape.PolygonVerticesTarget.Clear();
|
createProperties.Shape.PolygonVerticesTarget.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
createProperties.SplinePoints = splinesByCreateProperties[createProperties.Id];
|
var spline = splinesByCreateProperties.LookupByKey(createProperties.Id);
|
||||||
|
if (spline != null)
|
||||||
|
createProperties.SplinePoints = spline;
|
||||||
|
|
||||||
_areaTriggerCreateProperties[createProperties.Id] = createProperties;
|
_areaTriggerCreateProperties[createProperties.Id] = createProperties;
|
||||||
}
|
}
|
||||||
@@ -256,7 +258,6 @@ namespace Game.DataStorage
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
orbitInfo.Radius = ValidateAndSetFloat(circularMovementInfos.Read<float>(3));
|
orbitInfo.Radius = ValidateAndSetFloat(circularMovementInfos.Read<float>(3));
|
||||||
orbitInfo.BlendFromRadius = circularMovementInfos.Read<float>(4);
|
orbitInfo.BlendFromRadius = circularMovementInfos.Read<float>(4);
|
||||||
orbitInfo.InitialAngle = circularMovementInfos.Read<float>(5);
|
orbitInfo.InitialAngle = circularMovementInfos.Read<float>(5);
|
||||||
@@ -327,7 +328,7 @@ namespace Game.DataStorage
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createProperties.HasSplines())
|
if (createProperties.SplinePoints != null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with splines");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with splines");
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -149,8 +149,7 @@ namespace Game.Entities
|
|||||||
if (IsServerSide())
|
if (IsServerSide())
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.DecalPropertiesID), 24u); // Blue decal, for .debug areatrigger visibility
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.DecalPropertiesID), 24u); // Blue decal, for .debug areatrigger visibility
|
||||||
|
|
||||||
AreaTriggerScaleCurveTemplate extraScaleCurve = IsStaticSpawn() ? new AreaTriggerScaleCurveTemplate() : GetCreateProperties().ExtraScale;
|
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.ExtraScaleCurve), 1.0f);
|
||||||
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.ExtraScaleCurve), extraScaleCurve);
|
|
||||||
|
|
||||||
if (caster != null)
|
if (caster != null)
|
||||||
{
|
{
|
||||||
@@ -162,7 +161,7 @@ namespace Game.Entities
|
|||||||
modOwner.GetSpellModValues(spellInfo, SpellModOp.Radius, spell, (float)m_areaTriggerData.BoundsRadius2D, ref flat, ref multiplier);
|
modOwner.GetSpellModValues(spellInfo, SpellModOp.Radius, spell, (float)m_areaTriggerData.BoundsRadius2D, ref flat, ref multiplier);
|
||||||
if (multiplier != 1.0f)
|
if (multiplier != 1.0f)
|
||||||
{
|
{
|
||||||
AreaTriggerScaleCurveTemplate overrideScale = new();
|
ScaleCurveData overrideScale = new();
|
||||||
overrideScale.Curve = multiplier;
|
overrideScale.Curve = multiplier;
|
||||||
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.OverrideScaleCurve), overrideScale);
|
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.OverrideScaleCurve), overrideScale);
|
||||||
}
|
}
|
||||||
@@ -521,20 +520,17 @@ namespace Game.Entities
|
|||||||
|
|
||||||
void SetScaleCurve(ScaleCurve scaleCurve, float constantValue)
|
void SetScaleCurve(ScaleCurve scaleCurve, float constantValue)
|
||||||
{
|
{
|
||||||
AreaTriggerScaleCurveTemplate curveTemplate = new();
|
ScaleCurveData curveTemplate = new();
|
||||||
curveTemplate.Curve = constantValue;
|
curveTemplate.Curve = constantValue;
|
||||||
SetScaleCurve(scaleCurve, curveTemplate);
|
SetScaleCurve(scaleCurve, curveTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScaleCurve(ScaleCurve scaleCurve, Vector2[] points, uint? startTimeOffset, CurveInterpolationMode interpolation)
|
void SetScaleCurve(ScaleCurve scaleCurve, Vector2[] points, uint? startTimeOffset, CurveInterpolationMode interpolation)
|
||||||
{
|
{
|
||||||
AreaTriggerScaleCurvePointsTemplate curve = new();
|
ScaleCurveData curveTemplate = new();
|
||||||
curve.Mode = interpolation;
|
|
||||||
curve.Points = points;
|
|
||||||
|
|
||||||
AreaTriggerScaleCurveTemplate curveTemplate = new();
|
|
||||||
curveTemplate.StartTimeOffset = startTimeOffset.GetValueOrDefault(GetTimeSinceCreated());
|
curveTemplate.StartTimeOffset = startTimeOffset.GetValueOrDefault(GetTimeSinceCreated());
|
||||||
curveTemplate.CurveTemplate = curve;
|
curveTemplate.Mode = interpolation;
|
||||||
|
curveTemplate.CurvePoints = points;
|
||||||
|
|
||||||
SetScaleCurve(scaleCurve, curveTemplate);
|
SetScaleCurve(scaleCurve, curveTemplate);
|
||||||
}
|
}
|
||||||
@@ -544,7 +540,7 @@ namespace Game.Entities
|
|||||||
SetScaleCurve(scaleCurve, null);
|
SetScaleCurve(scaleCurve, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScaleCurve(ScaleCurve scaleCurve, AreaTriggerScaleCurveTemplate curve)
|
void SetScaleCurve(ScaleCurve scaleCurve, ScaleCurveData curve)
|
||||||
{
|
{
|
||||||
if (curve == null)
|
if (curve == null)
|
||||||
{
|
{
|
||||||
@@ -573,11 +569,11 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var curvePoints = curve.CurveTemplate;
|
var curvePoints = curve.CurvePoints;
|
||||||
if (curvePoints != null)
|
if (curvePoints != null)
|
||||||
{
|
{
|
||||||
CurveInterpolationMode mode = curvePoints.Mode;
|
CurveInterpolationMode mode = curve.Mode;
|
||||||
if (curvePoints.Points[1].X < curvePoints.Points[0].X)
|
if (curvePoints[1].X < curvePoints[0].X)
|
||||||
mode = CurveInterpolationMode.Constant;
|
mode = CurveInterpolationMode.Constant;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
@@ -603,9 +599,9 @@ namespace Game.Entities
|
|||||||
uint packedCurve = ((uint)mode << 1) | (pointCount << 24);
|
uint packedCurve = ((uint)mode << 1) | (pointCount << 24);
|
||||||
SetUpdateFieldValue(scaleCurve.ModifyValue(scaleCurve.ParameterCurve), packedCurve);
|
SetUpdateFieldValue(scaleCurve.ModifyValue(scaleCurve.ParameterCurve), packedCurve);
|
||||||
|
|
||||||
for (var i = 0; i < curvePoints.Points.Length; ++i)
|
for (var i = 0; i < curvePoints.Length; ++i)
|
||||||
{
|
{
|
||||||
point.Relocate(curvePoints.Points[i].X, curvePoints.Points[i].Y);
|
point.Relocate(curvePoints[i].X, curvePoints[i].Y);
|
||||||
SetUpdateFieldValue(ref scaleCurve.ModifyValue(scaleCurve.Points, i), point);
|
SetUpdateFieldValue(ref scaleCurve.ModifyValue(scaleCurve.Points, i), point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -896,7 +892,6 @@ namespace Game.Entities
|
|||||||
UpdateHasPlayersFlag();
|
UpdateHasPlayersFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AreaTriggerTemplate GetTemplate()
|
public AreaTriggerTemplate GetTemplate()
|
||||||
{
|
{
|
||||||
return _areaTriggerTemplate;
|
return _areaTriggerTemplate;
|
||||||
@@ -1424,7 +1419,6 @@ namespace Game.Entities
|
|||||||
GetMap().AreaTriggerRelocation(this, x, y, z, orientation);
|
GetMap().AreaTriggerRelocation(this, x, y, z, orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AI_Initialize()
|
void AI_Initialize()
|
||||||
{
|
{
|
||||||
AI_Destroy();
|
AI_Destroy();
|
||||||
@@ -1635,5 +1629,14 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public static implicit operator IDoWork<Player>(ValuesUpdateForPlayerWithMaskSender obj) => obj.Invoke;
|
public static implicit operator IDoWork<Player>(ValuesUpdateForPlayerWithMaskSender obj) => obj.Invoke;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ScaleCurveData
|
||||||
|
{
|
||||||
|
public uint StartTimeOffset;
|
||||||
|
public CurveInterpolationMode Mode;
|
||||||
|
|
||||||
|
public Vector2[] CurvePoints;
|
||||||
|
public float Curve;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,19 +91,6 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AreaTriggerScaleCurvePointsTemplate
|
|
||||||
{
|
|
||||||
public CurveInterpolationMode Mode = CurveInterpolationMode.Linear;
|
|
||||||
public Vector2[] Points = new Vector2[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AreaTriggerScaleCurveTemplate
|
|
||||||
{
|
|
||||||
public uint StartTimeOffset;
|
|
||||||
public float Curve = 1.0f;
|
|
||||||
public AreaTriggerScaleCurvePointsTemplate CurveTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct AreaTriggerId
|
public struct AreaTriggerId
|
||||||
{
|
{
|
||||||
public uint Id;
|
public uint Id;
|
||||||
@@ -232,9 +219,6 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public uint TimeToTargetScale;
|
public uint TimeToTargetScale;
|
||||||
|
|
||||||
public AreaTriggerScaleCurveTemplate OverrideScale;
|
|
||||||
public AreaTriggerScaleCurveTemplate ExtraScale;
|
|
||||||
|
|
||||||
public AreaTriggerShapeInfo Shape = new();
|
public AreaTriggerShapeInfo Shape = new();
|
||||||
|
|
||||||
public float Speed = 1.0f;
|
public float Speed = 1.0f;
|
||||||
@@ -246,10 +230,7 @@ namespace Game.Entities
|
|||||||
public AreaTriggerCreateProperties()
|
public AreaTriggerCreateProperties()
|
||||||
{
|
{
|
||||||
Id = new(0, false);
|
Id = new(0, false);
|
||||||
ExtraScale = new();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasSplines() { return SplinePoints.Count >= 2; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AreaTriggerSpawn : SpawnData
|
public class AreaTriggerSpawn : SpawnData
|
||||||
|
|||||||
Reference in New Issue
Block a user