48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using GTANetworkAPI;
|
|
using reallife_gamemode.Model;
|
|
using reallife_gamemode.Server.Managers;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Text;
|
|
|
|
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);
|
|
Vehicle veh = NAPI.Vehicle.CreateVehicle(this.Model, this.Position, this.Heading, this.PrimaryColor, this.SecondaryColor, this.NumberPlate, locked: this.Locked, engine: false);
|
|
VehicleManager.AddVehicle(this, veh);
|
|
|
|
if(this is FactionVehicle fV)
|
|
{
|
|
veh.NumberPlate = fV.GetFaction().Name;
|
|
}
|
|
|
|
return veh;
|
|
}
|
|
}
|
|
}
|