ksys/world: Add and implement more WorldMgr functions

This commit is contained in:
Léo Lam 2021-04-30 14:39:14 +02:00
parent 5798b676fd
commit 9f6cdf69b4
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
11 changed files with 399 additions and 68 deletions

View File

@ -2911,8 +2911,8 @@
0x0000007100093d24,_ZN5uking6action20AnimTimingAttackMove11loadParams_Ev,248,_ZN5uking6action20AnimTimingAttackMove11loadParams_Ev
0x0000007100093e1c,_ZNK5uking6action20AnimTimingAttackMove27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE,288,_ZNK5uking6action20AnimTimingAttackMove27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x0000007100093f3c,_ZNK5uking6action20AnimTimingAttackMove18getRuntimeTypeInfoEv,92,_ZNK5uking6action20AnimTimingAttackMove18getRuntimeTypeInfoEv
0x0000007100093f98,j__ZdlPv_33,4,
0x0000007100093f9c,_ZN4sead19FixedSafeStringBaseIcLi32EEaSERKNS_14SafeStringBaseIcEE,240,
0x0000007100093f98,j__ZdlPv_33,4,_ZN4sead15FixedSafeStringILi9EED0Ev
0x0000007100093f9c,_ZN4sead15FixedSafeStringILi9EEaSERKNS_14SafeStringBaseIcEE,240,_ZN4sead15FixedSafeStringILi9EEaSERKNS_14SafeStringBaseIcEE
0x000000710009408c,AI_Action_AnmBackMove::ctor,84,
0x00000071000940e0,_ZN5uking6action11AnmBackMoveD1Ev,20,_ZN5uking6action11AnmBackMoveD1Ev
0x00000071000940f4,_ZN5uking6action11AnmBackMoveD0Ev,52,_ZN5uking6action11AnmBackMoveD0Ev
@ -56867,9 +56867,9 @@
0x00000071009a26cc,_ZN4sead15FixedSafeStringILi260EEaSERKNS_14SafeStringBaseIcEE,240,
0x00000071009a27bc,getLocationTypeName,428,
0x00000071009a2968,j__ZdlPv_496,4,
0x00000071009a296c,_ZN4sead15FixedSafeStringILi23EEaSERKNS_14SafeStringBaseIcEE,240,
0x00000071009a296c,xxx,240,
0x00000071009a2a5c,j__ZdlPv_497,4,
0x00000071009a2a60,_ZN4sead19FixedSafeStringBaseIcLi23EEaSERKNS_14SafeStringBaseIcEE,240,
0x00000071009a2a60,xxx,240,
0x00000071009a2b50,sub_71009A2B50,140,
0x00000071009a2bdc,sub_71009A2BDC,140,
0x00000071009a2c68,sub_71009A2C68,272,
@ -63424,10 +63424,10 @@
0x0000007100b0b3b8,_ZN4sead8RegionID8fromTextERKNS_14SafeStringBaseIcEE_0,880,
0x0000007100b0b728,sead::EnvUtil::getEnvVariable,8,
0x0000007100b0b730,_ZN4sead8RegionID8fromTextERKNS_14SafeStringBaseIcEE,428,
0x0000007100b0b8dc,j__ZdlPv_597,4,
0x0000007100b0b8e0,_ZN4sead19FixedSafeStringBaseIcLi36EEaSERKNS_14SafeStringBaseIcEE,240,
0x0000007100b0b9d0,j__ZdlPv_598,4,
0x0000007100b0b9d4,_ZN4sead15FixedSafeStringILi385EEaSERKNS_14SafeStringBaseIcEE,240,
0x0000007100b0b8dc,j__ZdlPv_597,4,_ZN4sead15FixedSafeStringILi23EED0Ev
0x0000007100b0b8e0,_ZN4sead15FixedSafeStringILi23EEaSERKNS_14SafeStringBaseIcEE,240,_ZN4sead15FixedSafeStringILi23EEaSERKNS_14SafeStringBaseIcEE
0x0000007100b0b9d0,j__ZdlPv_598,4,_ZN4sead19FixedSafeStringBaseIcLi23EED0Ev
0x0000007100b0b9d4,_ZN4sead19FixedSafeStringBaseIcLi23EEaSERKNS_14SafeStringBaseIcEE,240,_ZN4sead19FixedSafeStringBaseIcLi23EEaSERKNS_14SafeStringBaseIcEE
0x0000007100b0bac4,sub_7100B0BAC4,360,
0x0000007100b0bc2c,sub_7100B0BC2C,360,
0x0000007100b0bd94,_ZN4sead14PrintFormatter5flushEv,76,
@ -80009,10 +80009,10 @@
0x0000007100ed8af0,sub_7100ED8AF0,8,
0x0000007100ed8af8,_ZN4sead18Matrix34CalcCommonIfE18makeVectorRotationERNS_9BaseMtx34IfEERKNS_8BaseVec3IfEES8_,364,
0x0000007100ed8c64,sub_7100ED8C64,28,
0x0000007100ed8c80,getCurrentMapName,12,
0x0000007100ed8c8c,getCurrentMapType,12,
0x0000007100ed8c98,setCurrentMapTypeAndName,440,
0x0000007100ed8e50,setCurrentMapNameFromPos_,416,
0x0000007100ed8c80,getCurrentMapName,12,_ZN4ksys9StageInfo17getCurrentMapNameEv
0x0000007100ed8c8c,getCurrentMapType,12,_ZN4ksys9StageInfo17getCurrentMapTypeEv
0x0000007100ed8c98,setCurrentMapTypeAndName,440,_ZN4ksys9StageInfo13setCurrentMapERKN4sead14SafeStringBaseIcEES5_
0x0000007100ed8e50,setCurrentMapNameFromPos_,416,_ZN4ksys9StageInfo28setCurrentMapNameForFieldPosERKN4sead7Vector3IfEE
0x0000007100ed8ff0,sinitCurrentMapStrings,168,_GLOBAL__sub_I_StageInfo.cpp
0x0000007100ed9098,sub_7100ED9098,56,
0x0000007100ed90d0,sub_7100ED90D0,92,
@ -89575,28 +89575,28 @@
0x00000071010f3c74,WorldMgr::getCurrentClimateFogType,104,_ZNK4ksys5world7Manager10getFogTypeEv
0x00000071010f3cdc,WorldMgr::isCurrentClimateForbidComeback,96,_ZNK4ksys5world7Manager16isForbidComebackEv
0x00000071010f3d3c,WorldMgr::isClimateForbidComeback,92,_ZNK4ksys5world7Manager16isForbidComebackENS0_7ClimateE
0x00000071010f3d98,WorldMgr::unloadDgnenvAndGetWeatherMgr,76,
0x00000071010f3d98,WorldMgr::unloadDgnenvAndGetWeatherMgr,76,_ZN4ksys5world7Manager6unloadEv
0x00000071010f3de4,WorldMgr::ctor,728,_ZN4ksys5world7ManagerC1Ev!
0x00000071010f40bc,WorldMgr::init,836,_ZN4ksys5world7Manager4initEPN4sead4HeapE
0x00000071010f4400,WorldMgr::resetForStageUnload,84,
0x00000071010f4454,WorldMgr::loadBwinfo,148,
0x00000071010f4400,WorldMgr::resetForStageUnload,84,_ZN4ksys5world7Manager19resetForStageUnloadEv
0x00000071010f4454,WorldMgr::loadBwinfo,148,_ZN4ksys5world7Manager16loadWorldInfoResEv
0x00000071010f44e8,WorldMgr::loadWorldInfo,8668,
0x00000071010f66c4,WorldMgr::updateRemainsType,268,
0x00000071010f66c4,WorldMgr::updateRemainsType,268,_ZN4ksys5world7Manager17updateRemainsTypeEv
0x00000071010f67d0,WorldMgr::updateGraphicsMap,164,
0x00000071010f6874,sub_71010F6874,680,_ZN4ksys5world7ManagerD1Ev
0x00000071010f6b1c,sub_71010F6B1C,116,_ZN4ksys5world10DungeonEnvD2Ev
0x00000071010f6b90,sub_71010F6B90,76,_ZN4ksys5world9WorldInfoD2Ev
0x00000071010f6bdc,sub_71010F6BDC,36,_ZN4ksys5world7ManagerD0Ev
0x00000071010f6c00,WorldMgr::initBeforeStageGenB,32,
0x00000071010f6c20,WorldMgr::__auto4,32,
0x00000071010f6c40,WorldMgr::calc0,20,
0x00000071010f6c54,WorldMgr::getWeatherBlueskyRate,32,
0x00000071010f6c74,WorldMgr::getWeatherCloudyRate,32,
0x00000071010f6c94,WorldMgr::getWeatherRainRate,32,
0x00000071010f6cb4,WorldMgr::getWeatherHeavyRainRate,32,
0x00000071010f6cd4,WorldMgr::x_6,32,
0x00000071010f6c00,WorldMgr::initBeforeStageGenB,32,_ZN4ksys5world7Manager18initBeforeStageGenEv
0x00000071010f6c20,WorldMgr::__auto4,32,_ZN4ksys5world7Manager7unload2Ev
0x00000071010f6c40,WorldMgr::calc0,20,_ZN4ksys5world7Manager10clearArrayEv
0x00000071010f6c54,WorldMgr::getWeatherBlueskyRate,32,_ZNK4ksys5world7Manager21getWeatherBlueskyRateENS0_7ClimateE
0x00000071010f6c74,WorldMgr::getWeatherCloudyRate,32,_ZNK4ksys5world7Manager20getWeatherCloudyRateENS0_7ClimateE
0x00000071010f6c94,WorldMgr::getWeatherRainRate,32,_ZNK4ksys5world7Manager18getWeatherRainRateENS0_7ClimateE
0x00000071010f6cb4,WorldMgr::getWeatherHeavyRainRate,32,_ZNK4ksys5world7Manager23getWeatherHeavyRainRateENS0_7ClimateE
0x00000071010f6cd4,WorldMgr::x_6,32,_ZNK4ksys5world7Manager19getWeatherStormRateENS0_7ClimateE
0x00000071010f6cf4,WorldMgr::calc1,124,
0x00000071010f6d70,WorldMgr::calcManagers,276,
0x00000071010f6d70,WorldMgr::calcManagers,276,_ZN4ksys5world7Manager12calcManagersEPN4sead9WorkerMgrE
0x00000071010f6e84,WorldMgr::calc2,504,
0x00000071010f707c,WorldMgr::x_10,460,
0x00000071010f7248,WorldMgr::x_11,212,
@ -89611,31 +89611,31 @@
0x00000071010f7960,WorldMgr::getChemicalMgrFieldAE8,16,
0x00000071010f7970,WorldMgr::calcEntryJob,264,
0x00000071010f7a78,sub_71010F7A78,32,
0x00000071010f7a98,WorldMgr::setWindPower,28,
0x00000071010f7ab4,WorldMgr::setWind,44,
0x00000071010f7ae0,WorldMgr::x_12,20,
0x00000071010f7af4,sub_71010F7AF4,156,
0x00000071010f7a98,WorldMgr::setWindPower,28,_ZN4ksys5world7Manager10changeWindEibf
0x00000071010f7ab4,WorldMgr::setWind,44,_ZN4ksys5world7Manager13setManualWindEbN4sead7Vector3IfEEf
0x00000071010f7ae0,WorldMgr::x_12,20,_ZN4ksys5world7Manager15resetManualWindEv
0x00000071010f7af4,sub_71010F7AF4,156,_ZN4ksys5world7Manager19setDirectionalLightEff
0x00000071010f7b90,sub_71010F7B90,320,
0x00000071010f7cd0,WorldMgr::isClimate19Or5,24,
0x00000071010f7ce8,WorldMgr::someVectorNormCheck,340,
0x00000071010f7e3c,WorldMgr::getDungeonSizeType,692,
0x00000071010f80f0,WorldMgr::whatDungeonType,540,
0x00000071010f830c,WorldMgr::getLightLongitude,8,
0x00000071010f8314,sub_71010F8314,104,
0x00000071010f837c,WorldMgr::setFocusDist,20,
0x00000071010f8390,WorldMgr::callWeatherMgrClimateStuff2,32,
0x00000071010f83b0,WorldMgr::x_7,8,
0x00000071010f83b8,WorldMgr::setTemperatureDirectDay,64,
0x00000071010f83f8,WorldMgr::setTemperatureDirectNight,64,
0x00000071010f8438,WorldMgr::setIgnitedLevel,188,
0x00000071010f7cd0,WorldMgr::isClimate19Or5,24,_ZNK4ksys5world7Manager21isGerudoDesertClimateEv
0x00000071010f7ce8,WorldMgr::someVectorNormCheck,340,_ZNK4ksys5world7Manager22hasCameraOrPlayerMovedEf
0x00000071010f7e3c,WorldMgr::getDungeonSizeType,692,_ZNK4ksys5world7Manager14getDungeonSizeEv
0x00000071010f80f0,WorldMgr::whatDungeonType,540,_ZNK4ksys5world7Manager14getDungeonTypeEv
0x00000071010f830c,WorldMgr::getLightLongitude,8,_ZNK4ksys5world7Manager24getDungeonLightLongitudeEv
0x00000071010f8314,sub_71010F8314,104,_ZN4ksys5world7Manager31setCameraDistForRemainsElectricEN4sead7Vector3IfEE
0x00000071010f837c,WorldMgr::setFocusDist,20,_ZN4ksys5world7Manager12setFocusDistEf
0x00000071010f8390,WorldMgr::callWeatherMgrClimateStuff2,32,_ZN4ksys5world7Manager23rerollClimateWindPowersEv
0x00000071010f83b0,WorldMgr::x_7,8,_ZN4ksys5world7Manager20forceResetManualWindEv
0x00000071010f83b8,WorldMgr::setTemperatureDirectDay,64,_ZN4ksys5world7Manager17setTemperatureDayEf
0x00000071010f83f8,WorldMgr::setTemperatureDirectNight,64,_ZN4ksys5world7Manager19setTemperatureNightEf
0x00000071010f8438,WorldMgr::setIgnitedLevel,188,_ZN4ksys5world7Manager15setIgnitedLevelEifN4sead7Vector3IfEE?
0x00000071010f84f4,WorldMgr::__auto7,48,
0x00000071010f8524,WorldMgr::__auto17,32,
0x00000071010f8544,sub_71010F8544,64,_ZN4ksys5world9WorldInfoD0Ev
0x00000071010f8584,sub_71010F8584,104,_ZN4ksys5world10DungeonEnvD0Ev
0x00000071010f85ec,getDungeonSizeText,428,
0x00000071010f8798,j__ZdlPv_1204,4,
0x00000071010f879c,_ZN4sead15FixedSafeStringILi9EEaSERKNS_14SafeStringBaseIcEE,240,
0x00000071010f888c,sub_71010F888C,428,
0x00000071010f85ec,getDungeonSizeText,428,_ZN4ksys5world11DungeonSize5text_Ei
0x00000071010f8798,j__ZdlPv_1204,4,_ZN4sead19FixedSafeStringBaseIcLi9EED0Ev
0x00000071010f879c,_ZN4sead19FixedSafeStringBaseIcLi9EEaSERKNS_14SafeStringBaseIcEE,240,_ZN4sead19FixedSafeStringBaseIcLi9EEaSERKNS_14SafeStringBaseIcEE
0x00000071010f888c,sub_71010F888C,428,_ZN4ksys5world11DungeonType5text_Ei
0x00000071010f8a38,WorldMgr::Climate::ctor,696,_ZN4ksys5world11ClimateInfoC2Ev
0x00000071010f8cf0,sub_71010F8CF0,124,
0x00000071010f8d6c,sub_71010F8D6C,1028,

