IW4M-Admin/Plugins/LiveRadar/RadarEvent.cs

64 lines
1.9 KiB
C#
Raw Normal View History

using Data.Models;
using SharedLibraryCore;
2019-06-30 14:37:59 -04:00
using System;
using System.Linq;
2022-01-26 11:32:16 -05:00
// ReSharper disable CompareOfFloatsByEqualityOperator
2022-01-28 10:37:04 -05:00
#pragma warning disable CS0659
2019-06-30 14:37:59 -04:00
2023-02-11 21:46:08 -05:00
namespace IW4MAdmin.Plugins.LiveRadar;
public class RadarEvent
2019-06-30 14:37:59 -04:00
{
2023-02-11 21:46:08 -05:00
public string Name { get; set; }
public long Guid { get; set; }
public Vector3 Location { get; set; }
public Vector3 ViewAngles { get; set; }
public string Team { get; set; }
public int Kills { get; set; }
public int Deaths { get; set; }
public int Score { get; set; }
public int PlayTime { get; set; }
public string Weapon { get; set; }
public int Health { get; set; }
public bool IsAlive { get; set; }
public Vector3 RadianAngles => new Vector3(ViewAngles.X.ToRadians(), ViewAngles.Y.ToRadians(), ViewAngles.Z.ToRadians());
public int Id => GetHashCode();
2019-07-02 18:30:05 -04:00
2023-02-11 21:46:08 -05:00
public override bool Equals(object obj)
{
if (obj is RadarEvent re)
2019-07-02 18:30:05 -04:00
{
2023-02-11 21:46:08 -05:00
return re.ViewAngles.X == ViewAngles.X &&
re.ViewAngles.Y == ViewAngles.Y &&
re.ViewAngles.Z == ViewAngles.Z &&
re.Location.X == Location.X &&
re.Location.Y == Location.Y &&
re.Location.Z == Location.Z;
2019-07-02 18:30:05 -04:00
}
2019-06-30 14:37:59 -04:00
2023-02-11 21:46:08 -05:00
return false;
}
2019-06-30 14:37:59 -04:00
2023-02-11 21:46:08 -05:00
public static RadarEvent Parse(string input, long generatedBotGuid)
{
var items = input.Split(';').Skip(1).ToList();
2019-06-30 14:37:59 -04:00
2023-02-11 21:46:08 -05:00
var parsedEvent = new RadarEvent()
{
Guid = generatedBotGuid,
Location = Vector3.Parse(items[1]),
ViewAngles = Vector3.Parse(items[2]).FixIW4Angles(),
Team = items[3],
Kills = int.Parse(items[4]),
Deaths = int.Parse(items[5]),
Score = int.Parse(items[6]),
Weapon = items[7],
Health = int.Parse(items[8]),
IsAlive = items[9] == "1",
PlayTime = Convert.ToInt32(items[10])
};
return parsedEvent;
2019-06-30 14:37:59 -04:00
}
}