Rewrite of vehicle system

This commit is contained in:
hydrant
2018-11-28 19:36:46 +01:00
parent 52ab83f5ea
commit d5b249e8e1
12 changed files with 137 additions and 174 deletions

View File

@@ -14,28 +14,11 @@ using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class FactionVehicle
[Table("FactionVehicles")]
public class FactionVehicle : ServerVehicle
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("Faction")]
public int? FactionId { get; set; }
public Faction Faction { 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 byte Alpha { get; set; }
public byte PrimaryColor { get; set; }
public byte SecondaryColor { get; set; }
public bool Locked { get; set; }
public bool Engine { get; set; }
public byte Dimension { get; set; }
public bool Active { get; set; }
}
}

View File

@@ -0,0 +1,40 @@
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 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);
return veh;
}
}
}

View File

@@ -14,30 +14,12 @@ using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class ShopVehicle
[Table("ShopVehicles")]
public class ShopVehicle : ServerVehicle
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("Shop")]
public int? ShopId { get; set; }
public Shop Shop { get; set; }
public VehicleHash Model { get; set; }
[StringLength(32)]
public string ModelName { get; set; }
public int Price { 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 byte Alpha { get; set; }
public byte PrimaryColor { get; set; }
public byte SecondaryColor { get; set; }
public byte Dimension { get; set; }
public bool Active { get; set; }
}
}

View File

@@ -14,27 +14,11 @@ using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class UserVehicle
[Table("UserVehicles")]
public class UserVehicle : ServerVehicle
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("User")]
public int UserId { get; set; }
public User User { 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 byte Alpha { get; set; }
public byte PrimaryColor { get; set; }
public byte SecondaryColor { get; set; }
public bool Locked { get; set; }
public bool Engine { get; set; }
public byte Dimension { get; set; }
}
}