Can't render this file because it is too large.

@ -1 +1 @@
Subproject commit 037df8eb8524b686b4539241f586e880a54e9962
Subproject commit 2105e3e5591796112deef0f2ecce0a1e26e5004b

View File

@ -16,6 +16,7 @@ public:
void init(sead::Heap* heap);
Event* getActiveEvent() const;
bool hasActiveEvent() const;
sead::Heap* mEventHeap; // 0x1d180
};

View File

@ -5,7 +5,7 @@ namespace ksys {
static sead::Atomic<int> sUnused;
void (*StageInfo::sChangeScene)(const sead::SafeString& map_name, const sead::SafeString& pos_name,
int x, bool triggered_by_stage_select);
bool StageInfo::sIsNotDebugStage;
bool StageInfo::sIsNotDebugStageAndNotDungeon;
bool StageInfo::sIsMainFieldDungeon;
bool StageInfo::sIsDungeon;
bool StageInfo::sIsCDungeon;
@ -24,4 +24,26 @@ bool StageInfo::sIsMainField;
sead::FixedSafeString<32> StageInfo::sCurrentMapType;
sead::FixedSafeString<32> StageInfo::sCurrentMapName;
const sead::SafeString& StageInfo::getCurrentMapName() {
return sCurrentMapName;
}
const sead::SafeString& StageInfo::getCurrentMapType() {
return sCurrentMapType;
}
void StageInfo::setCurrentMap(const sead::SafeString& type, const sead::SafeString& name) {
sCurrentMapName = name;
sCurrentMapType = type;
}
void StageInfo::setCurrentMapNameForFieldPos(const sead::Vector3f& pos) {
if (!sIsNotDebugStageAndNotDungeon)
return;
sead::FixedSafeString<32> name;
name.format("%c-%c", (int(pos.x) + 5000) / 1000 + 'A', (int(pos.z) + 4000) / 1000 + '1');
sCurrentMapName = name;
}
} // namespace ksys

