diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2025-11-14 14:50:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-14 14:50:33 -0700 |
| commit | fffd3f7fe92c6eb45b68c0ca522066bf9c54abb2 (patch) | |
| tree | 3dace8aa5a702dddfc0e5d7d7fde948c358a67dd /src/engine/RaceManager.cpp | |
| parent | c2755aee40bb37c8440ec58f260b4bd36bd6e256 (diff) | |
RaceManager class (#562)
* Create RaceManager.cpp
* Create RaceManager class for race lifecycle management
Added RaceManager class to manage race events lifecycle.
* Refactor World class and implement ClearWorld method
Refactor World class constructor and destructor. Implement ClearWorld method to delete all objects and reset state.
* Add RaceManager to World class
* Update ValidateString for editor mode checks
Refactor ValidateString to handle editor mode and empty strings.
* Update Text.cpp
* Add SetText method to Text class
* Document RunGarbageCollector function
Added documentation for the RunGarbageCollector function.
* Refactor Game.cpp by removing dead code
Removed unused ruleset handling and clean-up code.
* Update Game.h
* Remove CM_SpawnFromLevelProps call
* Update Text.cpp
* Update World.cpp
* Add Clean method to RaceManager class
* Update RaceManager.cpp
* Update World.cpp
* Update World.h
* Update World.cpp
Diffstat (limited to 'src/engine/RaceManager.cpp')
| -rw-r--r-- | src/engine/RaceManager.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/engine/RaceManager.cpp b/src/engine/RaceManager.cpp new file mode 100644 index 000000000..ae1ef828f --- /dev/null +++ b/src/engine/RaceManager.cpp @@ -0,0 +1,77 @@ +#include "RaceManager.h" + +#include "AllActors.h" +#include "World.h" +#include "port/Game.h" +#include "engine/editor/Editor.h" +#include "engine/editor/SceneManager.h" + +extern "C" { +#include "render_courses.h" +} + +RaceManager::RaceManager(World& world) : WorldContext(world) { +} + +void RaceManager::Load() { + if (WorldContext.CurrentCourse) { + WorldContext.CurrentCourse->Load(); + } +} + +void RaceManager::PreInit() { + // Ruleset options + if (CVarGetInteger("gDisableItemboxes", false) == true) { + gPlaceItemBoxes = false; + } else { + gPlaceItemBoxes = true; + } +} + +void RaceManager::BeginPlay() { + auto course = WorldContext.CurrentCourse; + + if (course) { + // Do not spawn finishline in credits or battle mode. And if bSpawnFinishline. + if ((gGamestate != CREDITS_SEQUENCE) && (gModeSelection != BATTLE)) { + if (course->bSpawnFinishline) { + if (course->FinishlineSpawnPoint.has_value()) { + AFinishline::Spawn(course->FinishlineSpawnPoint.value(), IRotator(0, 0, 0)); + } else { + AFinishline::Spawn(); + } + + } + } + gEditor.AddLight("Sun", nullptr, D_800DC610[1].l->l.dir); + + course->BeginPlay(); + } +} + +void RaceManager::PostInit() { + // Ruleset options + if (CVarGetInteger("gAllThwompsAreMarty", false) == true) { + for (auto object : gWorldInstance.Objects) { + if (OThwomp* thwomp = dynamic_cast<OThwomp*>(object)) { + gObjectList[thwomp->_objectIndex].unk_0D5 = OThwomp::States::JAILED; // Sets all the thwomp behaviour flags to marty + thwomp->Behaviour = OThwomp::States::JAILED; + } + } + } + + if (CVarGetInteger("gAllBombKartsChase", false) == true) { + for (auto object : gWorldInstance.Objects) { + if (OBombKart* kart = dynamic_cast<OBombKart*>(object)) { + kart->Behaviour = OBombKart::States::CHASE; + } + } + } + + if (CVarGetInteger("gGoFish", false) == true) { + OTrophy::Spawn(FVector(0,0,0), OTrophy::TrophyType::GOLD, OTrophy::Behaviour::GO_FISH); + } +} + +void RaceManager::Clean() { +} |
