mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-06-17 07:27:39 -04:00
[modding] Big Update PR (#118)
* Implement kart vehicle * Fix menu CC * Actors * variable framerate * Implement Actors vector * Fix water & scrolling textures * Finish ACoin * Refactor finishline * Refactor mtx to vector * Fix refactored screen code bugs * Fix playlist bug * Switching courses working now * Fix podium ceremony * Mostly Fix Demo and Credits * Credits Load Actors and Textures * Fix credits * Formatting * Update lus and torch * Fix water features * Fix crabs * Combine function * Fix wheels * Add Moon Jump Cheat * Wheel Change * Fix smoke due to wheel change * Fix screens for wheels * Fix transparency * Fix staff ghost * Fix lakitu transition widescreen * Rename and export credits text * Fixes --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
This commit is contained in:
+44
-15
@@ -9,6 +9,7 @@
|
||||
#include "vehicles/Bus.h"
|
||||
#include "vehicles/TankerTruck.h"
|
||||
#include "vehicles/Car.h"
|
||||
#include "vehicles/OBombKart.h"
|
||||
#include "TrainCrossing.h"
|
||||
#include <memory>
|
||||
|
||||
@@ -75,7 +76,7 @@ void World::AddCar(f32 speedA, f32 speedB, TrackWaypoint* path, uint32_t waypoin
|
||||
cars++;
|
||||
}
|
||||
|
||||
void World::ResetVehicles(void) {
|
||||
void World::ClearVehicles(void) {
|
||||
trains = trucks = busses = tankerTrucks = cars = boats = 0;
|
||||
Vehicles.clear();
|
||||
}
|
||||
@@ -86,6 +87,10 @@ TrainCrossing* World::AddCrossing(Vec3f position, u32 waypointMin, u32 waypointM
|
||||
return crossing.get();
|
||||
}
|
||||
|
||||
void World::AddBombKart(Vec3f pos, TrackWaypoint* waypoint, uint16_t waypointIndex, uint16_t state, f32 unk_3C) {
|
||||
BombKarts.push_back(std::make_unique<OBombKart>(pos, waypoint, waypointIndex, state, unk_3C));
|
||||
}
|
||||
|
||||
u32 World::GetCupIndex() {
|
||||
return this->CupIndex;
|
||||
}
|
||||
@@ -164,28 +169,52 @@ Object* World::AddObject(std::unique_ptr<GameObject> object) {
|
||||
return &rawPtr->o;
|
||||
}
|
||||
|
||||
AActor* World::AddActor(std::unique_ptr<AActor> actor) {
|
||||
AActor* rawPtr = actor.get();
|
||||
Actors.push_back(std::move(actor));
|
||||
return rawPtr;
|
||||
AActor* World::AddActor(AActor* actor) {
|
||||
Actors.push_back(actor);
|
||||
return Actors.back();
|
||||
}
|
||||
|
||||
struct Actor* World::AddBaseActor() {
|
||||
Actors.push_back(new AActor());
|
||||
// Skip C++ vtable to access variables in C
|
||||
return reinterpret_cast<struct Actor*>(reinterpret_cast<char*>(Actors.back()) + sizeof(void*));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a C struct Actor* to its C++ AActor class
|
||||
*/
|
||||
AActor* World::ConvertActorToAActor(Actor* actor) {
|
||||
// Move the ptr back so that it points at the vtable.
|
||||
// Which is the initial item in the class, or in other words
|
||||
// Point to the class.
|
||||
return reinterpret_cast<AActor*>((char*)actor - sizeof(void*));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a C++ AActor class to a C Actor* struct.
|
||||
*/
|
||||
Actor* World::ConvertAActorToActor(AActor* actor) {
|
||||
// Move the ptr forward past the vtable.
|
||||
// This allows C to access the class variables like a normal Actor* struct.
|
||||
return reinterpret_cast<Actor*>((char*)actor + sizeof(void*));
|
||||
}
|
||||
|
||||
AActor* World::GetActor(size_t index) {
|
||||
return Actors[index];
|
||||
}
|
||||
|
||||
void World::TickActors() {
|
||||
for (auto& actor : Actors) {
|
||||
actor->Tick();
|
||||
}
|
||||
}
|
||||
|
||||
void World::DrawActors(Camera* camera) {
|
||||
for (auto& actor : Actors) {
|
||||
actor->Draw(camera);
|
||||
for (AActor* actor : Actors) {
|
||||
if (actor->IsMod()) {
|
||||
actor->Tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveExpiredActors() {
|
||||
//Actors.erase(
|
||||
// Actors.erase(
|
||||
// std::remove_if(Actors.begin(), Actors.end(),
|
||||
// [](const std::unique_ptr<AActor>& actor) { return actor->uuid == 0; }), // Example condition
|
||||
// [](const std::unique_ptr<AActor>& actor) { return actor->uuid == 0; }),
|
||||
// Actors.end());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user