ksys/act: Implement ActorUtil "has tag" functions

This commit is contained in:
Léo Lam 2020-12-02 18:50:27 +01:00
parent 3559c31bc9
commit fc55c87f12
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 74 additions and 8 deletions

View File

@ -80190,12 +80190,12 @@
0x0000007100edd390,_ZNK4gsys16ModelSceneBuffer27isOutlineSilhouetteEnabled_Ev,36,
0x0000007100edd3b4,_ZN3act12hasTagByNameEP5ActorRKN4sead10SafeStringE,76,_ZN4ksys3act6hasTagEPNS0_5ActorERKN4sead14SafeStringBaseIcEE
0x0000007100edd400,_ZN3act12hasTagByNameERKN4sead10SafeStringES3_,124,_ZN4ksys3act6hasTagERKN4sead14SafeStringBaseIcEES5_
0x0000007100edd47c,_ZN3act6hasTagEP5ActorNS_3TagE,20,
0x0000007100edd490,_ZN3act6hasTagER12BaseProcLinkNS_3TagE,84,
0x0000007100edd4e4,_ZN3act6hasTagERKN4sead10SafeStringENS_3TagE,104,
0x0000007100edd54c,act::hasOneTagByNames_0,1160,
0x0000007100edd9d4,act::hasOneTagByNames,724,
0x0000007100eddca8,ActorAccessor::hasOneTagByNames,688,
0x0000007100edd47c,_ZN3act6hasTagEP5ActorNS_3TagE,20,_ZN4ksys3act6hasTagEPNS0_5ActorEj
0x0000007100edd490,_ZN3act6hasTagER12BaseProcLinkNS_3TagE,84,_ZN4ksys3act6hasTagEPNS0_12BaseProcLinkEj
0x0000007100edd4e4,_ZN3act6hasTagERKN4sead10SafeStringENS_3TagE,104,_ZN4ksys3act6hasTagERKN4sead14SafeStringBaseIcEEj
0x0000007100edd54c,act::hasOneTagByNames_0,1160,_ZN4ksys3act16hasOneTagAtLeastEPNS0_5ActorERKN4sead14SafeStringBaseIcEE
0x0000007100edd9d4,act::hasOneTagByNames,724,_ZN4ksys3act16hasOneTagAtLeastEPNS0_12BaseProcLinkERKN4sead14SafeStringBaseIcEE
0x0000007100eddca8,ActorAccessor::hasOneTagByNames,688,_ZN4ksys3act16hasOneTagAtLeastERKNS0_20ActorConstDataAccessERKN4sead14SafeStringBaseIcEE
0x0000007100eddf58,PlacementObj::shouldSkipSpawnWeatherStuff,108,
0x0000007100eddfc4,PlacementObj::isAnimalMasterAppearance,148,
0x0000007100ede058,PlacementObj::shouldSkipSpawnGodForestActor,256,

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

View File

@ -28,7 +28,7 @@ public:
const sead::SafeString& getProfile() const;
const sead::SafeString& getName() const;
bool hasTag(const sead::SafeString& tag) const;
bool hasTag(const char* tag) const;
bool hasTag(u32 tag) const;
u32 getId() const;
bool acquireConnectedCalcParent(ActorLinkConstDataAccess* accessor) const;

View File

@ -1,20 +1,83 @@
#include "KingSystem/ActorSystem/actActorUtil.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/ActorSystem/actActorConstDataAccess.h"
#include "KingSystem/ActorSystem/actActorParam.h"
#include "KingSystem/ActorSystem/actBaseProcLink.h"
#include "KingSystem/ActorSystem/actInfoData.h"
#include "KingSystem/Resource/resResourceActorLink.h"
namespace ksys::act {
static ActorConstDataAccess getAccessor(BaseProcLink* link) {
ActorConstDataAccess accessor;
acquireActor(link, &accessor);
return accessor;
}
bool hasTag(Actor* actor, const sead::SafeString& tag) {
if (!actor)
return false;
return actor->getParam()->getRes().mActorLink->hasTag(tag.cstr());
}
bool hasTag(BaseProcLink* link, const sead::SafeString& tag) {
return hasTag(getAccessor(link), tag);
}
bool hasTag(const ActorConstDataAccess& accessor, const sead::SafeString& tag) {
return accessor.hasTag(tag.cstr());
}
bool hasTag(const sead::SafeString& actor, const sead::SafeString& tag) {
auto* data = InfoData::instance();
return data && data->hasTag(actor.cstr(), tag.cstr());
}
bool hasTag(Actor* actor, u32 tag) {
return actor && actor->getParam()->getRes().mActorLink->hasTag(tag);
}
bool hasTag(BaseProcLink* link, u32 tag) {
return hasTag(getAccessor(link), tag);
}
bool hasTag(const ActorConstDataAccess& accessor, u32 tag) {
return accessor.hasTag(tag);
}
bool hasTag(const sead::SafeString& actor, u32 tag) {
auto* data = InfoData::instance();
return data && data->hasTag(actor.cstr(), tag);
}
bool hasOneTagAtLeast(Actor* actor, const sead::SafeString& tags) {
sead::FixedSafeString<32> tag;
for (auto it = tags.tokenBegin(","); tags.tokenEnd(",") != it; ++it) {
it.get(&tag);
if (hasTag(actor, tag))
return true;
}
return false;
}
bool hasOneTagAtLeast(BaseProcLink* link, const sead::SafeString& tags) {
sead::FixedSafeString<32> tag;
for (auto it = tags.tokenBegin(","); tags.tokenEnd(",") != it; ++it) {
it.get(&tag);
if (hasTag(link, tag))
return true;
}
return false;
}
bool act::hasOneTagAtLeast(const ActorConstDataAccess& accessor, const sead::SafeString& tags) {
sead::FixedSafeString<32> tag;
for (auto it = tags.tokenBegin(","); tags.tokenEnd(",") != it; ++it) {
it.get(&tag);
if (hasTag(accessor, tag))
return true;
}
return false;
}
} // namespace ksys::act

View File

@ -45,17 +45,20 @@ enum class ZukanType {
};
bool hasTag(Actor* actor, const sead::SafeString& tag);
bool hasTag(BaseProcLink* link, const sead::SafeString& tag);
bool hasTag(const ActorConstDataAccess& accessor, const sead::SafeString& tag);
bool hasTag(const sead::SafeString& actor, const sead::SafeString& tag);
bool hasTag(Actor* actor, u32 tag);
bool hasTag(BaseProcLink* link, u32 tag);
bool hasTag(const ActorConstDataAccess& accessor, u32 tag);
bool hasTag(const sead::SafeString& actor, u32 tag);
/// Checks whether the actor has at least one of the specified tags.
/// @param tags A comma separated list of tags.
bool hasOneTagAtLeast(Actor* actor, const sead::SafeString& tags);
bool hasOneTagAtLeast(BaseProcLink* link, const sead::SafeString& tags);
bool hasOneTagAtLeast(ActorConstDataAccess* accessor, const sead::SafeString& tags);
bool hasOneTagAtLeast(const ActorConstDataAccess& accessor, const sead::SafeString& tags);
bool shouldSkipSpawnForWeatherReasons(map::Object* obj);
bool isAnimalMasterAppearance(map::Object* obj);