diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 21e382c9..7c34abf2 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -73409,13 +73409,13 @@ 0x0000007100d30d74,ActorInfoData::isAmiiboDrop,92,_ZNK4ksys3act8InfoData12hasDropEntryEPKcS3_ 0x0000007100d30dd0,ActorInfoData::getActorInstSize,20,_ZNK4ksys3act8InfoData11getInstSizeEPKc 0x0000007100d30de4,ActorInfoData::getBugMask,20,_ZNK4ksys3act8InfoData10getBugMaskEPKc -0x0000007100d30df8,sub_7100D30DF8,64, -0x0000007100d30e38,sub_7100D30E38,408, -0x0000007100d30fd0,sub_7100D30FD0,408, +0x0000007100d30df8,sub_7100D30DF8,64,_ZNK4ksys3act8InfoData21InvalidLifeConditions28containsCurrentTimeOrWeatherERKN4sead7Vector3IfEE +0x0000007100d30e38,sub_7100D30E38,408,_ZNK4ksys3act8InfoData21InvalidLifeConditions19containsCurrentTimeEv +0x0000007100d30fd0,sub_7100D30FD0,408,_ZNK4ksys3act8InfoData21InvalidLifeConditions22containsCurrentWeatherERKN4sead7Vector3IfEE 0x0000007100d31168,ActorInfoData::x_0,712,_ZNK4ksys3act8InfoData13getModelFlagsEPKc 0x0000007100d31430,sub_7100D31430,328,_ZNK4ksys3act8InfoData19getVariationMatAnimEPKcPS3_Pf 0x0000007100d31578,ActorInfoData::getStringFromByaml,168,_ZNK4ksys3act8InfoData7getNameEPN2al9ByamlIterEPPKci -0x0000007100d31620,getTimeSubTypeString,428, +0x0000007100d31620,getTimeSubTypeString,428,_ZN4ksys5world8TimeType5text_Ei 0x0000007100d317cc,AI_Action_DemoGetItem::ctor,48,_ZN5uking6action11DemoGetItemC1ERKN4ksys3act2ai10ActionBase7InitArgE 0x0000007100d317fc,_ZN5uking6action11DemoGetItemD1Ev,20,_ZN5uking6action11DemoGetItemD1Ev 0x0000007100d31810,_ZN5uking6action11DemoGetItemD0Ev,52,_ZN5uking6action11DemoGetItemD0Ev diff --git a/src/KingSystem/ActorSystem/actInfoData.cpp b/src/KingSystem/ActorSystem/actInfoData.cpp index 5c7ef40c..94fb092d 100644 --- a/src/KingSystem/ActorSystem/actInfoData.cpp +++ b/src/KingSystem/ActorSystem/actInfoData.cpp @@ -11,6 +11,7 @@ #include "KingSystem/Utils/Byaml/ByamlArrayIter.h" #include "KingSystem/Utils/Byaml/ByamlData.h" #include "KingSystem/Utils/Byaml/ByamlHashIter.h" +#include "KingSystem/World/worldManager.h" namespace ksys::act { @@ -717,4 +718,36 @@ bool InfoData::getName(al::ByamlIter* iter, const char** name, s32 idx) const { return iter->tryConvertString(name, &data); } +bool InfoData::InvalidLifeConditions::containsCurrentTimeOrWeather( + const sead::Vector3f& pos) const { + return containsCurrentTime() || containsCurrentWeather(pos); +} + +bool InfoData::InvalidLifeConditions::containsCurrentTime() const { + if (num_times < 1 || !world::Manager::instance() || world::Manager::instance()->isAocField()) { + return false; + } + const char* time_type_name = + world::TimeType::text(world::Manager::instance()->getTimeMgr()->getTimeType()); + for (int i = 0; i < num_times; i++) { + if (times[i] == time_type_name) + return true; + } + return false; +} + +bool InfoData::InvalidLifeConditions::containsCurrentWeather(const sead::Vector3f& pos) const { + if (num_weathers < 1 || !world::Manager::instance() || + world::Manager::instance()->isAocField()) { + return false; + } + auto current_weather = world::WeatherType(world::Manager::instance()->sub_71010F337C(pos)); + const char* current_weather_name = world::Manager::getWeatherTypeString(current_weather); + for (int i = 0; i < num_weathers; i++) { + if (weathers[i] == current_weather_name) + return true; + } + return false; +} + } // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actInfoData.h b/src/KingSystem/ActorSystem/actInfoData.h index b4f20b63..bd23551c 100644 --- a/src/KingSystem/ActorSystem/actInfoData.h +++ b/src/KingSystem/ActorSystem/actInfoData.h @@ -74,6 +74,10 @@ public: sead::SafeArray times; s32 num_weathers; sead::SafeArray weathers; + + bool containsCurrentTimeOrWeather(const sead::Vector3f& pos) const; + bool containsCurrentTime() const; + bool containsCurrentWeather(const sead::Vector3f& pos) const; }; KSYS_CHECK_SIZE_NX150(InvalidLifeConditions, 0x210); diff --git a/src/KingSystem/World/worldManager.h b/src/KingSystem/World/worldManager.h index 2eb13ac0..7b40cb03 100644 --- a/src/KingSystem/World/worldManager.h +++ b/src/KingSystem/World/worldManager.h @@ -208,6 +208,9 @@ public: bool worldInfoLoaded() const { return mWorldInfoLoadStatus != WorldInfoLoadStatus::NotLoaded; } + u8 sub_71010F337C(const sead::Vector3f& pos); // TODO implement this : 0x71010F337C - maybe has + // a different parameter type + private: enum class WorldInfoLoadStatus : u8 { NotLoaded, diff --git a/src/KingSystem/World/worldTimeMgr.h b/src/KingSystem/World/worldTimeMgr.h index 107b5836..ba374793 100644 --- a/src/KingSystem/World/worldTimeMgr.h +++ b/src/KingSystem/World/worldTimeMgr.h @@ -91,6 +91,7 @@ public: bool isTimeFlowingNormally() const; int getTimeDivision() const { return mTimeDivision; } + int getTimeType() const { return mTimeType; } sead::DelegateEvent& getNewDaySignal() { return mNewDaySignal; } float getTimeStep() const { return mTimeStep; } float getBloodMoonTimer() const { return mBloodMoonTimer; }