From a0862b6a159373f2e1554e489ecb5bb08d89654e Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 15 Oct 2024 13:09:43 -0600 Subject: [modding] Implement Vehicles & Fix Animations (#109) * Train works * Fix minimap * Fix highway * Fix * Refactor train and boat * Update * Implement Trucks * Fix tanker * Finish implementing vehicles * Fix animations * Fix spawn players * Fix spawn players * Fix loading custom data --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> --- src/engine/World.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/engine/World.cpp') diff --git a/src/engine/World.cpp b/src/engine/World.cpp index 05a725aff..a27ee2540 100644 --- a/src/engine/World.cpp +++ b/src/engine/World.cpp @@ -2,6 +2,16 @@ #include "World.h" #include "Cup.h" #include "courses/Course.h" +#include "vehicles/Vehicle.h" +#include "vehicles/Train.h" +#include "vehicles/Boat.h" +#include "vehicles/Truck.h" +#include "vehicles/Bus.h" +#include "vehicles/TankerTruck.h" +#include "vehicles/Car.h" +#include "TrainCrossing.h" +#include + extern "C" { #include "camera.h" @@ -38,6 +48,54 @@ void World::SetCourseFromCup() { CurrentCourse = CurrentCup->GetCourse(); } +// Required for spawning vehicles in divisions across path points +static size_t trains; +static size_t trucks; +static size_t busses; +static size_t tankerTrucks; +static size_t cars; +static size_t boats; +void World::AddTrain(size_t numCarriages, f32 speed, uint32_t waypoint) { + Vehicles.push_back(std::make_unique(trains, numCarriages, speed, waypoint)); + trains++; +} + +void World::AddBoat(f32 speed, uint32_t waypoint) { + Vehicles.push_back(std::make_unique(boats, speed, waypoint)); + boats++; +} + +void World::AddTruck(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique(trucks, speedA, speedB, path, waypoint)); + trucks++; +} + +void World::AddBus(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique(busses, speedA, speedB, path, waypoint)); + busses++; +} + +void World::AddTankerTruck(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique(tankerTrucks, speedA, speedB, path, waypoint)); + tankerTrucks++; +} + +void World::AddCar(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique(cars, speedA, speedB, path, waypoint)); + cars++; +} + +void World::ResetVehicles(void) { + trains = trucks = busses = tankerTrucks = cars = boats = 0; + Vehicles.clear(); +} + +TrainCrossing* World::AddCrossing(Vec3f position, u32 waypointMin, u32 waypointMax, f32 approachRadius, f32 exitRadius) { + auto crossing = std::make_shared(position, waypointMin, waypointMax, approachRadius, exitRadius); + Crossings.push_back(crossing); + return crossing.get(); +} + //const char* World::GetCupName() { // //return this->Cups[CupIndex].Name; //} -- cgit v1.2.3