From 91f750e562bc525c23d9041ca979b165f83c7389 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 2 Sep 2023 15:11:38 -0400 Subject: [PATCH] Core/AreaTriggers: Handle AREATRIGGER_FLAG_HAS_DYNAMIC_SHAPE for disks Port From (https://github.com/TrinityCore/TrinityCore/commit/5be076b2400364c5fc2b293032ad92f1d955ec1f) --- Source/Framework/Util/MathFunctions.cs | 2 +- .../Game/Entities/AreaTrigger/AreaTrigger.cs | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Source/Framework/Util/MathFunctions.cs b/Source/Framework/Util/MathFunctions.cs index 478d2631d..963c63f10 100644 --- a/Source/Framework/Util/MathFunctions.cs +++ b/Source/Framework/Util/MathFunctions.cs @@ -76,7 +76,7 @@ public static class MathFunctions return 0.0000005f * aa; } - public static float lerp(float a, float b, float f) + public static float Lerp(float a, float b, float f) { return a + (b - a) * f; } diff --git a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs index 916f63705..c69ab7a55 100644 --- a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs +++ b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs @@ -475,7 +475,7 @@ namespace Game.Entities { if (GetCreateProperties().MorphCurveId != 0) { - radius = MathFunctions.lerp(_shape.SphereDatas.Radius, _shape.SphereDatas.RadiusTarget, Global.DB2Mgr.GetCurveValueAt(GetCreateProperties().MorphCurveId, GetProgress())); + radius = MathFunctions.Lerp(_shape.SphereDatas.Radius, _shape.SphereDatas.RadiusTarget, Global.DB2Mgr.GetCurveValueAt(GetCreateProperties().MorphCurveId, GetProgress())); } } @@ -523,10 +523,23 @@ namespace Game.Entities void SearchUnitInDisk(List targetList) { - SearchUnits(targetList, GetMaxSearchRadius(), false); - float innerRadius = _shape.DiskDatas.InnerRadius; + float outerRadius = _shape.DiskDatas.OuterRadius; float height = _shape.DiskDatas.Height; + + if (GetTemplate() != null && GetTemplate().HasFlag(AreaTriggerFlags.HasDynamicShape)) + { + float progress = GetProgress(); + if (GetCreateProperties().MorphCurveId != 0) + progress = Global.DB2Mgr.GetCurveValueAt(GetCreateProperties().MorphCurveId, progress); + + innerRadius = MathFunctions.Lerp(_shape.DiskDatas.InnerRadius, _shape.DiskDatas.InnerRadiusTarget, progress); + outerRadius = MathFunctions.Lerp(_shape.DiskDatas.OuterRadius, _shape.DiskDatas.OuterRadiusTarget, progress); + height = MathFunctions.Lerp(_shape.DiskDatas.Height, _shape.DiskDatas.HeightTarget, progress); + } + + SearchUnits(targetList, outerRadius, false); + float minZ = GetPositionZ() - height; float maxZ = GetPositionZ() + height; @@ -946,7 +959,7 @@ namespace Game.Entities // 4.f Defines four quarters blendCurve = MathFunctions.RoundToInterval(ref blendCurve, 1.0f, 4.0f) / 4.0f; float blendProgress = Math.Min(1.0f, pathProgress / blendCurve); - radius = MathFunctions.lerp(cmi.BlendFromRadius, cmi.Radius, blendProgress); + radius = MathFunctions.Lerp(cmi.BlendFromRadius, cmi.Radius, blendProgress); } // Adapt Path progress depending of circle direction