RAGECOOP-V/Server/PlayerData.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2021-12-17 21:32:57 +01:00
using System.Linq;
namespace CoopServer
2021-07-07 13:36:25 +02:00
{
2021-08-26 17:01:32 +02:00
public struct PlayerData
2021-07-07 13:36:25 +02:00
{
public string Username { get; set; }
2021-08-26 17:01:32 +02:00
private LVector3 LastPosition { get; set; }
private LVector3 CurrentPosition { get; set; }
2021-08-20 17:28:13 +02:00
public LVector3 Position
{
get => CurrentPosition;
2021-08-20 17:28:13 +02:00
set
{
LastPosition = CurrentPosition;
CurrentPosition = value;
2021-12-17 21:32:57 +01:00
if (Server.Resources.Any() && !LVector3.Equals(CurrentPosition, LastPosition))
2021-08-20 17:28:13 +02:00
{
2021-12-17 21:32:57 +01:00
foreach (Resource resource in Server.Resources)
{
resource.InvokePlayerPositionUpdate(this);
}
2021-08-20 17:28:13 +02:00
}
}
}
private int CurrentHealth { get; set; }
public int Health
{
get => CurrentHealth;
set
{
2021-12-17 21:32:57 +01:00
if (Server.Resources.Any() && CurrentHealth != value)
{
2021-12-17 21:32:57 +01:00
foreach (Resource resource in Server.Resources)
{
resource.InvokePlayerHealthUpdate(this);
}
}
CurrentHealth = value;
}
}
2021-08-20 17:28:13 +02:00
public bool IsInRangeOf(LVector3 position, float distance)
{
return LVector3.Subtract(Position, position).Length() < distance;
}
2021-07-07 13:36:25 +02:00
}
}