haus system auf core geändert

This commit is contained in:
hydrant
2020-03-29 12:18:17 +02:00
parent 6bd3d4a3d0
commit bcfc2105ea
68 changed files with 1366 additions and 810 deletions

View File

@@ -16,6 +16,8 @@ namespace ReallifeGamemode.Server.Core.RageMP
public ITextLabelAPI TextLabel => new RageTextLabelAPI();
public IBlipAPI Blip => new RageBlipAPI();
public void DisableDefaultCommandErrorMessages()
{
NAPI.Server.SetCommandErrorMessage(null);
@@ -61,5 +63,18 @@ namespace ReallifeGamemode.Server.Core.RageMP
{
NAPI.ClientEvent.TriggerClientEventForAll("SERVER:" + eventName, args);
}
public TEntity ToEntity<TEntity>(ushort handle) where TEntity : class, IEntity
{
return typeof(TEntity).Name switch
{
"IPlayer" => new RagePlayer(new NetHandle(handle, EntityType.Player).Entity<Player>()) as TEntity,
"IVehicle" => new RageVehicle(new NetHandle(handle, EntityType.Vehicle).Entity<Vehicle>()) as TEntity,
"IMarker" => new RageMarker(new NetHandle(handle, EntityType.Marker).Entity<Marker>()) as TEntity,
"ITextLabel" => new RageTextLabel(new NetHandle(handle, EntityType.TextLabel).Entity<TextLabel>()) as TEntity,
"IColShape" => new RageColShape(new NetHandle(handle, EntityType.Colshape).Entity<ColShape>()) as TEntity,
_ => null,
};
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Server.Core.API;
namespace ReallifeGamemode.Server.Core.RageMP
{
class RageBlip : RageEntity, IBlip
{
private Blip blip;
public RageBlip(Blip blip) : base(blip)
{
this.blip = blip;
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Server.Core.API;
namespace ReallifeGamemode.Server.Core.RageMP
{
class RageBlipAPI : IBlipAPI
{
public IBlip CreateBlip(uint sprite, Position position, string name, byte color, byte alpha, float scale, float drawDistance, bool shortRange)
{
return new RageBlip(NAPI.Blip.CreateBlip(sprite, position.ToVector3(), scale, color, name, alpha, drawDistance, shortRange));
}
}
}

View File

@@ -35,6 +35,8 @@ namespace ReallifeGamemode.Server.Core.RageMP
}
}
public uint Dimension { get => entity.Dimension; set => entity.Dimension = value; }
public RageEntity(GTANetworkAPI.Entity rageEntity)
{
entity = rageEntity;
@@ -57,7 +59,9 @@ namespace ReallifeGamemode.Server.Core.RageMP
return fallback;
}
return (entity.GetSharedData<string>(key)).DeserializeJson<T>();
var data = entity.GetSharedData<string>(key);
return data.DeserializeJson<T>();
}
}
}