mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 05:43:42 -07:00
Logic class (#3812)
* Convert `Rando::Logic` to a class. * Readd `LogicReset` as `Logic::Reset` for resetting logic mid-generation-cycle to allow seed generation to actually work. * Change `IsChild` and `IsAdult` to `CanBe` variants. * Make it buildable. * First LogicVar class. * Revert CanBe changes to Is (adult & child) as I'm no longer sure that it's a good one. * Update soh/soh/OTRGlobals.cpp Use existing gRandoContext reference. Co-authored-by: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> * Conflict resolution cleanup (plus removing SaveContext references). --------- Co-authored-by: Pepe20129 <72659707+Pepe20129@users.noreply.github.com>
This commit is contained in:
parent
b96df0b642
commit
467ee7ad12
36 changed files with 2884 additions and 3215 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "soh/Enhancements/item-tables/ItemTableManager.h"
|
||||
#include "3drando/shops.hpp"
|
||||
#include "dungeon.h"
|
||||
#include "logic.h"
|
||||
#include "trial.h"
|
||||
#include "entrance.h"
|
||||
#include "settings.h"
|
||||
|
@ -18,11 +19,6 @@ namespace Rando {
|
|||
std::weak_ptr<Context> Context::mContext;
|
||||
|
||||
Context::Context() {
|
||||
StaticData::InitItemTable();
|
||||
StaticData::InitLocationTable();
|
||||
for (auto& location : StaticData::GetLocationTable()) {
|
||||
mSpoilerfileCheckNameToEnum[location.GetName()] = location.GetRandomizerCheck();
|
||||
}
|
||||
mSpoilerfileCheckNameToEnum["Invalid Location"] = RC_UNKNOWN_CHECK;
|
||||
mSpoilerfileCheckNameToEnum["Link's Pocket"] = RC_LINKS_POCKET;
|
||||
|
||||
|
@ -92,14 +88,23 @@ Context::Context() {
|
|||
}
|
||||
mEntranceShuffler = std::make_shared<EntranceShuffler>();
|
||||
mDungeons = std::make_shared<Dungeons>();
|
||||
mLogic = std::make_shared<Logic>();
|
||||
mTrials = std::make_shared<Trials>();
|
||||
mSettings = std::make_shared<Settings>();
|
||||
for (auto& location : StaticData::GetLocationTable()) {
|
||||
mSpoilerfileCheckNameToEnum[location.GetName()] = location.GetRandomizerCheck();
|
||||
}
|
||||
}
|
||||
|
||||
RandomizerArea Context::GetAreaFromString(std::string str) {
|
||||
return mSpoilerfileAreaNameToEnum[str];
|
||||
}
|
||||
|
||||
void Context::InitStaticData() {
|
||||
StaticData::InitItemTable();
|
||||
StaticData::InitLocationTable();
|
||||
}
|
||||
|
||||
std::shared_ptr<Context> Context::CreateInstance() {
|
||||
if (mContext.expired()) {
|
||||
auto instance = std::make_shared<Context>();
|
||||
|
@ -618,6 +623,17 @@ DungeonInfo* Context::GetDungeon(size_t key) const {
|
|||
return mDungeons->GetDungeon(static_cast<DungeonKey>(key));
|
||||
}
|
||||
|
||||
std::shared_ptr<Logic> Context::GetLogic() {
|
||||
if (mLogic.get() == nullptr) {
|
||||
mLogic = std::make_shared<Logic>();
|
||||
}
|
||||
return mLogic;
|
||||
}
|
||||
|
||||
void Context::ResetLogic() {
|
||||
mLogic->Reset();
|
||||
}
|
||||
|
||||
std::shared_ptr<Trials> Context::GetTrials() {
|
||||
return mTrials;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue