diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2024-10-15 13:09:43 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-15 13:09:43 -0600 |
| commit | a0862b6a159373f2e1554e489ecb5bb08d89654e (patch) | |
| tree | b5c33fc7f65b438ee74898dd9ed7ba25b0fa108a /src/engine/World.cpp | |
| parent | 58d56fcba848e8545052c1d85ef27d0b02841538 (diff) | |
[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>
Diffstat (limited to 'src/engine/World.cpp')
| -rw-r--r-- | src/engine/World.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
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 <memory> + 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<ATrain>(trains, numCarriages, speed, waypoint)); + trains++; +} + +void World::AddBoat(f32 speed, uint32_t waypoint) { + Vehicles.push_back(std::make_unique<ABoat>(boats, speed, waypoint)); + boats++; +} + +void World::AddTruck(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique<ATruck>(trucks, speedA, speedB, path, waypoint)); + trucks++; +} + +void World::AddBus(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique<ABus>(busses, speedA, speedB, path, waypoint)); + busses++; +} + +void World::AddTankerTruck(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique<ATankerTruck>(tankerTrucks, speedA, speedB, path, waypoint)); + tankerTrucks++; +} + +void World::AddCar(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoint) { + Vehicles.push_back(std::make_unique<ACar>(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<TrainCrossing>(position, waypointMin, waypointMax, approachRadius, exitRadius); + Crossings.push_back(crossing); + return crossing.get(); +} + //const char* World::GetCupName() { // //return this->Cups[CupIndex].Name; //} |
