68 lines
1.4 KiB
C#
68 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using ReallifeGamemode.Server.Common;
|
|
using ReallifeGamemode.Server.Core.API;
|
|
|
|
namespace ReallifeGamemode.Server.Core.RageMP
|
|
{
|
|
public class RageEntity : IEntity
|
|
{
|
|
|
|
private readonly GTANetworkAPI.Entity entity;
|
|
|
|
public Position Position
|
|
{
|
|
get => entity.Position.ToPosition();
|
|
set => entity.Position = value.ToVector3();
|
|
}
|
|
public Position Rotation
|
|
{
|
|
get => entity.Rotation.ToPosition();
|
|
set => entity.Rotation = value.ToVector3();
|
|
}
|
|
|
|
public ulong Handle => entity.Handle.Value;
|
|
|
|
public double Heading
|
|
{
|
|
get => Rotation.Z;
|
|
set
|
|
{
|
|
var rotation = Rotation;
|
|
rotation.Z = value;
|
|
Rotation = rotation;
|
|
}
|
|
}
|
|
|
|
public uint Dimension { get => entity.Dimension; set => entity.Dimension = value; }
|
|
|
|
public RageEntity(GTANetworkAPI.Entity rageEntity)
|
|
{
|
|
entity = rageEntity;
|
|
}
|
|
|
|
public void Remove()
|
|
{
|
|
entity.Delete();
|
|
}
|
|
|
|
public void SetSharedData<T>(string key, T data)
|
|
{
|
|
entity.SetSharedData(key, data.SerializeJson());
|
|
}
|
|
|
|
public T GetSharedData<T>(string key, T fallback)
|
|
{
|
|
if (!entity.HasSharedData(key))
|
|
{
|
|
return fallback;
|
|
}
|
|
|
|
var data = entity.GetSharedData<string>(key);
|
|
|
|
return data.DeserializeJson<T>();
|
|
}
|
|
}
|
|
}
|