More cleanups of custom classes in favor of .NET runtime types.

This commit is contained in:
hondacrx
2021-11-15 18:04:57 -05:00
parent a9a51d0641
commit b026ee7ef8
132 changed files with 373 additions and 6833 deletions
-5
View File
@@ -15,11 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Game.Entities;
namespace Game.Movement
@@ -16,13 +16,13 @@
*/
using Framework.Constants;
using Framework.GameMath;
using Game.DataStorage;
using Game.Entities;
using Game.Maps;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Game.Movement
{
@@ -17,7 +17,6 @@
using Framework.Constants;
using Game.Entities;
using System;
namespace Game.Movement
{
@@ -16,10 +16,10 @@
*/
using Framework.Constants;
using Framework.GameMath;
using Game.Entities;
using Game.Maps;
using System;
using System.Numerics;
namespace Game.Movement
{
@@ -481,7 +481,7 @@ namespace Game.Movement
Vector3 endVec = new(endPoint[0], endPoint[1], endPoint[2]);
Vector3 diffVec = (endVec - startVec);
Vector3 prevVec = startVec;
float len = diffVec.GetLength();
float len = diffVec.Length();
diffVec *= 4.0f / len;
while (len > 4.0f)
{
@@ -861,7 +861,7 @@ namespace Game.Movement
float Dist3DSqr(Vector3 p1, Vector3 p2)
{
return (p1 - p2).GetLengthSquared();
return (p1 - p2).LengthSquared();
}
public void ShortenPathUntilDist(Position pos, float dist) { ShortenPathUntilDist(new Vector3(pos.posX, pos.posY, pos.posZ), dist); }
@@ -878,11 +878,11 @@ namespace Game.Movement
// the first point of the path must be outside the specified range
// (this should have really been checked by the caller...)
if ((_pathPoints[0] - target).GetLengthSquared() < distSq)
if ((_pathPoints[0] - target).LengthSquared() < distSq)
return;
// check if we even need to do anything
if ((_pathPoints[0] - target).GetLengthSquared() >= distSq)
if ((_pathPoints[0] - target).LengthSquared() >= distSq)
return;
int i = _pathPoints.Length - 1;
@@ -893,7 +893,7 @@ namespace Game.Movement
while (true)
{
// we know that pathPoints[i] is too close already (from the previous iteration)
if ((_pathPoints[i - 1] - target).GetLengthSquared() >= distSq)
if ((_pathPoints[i - 1] - target).LengthSquared() >= distSq)
break; // bingo!
if (--i == 0)
@@ -908,7 +908,7 @@ namespace Game.Movement
// ok, _pathPoints[i] is too close, _pathPoints[i-1] is not, so our target point is somewhere between the two...
// ... settle for a guesstimate since i'm not confident in doing trig on every chase motion tick...
// (@todo review this)
_pathPoints[i] += (_pathPoints[i - 1] - _pathPoints[i]).directionOrZero() * (dist - (_pathPoints[i] - target).GetLength());
_pathPoints[i] += (_pathPoints[i - 1] - _pathPoints[i]).directionOrZero() * (dist - (_pathPoints[i] - target).Length());
Array.Resize(ref _pathPoints, i + 1);
}
@@ -17,7 +17,6 @@
using Framework.Constants;
using Game.Entities;
using Game.Maps;
using System;
namespace Game.Movement
@@ -16,11 +16,11 @@
*/
using Framework.Constants;
using Framework.GameMath;
using Game.AI;
using Game.Entities;
using System;
using System.Collections.Generic;
using System.Numerics;
namespace Game.Movement
{
+1 -1
View File
@@ -16,13 +16,13 @@
*/
using Framework.Constants;
using Framework.GameMath;
using Game.AI;
using Game.DataStorage;
using Game.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Game.Movement
{
+2 -2
View File
@@ -17,9 +17,9 @@
using Framework.Constants;
using Framework.Dynamic;
using Framework.GameMath;
using System;
using System.Collections.Generic;
using System.Numerics;
namespace Game.Movement
{
@@ -52,7 +52,7 @@ namespace Game.Movement
effect_start_time = 0;
spell_effect_extra = args.spellEffectExtra;
anim_tier = args.animTier;
splineIsFacingOnly = args.path.Length == 2 && args.facing.type != MonsterMoveType.Normal && ((args.path[1] - args.path[0]).GetLength() < 0.1f);
splineIsFacingOnly = args.path.Length == 2 && args.facing.type != MonsterMoveType.Normal && ((args.path[1] - args.path[0]).Length() < 0.1f);
// Check if its a stop spline
if (args.flags.HasFlag(SplineFlag.Done))
+1 -1
View File
@@ -16,10 +16,10 @@
*/
using Framework.Constants;
using Framework.GameMath;
using Game.Entities;
using Game.Networking.Packets;
using System;
using System.Numerics;
namespace Game.Movement
{
+2 -3
View File
@@ -16,9 +16,8 @@
*/
using Framework.Dynamic;
using Framework.GameMath;
using Game.Entities;
using System;
using System.Numerics;
namespace Game.Movement
{
@@ -80,7 +79,7 @@ namespace Game.Movement
{
if (path.Length > 2 || facing.type == Framework.Constants.MonsterMoveType.Normal)
for (uint i = 0; i < path.Length - 1; ++i)
if ((path[i + 1] - path[i]).GetLength() < 0.1f)
if ((path[i + 1] - path[i]).Length() < 0.1f)
return false;
return true;
}
+16 -16
View File
@@ -16,10 +16,10 @@
*/
using Framework.Constants;
using Framework.GameMath;
using Game.Entities;
using Game.Maps;
using System;
using System.Numerics;
namespace Game.Movement
{
@@ -139,14 +139,14 @@ namespace Game.Movement
if (cyclic_point == 0)
points[0] = controls[count - 1];
else
points[0] = controls[0].lerp(controls[1], -1);
points[0] = Vector3.Lerp(controls[0], controls[1], -1);
points[high_index + 1] = controls[cyclic_point];
points[high_index + 2] = controls[cyclic_point + 1];
}
else
{
points[0] = controls[0].lerp(controls[1], -1);
points[0] = Vector3.Lerp(controls[0], controls[1], -1);
points[high_index + 1] = controls[count - 1];
}
@@ -219,7 +219,7 @@ namespace Game.Movement
}
float SegLengthLinear(int index)
{
return (points[index] - points[index + 1]).GetLength();
return (points[index] - points[index + 1]).Length();
}
float SegLengthCatmullRom(int index)
{
@@ -232,7 +232,7 @@ namespace Game.Movement
while (i <= 3)
{
C_Evaluate(p, i / (float)3, s_catmullRomCoeffs, out nextPos);
length += (nextPos - curPos).GetLength();
length += (nextPos - curPos).Length();
curPos = nextPos;
++i;
}
@@ -253,7 +253,7 @@ namespace Game.Movement
while (i <= 3)
{
C_Evaluate(p, i / (float)3, s_Bezier3Coeffs, out nextPos);
length += (nextPos - curPos).GetLength();
length += (nextPos - curPos).Length();
curPos = nextPos;
++i;
}
@@ -296,25 +296,25 @@ namespace Game.Movement
return i;
}
private static readonly Matrix4 s_catmullRomCoeffs = new(-0.5f, 1.5f, -1.5f, 0.5f, 1.0f, -2.5f, 2.0f, -0.5f, -0.5f, 0.0f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
private static readonly Matrix4x4 s_catmullRomCoeffs = new(-0.5f, 1.5f, -1.5f, 0.5f, 1.0f, -2.5f, 2.0f, -0.5f, -0.5f, 0.0f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
private static readonly Matrix4 s_Bezier3Coeffs = new(-1.0f, 3.0f, -3.0f, 1.0f, 3.0f, -6.0f, 3.0f, 0.0f, -3.0f, 3.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
private static readonly Matrix4x4 s_Bezier3Coeffs = new(-1.0f, 3.0f, -3.0f, 1.0f, 3.0f, -6.0f, 3.0f, 0.0f, -3.0f, 3.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
void C_Evaluate(Span<Vector3> vertice, float t, Matrix4 matr, out Vector3 result)
void C_Evaluate(Span<Vector3> vertice, float t, Matrix4x4 matr, out Vector3 result)
{
Vector4 tvec = new(t * t * t, t * t, t, 1.0f);
Vector4 weights = (tvec * matr);
Vector4 weights = Vector4.Transform(tvec, matr);
result = vertice[0] * weights[0] + vertice[1] * weights[1]
+ vertice[2] * weights[2] + vertice[3] * weights[3];
result = vertice[0] * weights.X + vertice[1] * weights.Y
+ vertice[2] * weights.Z + vertice[3] * weights.W;
}
void C_Evaluate_Derivative(Span<Vector3> vertice, float t, Matrix4 matr, out Vector3 result)
void C_Evaluate_Derivative(Span<Vector3> vertice, float t, Matrix4x4 matr, out Vector3 result)
{
Vector4 tvec = new(3.0f * t * t, 2.0f * t, 1.0f, 0.0f);
Vector4 weights = (tvec * matr);
Vector4 weights = Vector4.Transform(tvec, matr);
result = vertice[0] * weights[0] + vertice[1] * weights[1]
+ vertice[2] * weights[2] + vertice[3] * weights[3];
result = vertice[0] * weights.X + vertice[1] * weights.Y
+ vertice[2] * weights.Z + vertice[3] * weights.W;
}
public int Length() { return lengths[index_hi];}