View File

@ -1,15 +1,31 @@
#pragma once
#include <math/seadVector.h>
#include <prim/seadSafeString.h>
#include <thread/seadAtomic.h>
namespace ksys {
enum class StageType {
Invalid = 0,
OpenWorld = 1,
Indoor = 2,
OpenWorldTest = 3,
MainFieldDungeon = 4,
Viewer = 5,
};
class StageInfo {
public:
static const sead::SafeString& getCurrentMapName();
static const sead::SafeString& getCurrentMapType();
static void setCurrentMap(const sead::SafeString& type, const sead::SafeString& name);
static void setCurrentMapNameForFieldPos(const sead::Vector3f& pos);
static void (*sChangeScene)(const sead::SafeString& map_name, const sead::SafeString& pos_name,
int x, bool triggered_by_stage_select);
static bool sIsNotDebugStage;
static bool sIsNotDebugStageAndNotDungeon;
static bool sIsMainFieldDungeon;
static bool sIsDungeon;
static bool sIsCDungeon;
@ -25,6 +41,8 @@ public:
static bool sIsFinalTrial;
static bool sIsAocField;
static bool sIsMainField;
private:
static sead::FixedSafeString<32> sCurrentMapType;
static sead::FixedSafeString<32> sCurrentMapName;
};

View File

@ -12,6 +12,9 @@ public:
JobType getType() const override { return JobType::Chemical; }
void initBeforeStageGen();
void unload2();
u8 _20[0xdc0 - 0x20];
};
KSYS_CHECK_SIZE_NX150(ChemicalMgr, 0xdc0);

