Changed whole project structure (split client and server into separat projects)
This commit is contained in:
72
ReallifeGamemode.Server/Entities/ServerVehicle.cs
Normal file
72
ReallifeGamemode.Server/Entities/ServerVehicle.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Managers;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public abstract class ServerVehicle
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public int PrimaryColor { get; set; }
|
||||
public int SecondaryColor { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public bool Active { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(PositionX, PositionY, PositionZ);
|
||||
|
||||
public Vehicle Spawn(Vehicle currentVeh = null)
|
||||
{
|
||||
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
||||
Vector3 position = this.Position;
|
||||
uint model = (uint)this.Model;
|
||||
float heading = this.Heading;
|
||||
int c1 = this.PrimaryColor;
|
||||
int c2 = this.SecondaryColor;
|
||||
string np = this.NumberPlate;
|
||||
Vehicle veh = NAPI.Vehicle.CreateVehicle(Model, position, heading, c1, c2, "", 255, false, false);
|
||||
VehicleStreaming.SetEngineState(veh, false);
|
||||
VehicleStreaming.SetLockStatus(veh, this.Locked);
|
||||
VehicleManager.AddVehicle(this, veh);
|
||||
|
||||
string numberplate = $"{this.Id}";
|
||||
|
||||
if(this is FactionVehicle fV)
|
||||
{
|
||||
numberplate = $"F{fV.FactionId} " + numberplate;
|
||||
}
|
||||
|
||||
if (this is UserVehicle uV)
|
||||
{
|
||||
numberplate = $"U{uV.UserId} " + numberplate;
|
||||
}
|
||||
|
||||
if(this is ShopVehicle sV)
|
||||
{
|
||||
numberplate = "Shop";
|
||||
VehicleStreaming.SetLockStatus(veh, false);
|
||||
TextLabel label = NAPI.TextLabel.CreateTextLabel(NAPI.Vehicle.GetVehicleDisplayName((VehicleHash)veh.Model) + "\n" + "~g~" + sV.Price.ToMoneyString(),
|
||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 10.0f, 1f, 1, new Color(255, 255, 255));
|
||||
}
|
||||
|
||||
veh.NumberPlate = numberplate;
|
||||
|
||||
return veh;
|
||||
}
|
||||
|
||||
public abstract override string ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user