1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

implement functionality to dynamically populate property values from events that inherit from GameScriptEvent

This commit is contained in:
RaidMax
2024-06-22 17:02:04 -05:00
parent dffcae8344
commit 1596af1548
15 changed files with 232 additions and 75 deletions

View File

@ -1,12 +1,13 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
// ReSharper disable CompareOfFloatsByEqualityOperator
#pragma warning disable CS0659
namespace Data.Models
{
public class Vector3
public class Vector3 : IParsable<Vector3>
{
[Key] public int Vector3Id { get; set; }
public float X { get; protected set; }
@ -78,7 +79,7 @@ namespace Data.Models
return Math.Sqrt((dx * dx) + (dy * dy));
}
public static double ViewAngleDistance(Vector3 a, Vector3 b, Vector3 c)
{
double dabX = Math.Abs(a.X - b.X);
@ -111,5 +112,30 @@ namespace Data.Models
public double Magnitude() => Math.Sqrt((X * X) + (Y * Y) + (Z * Z));
public double AngleBetween(Vector3 a) => Math.Acos(this.DotProduct(a) / (a.Magnitude() * this.Magnitude()));
public static Vector3 Parse(string s, IFormatProvider provider)
{
return Parse(s);
}
public static bool TryParse(string s, IFormatProvider provider, out Vector3 result)
{
result = new Vector3();
try
{
var parsed = Parse(s);
result.X = parsed.X;
result.Y = parsed.Y;
result.Z = parsed.Z;
return true;
}
catch
{
// ignored
}
return false;
}
}
}