View File

@ -1,6 +1,11 @@
#include "KingSystem/World/worldManager.h"
#include <cmath>
#include <container/seadSafeArray.h>
#include <math/seadMathCalcCommon.h>
#include <mc/seadWorkerMgr.h>
#include "KingSystem/Ecosystem/ecoSystem.h"
#include "KingSystem/Event/evtManager.h"
#include "KingSystem/Resource/resLoadRequest.h"
#include "KingSystem/Utils/InitTimeInfo.h"
namespace ksys::world {
@ -304,6 +309,13 @@ bool Manager::isForbidComeback(Climate climate) const {
return mWorldInfo.mClimates[int(climate)].forbidComeback.ref();
}
void Manager::unload() {
mStageType = {};
mWorldInfoLoadStatus = WorldInfoLoadStatus::Unloaded;
mDungeonEnv.mResHandle.requestUnload2();
getWeatherMgr()->onUnload();
}
// NON_MATCHING: stores in a different order (handwritten assignments?) but should be equivalent
Manager::Manager() = default;
@ -352,6 +364,31 @@ void Manager::init(sead::Heap* heap) {
mWorldInfoLoadStatus = WorldInfoLoadStatus::NotLoaded;
}
void Manager::resetForStageUnload() {
getTimeMgr()->resetForStageUnload();
getSkyMgr()->resetForStageUnload();
}
void Manager::loadWorldInfoRes() {
res::LoadRequest req(0x2000, 1, false);
req.mRequester = "wiWorldMgr";
mInfoRes = mWorldInfo.mResHandle.load("WorldMgr/normal.bwinfo", &req);
}
void Manager::updateRemainsType() {
if (StageInfo::getCurrentMapName().include("RemainsWind")) {
mRemainsType = RemainsType::Wind;
} else if (StageInfo::getCurrentMapName().include("RemainsElectric")) {
mRemainsType = RemainsType::Electric;
} else if (StageInfo::getCurrentMapName().include("RemainsFire")) {
mRemainsType = RemainsType::Fire;
} else if (StageInfo::getCurrentMapName().include("RemainsWater")) {
mRemainsType = RemainsType::Water;
} else if (StageInfo::getCurrentMapName().include("FinalTrial")) {
mRemainsType = RemainsType::FinalTrial;
}
}
Manager::~Manager() {
for (auto& mgr : mMgrs)
delete &mgr;
@ -361,4 +398,191 @@ Manager::~Manager() {
mWorldInfo.mClimates.freeBuffer();
}
void Manager::initBeforeStageGen() {
getChemicalMgr()->initBeforeStageGen();
}
void Manager::unload2() {
getChemicalMgr()->unload2();
}
void Manager::clearArray() {
mAtomicPtrArray.clear();
}
int Manager::getWeatherBlueskyRate(Climate climate) const {
return mWorldInfo.mClimates[int(climate)].weatherBlueskyRate.ref();
}
int Manager::getWeatherCloudyRate(Climate climate) const {
return mWorldInfo.mClimates[int(climate)].weatherCloudyRate.ref();
}
int Manager::getWeatherRainRate(Climate climate) const {
return mWorldInfo.mClimates[int(climate)].weatherRainRate.ref();
}
int Manager::getWeatherHeavyRainRate(Climate climate) const {
return mWorldInfo.mClimates[int(climate)].weatherHeavyRainRate.ref();
}
int Manager::getWeatherStormRate(Climate climate) const {
return mWorldInfo.mClimates[int(climate)].weatherStormRate.ref();
}
void Manager::calcManagers(sead::WorkerMgr* worker_mgr) {
if (_5e0.isOffBit(0))
worker_mgr = nullptr;
sead::CoreIdMask cores{sead::CoreId::cMain, sead::CoreId::cSub1, sead::CoreId::cSub2};
mJobQueue.clear();
if (worker_mgr) {
for (auto& mgr : mMgrs)
mJobQueue.enque(&mgr);
worker_mgr->pushJobQueue("calc", &mJobQueue, cores, sead::SyncType::cNoSync,
sead::JobQueuePushType::cForward);
} else {
for (auto& mgr : mMgrs)
mgr.invoke();
}
}
void Manager::changeWind(int direction, bool enable_auto_wind, float speed) {
mManualWindTimer = 10;
mWindDirectionType = direction;
mManualWindSpeed = speed;
mEnableAutoWind = enable_auto_wind;
}
void Manager::setManualWind(bool enable_auto_wind, sead::Vector3f dir, float speed) {
mManualWindTimer = 10;
mWindDirectionType = -1;
mWindDir = dir;
mManualWindSpeed = speed;
mEnableAutoWind = enable_auto_wind;
}
void Manager::resetManualWind() {
if (mManualWindTimer <= 1)
mManualWindTimer = 0;
}
void Manager::setDirectionalLight(float angle_x, float angle_y) {
const auto x_rad = sead::Mathf::deg2rad(angle_x);
const auto y_rad = sead::Mathf::deg2rad(angle_y);
mDirectionalLightVecA.x = std::cos(x_rad) * std::sin(y_rad);
mDirectionalLightVecA.y = std::sin(x_rad);
mDirectionalLightVecA.z = std::cos(x_rad) * std::cos(y_rad);
mDirectionalLightVecB = mDirectionalLightVecA;
mDirectionalLightTimer = 1;
}
bool Manager::isGerudoDesertClimate() const {
if (mCurrentClimate != Climate::GerudoDesertClimate &&
mCurrentClimate != Climate::GerudoDesertClimateLv2) {
return false;
}
return true;
}
bool Manager::hasCameraOrPlayerMoved(float distance_threshold) const {
const auto camera_dist = sead::norm2(mCameraPos - mPrevCameraPos);
const auto player_dist = sead::norm2(mPlayerPos - mPrevPlayerPos);
const bool moved = player_dist >= distance_threshold || camera_dist >= distance_threshold;
if (sead::norm2(mPlayerPos - mPrevPlayerPos) <= 100.0 &&
evt::Manager::instance()->hasActiveEvent()) {
return false;
}
return moved;
}
int Manager::getDungeonSize() const {
for (int i = 0; i < DungeonSize::size(); ++i) {
if (mDungeonEnv.mDungeonSize.ref() == DungeonSize::text(i))
return DungeonSize(i);
}
return DungeonSize::XL;
}
int Manager::getDungeonType() const {
for (int i = 0; i < DungeonType::size(); ++i) {
if (mDungeonEnv.mDungeonType.ref() == DungeonType::text(i))
return DungeonType(i);
}
return DungeonType::Gimmick;
}
float Manager::getDungeonLightLongitude() const {
return mDungeonEnv.mLightLongitude.ref();
}
void Manager::setCameraDistForRemainsElectric(sead::Vector3f pos) {
_7ac = 10;
_770 = sead::norm2(mCameraPos - pos);
}
void Manager::setFocusDist(float dist) {
_720 = 2;
_7b8 = 2;
mFocusDist = dist;
}
void Manager::rerollClimateWindPowers() {
getWeatherMgr()->rerollClimateWindPowers();
}
void Manager::forceResetManualWind() {
mManualWindTimer = 0;
}
void Manager::setTemperatureDay(float temp) {
/// @bug this should be a strict inequality (<), not <=
if (mTempDirectDay <= 99999) {
if (temp > 0.0) {
if (mTempDirectDay > temp)
return;
} else {
if (mTempDirectDay < temp)
return;
}
}
mTempDirectDay = temp;
mTempDirectDayTimer = 4;
}
void Manager::setTemperatureNight(float temp) {
/// @bug this should be a strict inequality (<), not <=
if (mTempDirectNight <= 99999) {
if (temp > 0.0) {
if (mTempDirectNight > temp)
return;
} else {
if (mTempDirectNight < temp)
return;
}
}
mTempDirectNight = temp;
mTempDirectNightTimer = 4;
}
// NON_MATCHING: mPlayerPos.y gets loaded into s8 instead of w20
void Manager::setIgnitedLevel(int level, float radius, sead::Vector3f center) {
mIgnitedTimer = 4;
mIgnitedRadius = radius;
mIgnitedCenter = center;
const sead::Vector3f unk_center{-2004, mPlayerPos.y, 1710};
mIgnitedLevel = level;
if (sead::norm2(mPlayerPos - unk_center) < 20.0) {
mIgnitedCenter = unk_center;
mIgnitedRadius = 7.0;
}
}
} // namespace ksys::world

View File

@ -9,8 +9,10 @@
#include <container/seadSafeArray.h>
#include <hostio/seadHostIONode.h>
#include <mc/seadJobQueue.h>
#include <prim/seadEnum.h>
#include <prim/seadSizedEnum.h>
#include "KingSystem/Resource/resHandle.h"
#include "KingSystem/System/StageInfo.h"
#include "KingSystem/Utils/Types.h"
#include "KingSystem/World/worldChemicalMgr.h"
#include "KingSystem/World/worldCloudMgr.h"
@ -22,8 +24,15 @@
#include "KingSystem/World/worldWeatherMgr.h"
#include "KingSystem/World/worldWindMgr.h"
namespace sead {
class WorkerMgr;
}
namespace ksys::world {
SEAD_ENUM(DungeonSize, S,M,L,XL)
SEAD_ENUM(DungeonType, Gimmick,Enemy,Treasure)
enum class CalcType {
_0 = 0,
_1 = 1,
@ -31,17 +40,12 @@ enum class CalcType {
Invalid = 3,
};
enum class StageType {
Invalid = 0,
OpenWorld = 1,
Indoor = 2,
OpenWorldTest = 3,
MainFieldDungeon = 4,
Viewer = 5,
};
enum class RemainsType {
Wind,
Electric,
Fire,
Water,
FinalTrial,
};
enum class FieldType {
@ -146,7 +150,7 @@ public:
res::Handle mResHandle;
agl::utl::Parameter<float> mLightLongitude;
agl::utl::Parameter<sead::FixedSafeString<32>> mDungeonSize;
agl::utl::Parameter<sead::FixedSafeString<32>> mString538;
agl::utl::Parameter<sead::FixedSafeString<32>> mDungeonType;
agl::utl::ParameterObj mDungeonEnvObj;
};
KSYS_CHECK_SIZE_NX150(DungeonEnv, 0x338);
@ -199,6 +203,53 @@ public:
void updateRemainsType();
void updateGraphicsMap(StageType type);
void initBeforeStageGen();
void unload2();
void clearArray();
int getWeatherBlueskyRate(Climate climate) const;
int getWeatherCloudyRate(Climate climate) const;
int getWeatherRainRate(Climate climate) const;
int getWeatherHeavyRainRate(Climate climate) const;
int getWeatherStormRate(Climate climate) const;
void calc1(sead::WorkerMgr* mgr);
void calc2(sead::WorkerMgr* mgr);
void calc3(sead::WorkerMgr* mgr);
// TODO: more Chemical functions
void updateChemicalFarObj();
void calcEntryJob();
void changeWind(int direction, bool enable_auto_wind, float speed);
void setManualWind(bool enable_auto_wind, sead::Vector3f dir, float speed);
void resetManualWind();
void setDirectionalLight(float angle_x, float angle_y);
void setDirectionalLightYang(float value);
bool isGerudoDesertClimate() const;
bool hasCameraOrPlayerMoved(float distance_threshold) const;
int getDungeonSize() const;
int getDungeonType() const;
float getDungeonLightLongitude() const;
void setCameraDistForRemainsElectric(sead::Vector3f pos);
void setFocusDist(float dist);
void rerollClimateWindPowers();
void forceResetManualWind();
void setTemperatureDay(float temp);
void setTemperatureNight(float temp);
void setIgnitedLevel(int level, float radius, sead::Vector3f center);
void onEventFlowEnd();
// TODO: more functions
bool isMainField() const { return mIsMainField && mStageType == StageType::OpenWorld; }
bool isAocField() const {
@ -229,6 +280,11 @@ private:
void overrideWindSpeed(float* wind_speed) const;
void calcManagers(sead::WorkerMgr* worker_mgr);
void updateOverrides();
void updateTimers();
void updateWindDirections();
WorldInfo mWorldInfo;
DungeonEnv mDungeonEnv;
sead::DirectResource* mInfoRes{};
@ -258,7 +314,7 @@ private:
sead::Vector3f mWindDir{0, 0, -1};
sead::Vector3f mDirectionalLightVecA{0, 1, 0};
sead::Vector3f mDirectionalLightVecB{0, 1, 0};
sead::Vector3f _748{0, 0, 0};
sead::Vector3f mIgnitedCenter{0, 0, 0};
float mClimateTransitionProgress = 1.0;
float mMapEdgeWindSpeed = 1.0;
float mManualWindSpeed = 5.0;
@ -268,22 +324,22 @@ private:
float mTempDirectNight = 99999.9;
float _770 = 0.0;
float mFocusDist = 100.0;
float _778 = -1.0;
float mIgnitedRadius = -1.0;
u32 _77c = 9;
Climate mCurrentClimate{};
Climate mPrevClimate{};
u32 mWindDirectionType = 0;
u32 mManualWindTimer = 0;
int mWindDirectionType = 0;
int mManualWindTimer = 0;
u32 mMapEdgeWindDirectionType = 0;
u32 _794 = 0;
int _798 = -1;
u32 _79c = 0;
u32 _7a0 = 0;
u32 _7a4 = 0;
u32 _7a8 = 0;
int mTempDirectDayTimer = 0;
int mTempDirectNightTimer = 0;
u32 _7ac = 0;
u32 _7b0 = 0;
u32 mIgnitedLevel = 0;
int mIgnitedTimer = 0;
int mIgnitedLevel = 0;
u32 _7b8 = 0;
RemainsType mRemainsType{};
FieldType mFieldType{};
@ -293,7 +349,7 @@ private:
WorldInfoLoadStatus mWorldInfoLoadStatus = WorldInfoLoadStatus::NotLoaded;
sead::SizedEnum<WeatherType, u8> mWeatherType = WeatherType::Invalid;
u8 mDirectionalLightTimer = 0;
bool mWindChangesEnabled = true;
bool mEnableAutoWind = true;
bool mMapEdgeWindEnabled = false;
bool _7d5 = false;
bool mWeatherSetForDemo = false;

View File

@ -12,6 +12,8 @@ public:
JobType getType() const override { return JobType::Sky; }
void resetForStageUnload();
u8 _20[0x6b618 - 0x20];
};
KSYS_CHECK_SIZE_NX150(SkyMgr, 0x6b618);

View File

@ -12,6 +12,8 @@ public:
JobType getType() const override { return JobType::Time; }
void resetForStageUnload();
u8 _20[0x158 - 0x20];
};
KSYS_CHECK_SIZE_NX150(TimeMgr, 0x158);

View File

@ -12,6 +12,9 @@ public:
JobType getType() const override { return JobType::Weather; }
void onUnload();
void rerollClimateWindPowers();
u8 _20[0x398 - 0x20];
};
KSYS_CHECK_SIZE_NX150(WeatherMgr, 0x398);