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

@@ -40,44 +40,39 @@ namespace reallife_gamemode.Server.Managers
GotoPointList.Add(g);
}
}
foreach (Saves.SavedVehicle v in loadData.Vehicles)
foreach(ServerVehicle veh in loadData.ServerVehicles)
{
if (v.Active == true)
if (!veh.Active) continue;
Vehicle current = veh.Spawn();
if (veh is Saves.SavedVehicle savedV)
{
NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
v.SecondaryColor, v.NumberPlate, v.Alpha, v.Locked, v.Engine = false, v.Dimension);
NAPI.Vehicle.CreateVehicle((uint)savedV.Model, new Vector3(savedV.PositionX, savedV.PositionY, savedV.PositionZ), savedV.Heading, savedV.PrimaryColor,
savedV.SecondaryColor, savedV.NumberPlate, 255, savedV.Locked);
}
}
foreach (FactionVehicle v in loadData.FactionVehicles)
{
if (v.Active == true)
if (veh is FactionVehicle factionV)
{
Vehicle current = NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
v.SecondaryColor, v.NumberPlate, v.Alpha, v.Locked, v.Engine = false, v.Dimension);
current.SetData("factionId", v.FactionId);
current.SetData("factionId", factionV.FactionId);
FactionVehicleList.Add(current);
}
}
foreach (ShopVehicle v in loadData.ShopVehicles)
{
if (v.Active == true)
if (veh is ShopVehicle shopV)
{
Vehicle current = NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
v.SecondaryColor, v.NumberPlate, v.Alpha, false, false, v.Dimension);
string displayName = NAPI.Vehicle.GetVehicleDisplayName(shopV.Model);
ShopVehicleList.Add(current);
NAPI.Vehicle.SetVehicleEngineHealth(current, 0);
var tLabel = NAPI.TextLabel.CreateTextLabel(v.ModelName + " | " + v.Price + "~g~$", new Vector3(v.PositionX, v.PositionY, v.PositionZ + 1.5), 10, 1, 0, new Color(255, 255, 255), false, v.Dimension);
current.SetData("shopVehicleId", v.Id);
var tLabel = NAPI.TextLabel.CreateTextLabel(displayName + " | " + shopV.Price + "~g~$", new Vector3(shopV.PositionX, shopV.PositionY, shopV.PositionZ + 1.5), 10, 1, 0, new Color(255, 255, 255), false);
current.SetData("shopVehicleId", shopV.Id);
tLabel.AttachTo(current, "chassis", new Vector3(0, 0, 1.5), new Vector3(0, 0, 0));
}
if (veh is UserVehicle userV)
{
UserVehicleList.Add(current);
}
}
foreach (UserVehicle v in loadData.UserVehicles)
{
Vehicle current = NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
v.SecondaryColor, v.NumberPlate, v.Alpha, false, false, v.Dimension);
current.SetData("ownerId", v.UserId);
UserVehicleList.Add(current);
}
}
}
}