mirror of https://github.com/zeldaret/botw.git
parent
9d4dbaf815
commit
802be64d8e
|
@ -74660,28 +74660,28 @@ Address,Quality,Size,Name
|
|||
0x0000007100d78e30,U,000032,
|
||||
0x0000007100d78e50,U,000252,
|
||||
0x0000007100d78f4c,U,000776,
|
||||
0x0000007100d79254,U,000100,
|
||||
0x0000007100d792b8,U,000108,
|
||||
0x0000007100d79324,U,000220,Awareness::createInstance
|
||||
0x0000007100d79400,U,000088,Awareness::deleteInstance
|
||||
0x0000007100d79458,U,000124,
|
||||
0x0000007100d794d4,U,000160,
|
||||
0x0000007100d79254,O,000100,_ZN4ksys3act9Awareness18SingletonDisposer_D1Ev
|
||||
0x0000007100d792b8,O,000108,_ZN4ksys3act9Awareness18SingletonDisposer_D0Ev
|
||||
0x0000007100d79324,O,000220,_ZN4ksys3act9Awareness14createInstanceEPN4sead4HeapE
|
||||
0x0000007100d79400,O,000088,_ZN4ksys3act9Awareness14deleteInstanceEv
|
||||
0x0000007100d79458,O,000124,_ZN4ksys3act9Awareness9Instances16registerInstanceEPNS0_17AwarenessInstanceE
|
||||
0x0000007100d794d4,O,000160,_ZN4ksys3act9Awareness9Instances18deregisterInstanceEPNS0_17AwarenessInstanceE
|
||||
0x0000007100d79574,U,000100,
|
||||
0x0000007100d795d8,U,000104,
|
||||
0x0000007100d79640,U,000132,
|
||||
0x0000007100d796c4,U,000128,
|
||||
0x0000007100d79744,U,000132,
|
||||
0x0000007100d797c8,U,000132,
|
||||
0x0000007100d7984c,U,000100,
|
||||
0x0000007100d798b0,U,000300,
|
||||
0x0000007100d7984c,O,000100,_ZN4ksys3act9AwarenessD1Ev
|
||||
0x0000007100d798b0,O,000300,_ZN4ksys3act9Awareness8finalizeEv
|
||||
0x0000007100d799dc,U,000020,
|
||||
0x0000007100d799f0,U,000108,
|
||||
0x0000007100d79a5c,U,000468,Awareness::init
|
||||
0x0000007100d79c30,U,002528,Awareness::loadSystemData
|
||||
0x0000007100d7a610,U,000100,Awareness::initBeforeStageGenB
|
||||
0x0000007100d7a674,U,000104,Awareness::setPauseState
|
||||
0x0000007100d7a6dc,U,000108,Awareness::__auto1
|
||||
0x0000007100d7a748,U,000500,Awareness::calc
|
||||
0x0000007100d799f0,O,000108,_ZN4ksys3act9AwarenessD0Ev
|
||||
0x0000007100d79a5c,O,000468,_ZN4ksys3act9Awareness4initERKNS1_7InitArgEPN4sead4HeapE
|
||||
0x0000007100d79c30,m,002528,_ZN4ksys3act9Awareness14loadSystemDataEv
|
||||
0x0000007100d7a610,O,000100,_ZN4ksys3act9Awareness18initBeforeStageGenEv
|
||||
0x0000007100d7a674,O,000104,_ZN4ksys3act9Awareness9setPausedEb
|
||||
0x0000007100d7a6dc,O,000108,_ZN4ksys3act9Awareness14setEventActiveEb
|
||||
0x0000007100d7a748,O,000500,_ZN4ksys3act9Awareness4calcEv
|
||||
0x0000007100d7a93c,U,000232,
|
||||
0x0000007100d7aa24,U,000116,
|
||||
0x0000007100d7aa98,U,000008,
|
||||
|
@ -74692,36 +74692,36 @@ Address,Quality,Size,Name
|
|||
0x0000007100d7ab40,U,000128,
|
||||
0x0000007100d7abc0,U,000128,
|
||||
0x0000007100d7ac40,U,000052,
|
||||
0x0000007100d7ac74,U,000004,nullsub_3802
|
||||
0x0000007100d7ac78,U,000004,j__ZdlPv_862
|
||||
0x0000007100d7ac7c,U,000032,_ZN4sead10OrderedSetIiE4Node6erase_Ev
|
||||
0x0000007100d7ac9c,U,000416,
|
||||
0x0000007100d7ae3c,U,000004,nullsub_3803
|
||||
0x0000007100d7ae40,U,000004,j__ZdlPv_863
|
||||
0x0000007100d7ae44,U,000032,
|
||||
0x0000007100d7ae64,U,000416,
|
||||
0x0000007100d7b004,U,000004,nullsub_3804
|
||||
0x0000007100d7b008,U,000004,j__ZdlPv_864
|
||||
0x0000007100d7b00c,U,000032,_ZN4sead10StrTreeMapILi64EiE4Node6erase_Ev
|
||||
0x0000007100d7b02c,U,000416,
|
||||
0x0000007100d7b1cc,U,000016,
|
||||
0x0000007100d7b1dc,U,000116,
|
||||
0x0000007100d7b250,U,000048,
|
||||
0x0000007100d7b280,U,000092,
|
||||
0x0000007100d7b2dc,U,000008,
|
||||
0x0000007100d7b2e4,U,000008,
|
||||
0x0000007100d7b2ec,U,000016,
|
||||
0x0000007100d7b2fc,U,000116,
|
||||
0x0000007100d7b370,U,000048,
|
||||
0x0000007100d7b3a0,U,000092,
|
||||
0x0000007100d7b3fc,U,000008,
|
||||
0x0000007100d7b404,U,000008,
|
||||
0x0000007100d7b40c,U,000016,
|
||||
0x0000007100d7b41c,U,000116,
|
||||
0x0000007100d7b490,U,000048,
|
||||
0x0000007100d7b4c0,U,000092,
|
||||
0x0000007100d7b51c,U,000008,
|
||||
0x0000007100d7b524,U,000008,
|
||||
0x0000007100d7ac74,O,000004,_ZN4sead11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness12TerrorFilterEEEED2Ev
|
||||
0x0000007100d7ac78,O,000004,_ZN4sead10OrderedSetIN4ksys3act9Awareness12TerrorFilterEE4NodeD0Ev
|
||||
0x0000007100d7ac7c,O,000032,_ZN4sead10OrderedSetIN4ksys3act9Awareness12TerrorFilterEE4Node6erase_Ev
|
||||
0x0000007100d7ac9c,O,000416,_ZN4sead11TreeMapImplINS_18OrderedSetItemImplIN4ksys3act9Awareness12TerrorFilterEEEE6insertEPNS_11TreeMapNodeIS6_EESA_
|
||||
0x0000007100d7ae3c,O,000004,_ZN4sead11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness12SensorFilterEEEED2Ev
|
||||
0x0000007100d7ae40,O,000004,_ZN4sead10OrderedSetIN4ksys3act9Awareness12SensorFilterEE4NodeD0Ev
|
||||
0x0000007100d7ae44,O,000032,_ZN4sead10OrderedSetIN4ksys3act9Awareness12SensorFilterEE4Node6erase_Ev
|
||||
0x0000007100d7ae64,O,000416,_ZN4sead11TreeMapImplINS_18OrderedSetItemImplIN4ksys3act9Awareness12SensorFilterEEEE6insertEPNS_11TreeMapNodeIS6_EESA_
|
||||
0x0000007100d7b004,O,000004,_ZN4sead11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness18SensorFilterBufferEEEED2Ev
|
||||
0x0000007100d7b008,O,000004,_ZN4sead10OrderedSetIN4ksys3act9Awareness18SensorFilterBufferEE4NodeD0Ev
|
||||
0x0000007100d7b00c,O,000032,_ZN4sead10OrderedSetIN4ksys3act9Awareness18SensorFilterBufferEE4Node6erase_Ev
|
||||
0x0000007100d7b02c,O,000416,_ZN4sead11TreeMapImplINS_18OrderedSetItemImplIN4ksys3act9Awareness18SensorFilterBufferEEEE6insertEPNS_11TreeMapNodeIS6_EESA_
|
||||
0x0000007100d7b1cc,O,000016,_ZN4sead10OrderedSetIN4ksys3act9Awareness12TerrorFilterEE18eraseNodeForClear_EPNS_11TreeMapNodeINS_18OrderedSetItemImplIS4_EEEE
|
||||
0x0000007100d7b1dc,O,000116,_ZN4sead11TreeMapImplINS_18OrderedSetItemImplIN4ksys3act9Awareness12TerrorFilterEEEE7forEachINS_9Delegate1INS_10OrderedSetIS5_EEPNS_11TreeMapNodeIS6_EEEEEEvSE_RKT_
|
||||
0x0000007100d7b250,O,000048,_ZN4sead9Delegate1INS_10OrderedSetIN4ksys3act9Awareness12TerrorFilterEEEPNS_11TreeMapNodeINS_18OrderedSetItemImplIS5_EEEEE6invokeESB_
|
||||
0x0000007100d7b280,O,000092,_ZNK4sead9Delegate1INS_10OrderedSetIN4ksys3act9Awareness12TerrorFilterEEEPNS_11TreeMapNodeINS_18OrderedSetItemImplIS5_EEEEE5cloneEPNS_4HeapE
|
||||
0x0000007100d7b2dc,O,000008,_ZNK4sead10IDelegate1IPNS_11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness12TerrorFilterEEEEEE9isNoDummyEv
|
||||
0x0000007100d7b2e4,O,000008,_ZNK4sead10IDelegate1IPNS_11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness12TerrorFilterEEEEEE5cloneEPNS_4HeapE
|
||||
0x0000007100d7b2ec,O,000016,_ZN4sead10OrderedSetIN4ksys3act9Awareness12SensorFilterEE18eraseNodeForClear_EPNS_11TreeMapNodeINS_18OrderedSetItemImplIS4_EEEE
|
||||
0x0000007100d7b2fc,O,000116,_ZN4sead11TreeMapImplINS_18OrderedSetItemImplIN4ksys3act9Awareness12SensorFilterEEEE7forEachINS_9Delegate1INS_10OrderedSetIS5_EEPNS_11TreeMapNodeIS6_EEEEEEvSE_RKT_
|
||||
0x0000007100d7b370,O,000048,_ZN4sead9Delegate1INS_10OrderedSetIN4ksys3act9Awareness12SensorFilterEEEPNS_11TreeMapNodeINS_18OrderedSetItemImplIS5_EEEEE6invokeESB_
|
||||
0x0000007100d7b3a0,O,000092,_ZNK4sead9Delegate1INS_10OrderedSetIN4ksys3act9Awareness12SensorFilterEEEPNS_11TreeMapNodeINS_18OrderedSetItemImplIS5_EEEEE5cloneEPNS_4HeapE
|
||||
0x0000007100d7b3fc,O,000008,_ZNK4sead10IDelegate1IPNS_11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness12SensorFilterEEEEEE9isNoDummyEv
|
||||
0x0000007100d7b404,O,000008,_ZNK4sead10IDelegate1IPNS_11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness12SensorFilterEEEEEE5cloneEPNS_4HeapE
|
||||
0x0000007100d7b40c,O,000016,_ZN4sead10OrderedSetIN4ksys3act9Awareness18SensorFilterBufferEE18eraseNodeForClear_EPNS_11TreeMapNodeINS_18OrderedSetItemImplIS4_EEEE
|
||||
0x0000007100d7b41c,O,000116,_ZN4sead11TreeMapImplINS_18OrderedSetItemImplIN4ksys3act9Awareness18SensorFilterBufferEEEE7forEachINS_9Delegate1INS_10OrderedSetIS5_EEPNS_11TreeMapNodeIS6_EEEEEEvSE_RKT_
|
||||
0x0000007100d7b490,O,000048,_ZN4sead9Delegate1INS_10OrderedSetIN4ksys3act9Awareness18SensorFilterBufferEEEPNS_11TreeMapNodeINS_18OrderedSetItemImplIS5_EEEEE6invokeESB_
|
||||
0x0000007100d7b4c0,O,000092,_ZNK4sead9Delegate1INS_10OrderedSetIN4ksys3act9Awareness18SensorFilterBufferEEEPNS_11TreeMapNodeINS_18OrderedSetItemImplIS5_EEEEE5cloneEPNS_4HeapE
|
||||
0x0000007100d7b51c,O,000008,_ZNK4sead10IDelegate1IPNS_11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness18SensorFilterBufferEEEEEE9isNoDummyEv
|
||||
0x0000007100d7b524,O,000008,_ZNK4sead10IDelegate1IPNS_11TreeMapNodeINS_18OrderedSetItemImplIN4ksys3act9Awareness18SensorFilterBufferEEEEEE5cloneEPNS_4HeapE
|
||||
0x0000007100d7b52c,U,000156,
|
||||
0x0000007100d7b5c8,U,000424,
|
||||
0x0000007100d7b770,U,000104,
|
||||
|
@ -94298,8 +94298,8 @@ Address,Quality,Size,Name
|
|||
0x0000007101261638,U,000140,
|
||||
0x00000071012616c4,U,000152,
|
||||
0x000000710126175c,U,000224,
|
||||
0x000000710126183c,U,000516,
|
||||
0x0000007101261a40,U,000136,
|
||||
0x000000710126183c,O,000516,_ZN4ksys3act23getAwarenessTerrorFlagsEj
|
||||
0x0000007101261a40,O,000136,_ZN4ksys3act23getAwarenessSensorFlagsEj
|
||||
0x0000007101261ac8,U,000436,
|
||||
0x0000007101261c7c,U,006044,
|
||||
0x0000007101263418,U,006820,
|
||||
|
|
Can't render this file because it is too large.
|
2
lib/agl
2
lib/agl
|
@ -1 +1 @@
|
|||
Subproject commit e6bd74df66d65f387c575a17dc5949531d38dbdd
|
||||
Subproject commit 8ebf757c4a5d5ac5364fb2d7391ff1110f540d91
|
2
lib/sead
2
lib/sead
|
@ -1 +1 @@
|
|||
Subproject commit 207ccfb3f530a0e329c30791c290ec274c52bf4f
|
||||
Subproject commit a8043533baecb5ba4f437cb4b0f0afe5cc686227
|
|
@ -0,0 +1,259 @@
|
|||
#include "KingSystem/ActorSystem/Awareness/actAwareness.h"
|
||||
#include <agl/Utils/aglParameter.h>
|
||||
#include <agl/Utils/aglResParameter.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <cstring>
|
||||
#include <prim/seadScopedLock.h>
|
||||
#include "KingSystem/ActorSystem/Awareness/actAwarenessDefs.h"
|
||||
#include "KingSystem/ActorSystem/Awareness/actAwarenessInstance.h"
|
||||
#include "KingSystem/Resource/resHandle.h"
|
||||
#include "KingSystem/Resource/resLoadRequest.h"
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
SEAD_SINGLETON_DISPOSER_IMPL(Awareness)
|
||||
|
||||
bool Awareness::Instances::registerInstance(AwarenessInstance* instance) {
|
||||
auto lock = sead::makeScopedLock(critical_section);
|
||||
|
||||
if (instances.size() <= count)
|
||||
return false;
|
||||
|
||||
instances[count].instance = instance;
|
||||
++count;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Awareness::Instances::deregisterInstance(AwarenessInstance* instance) {
|
||||
auto lock = sead::makeScopedLock(critical_section);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (instances[i].instance == instance) {
|
||||
// Swap and remove. The instance order doesn't matter here.
|
||||
--count;
|
||||
instances[i] = instances[count];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Awareness::~Awareness() {
|
||||
finalize();
|
||||
}
|
||||
|
||||
void Awareness::finalize() {
|
||||
mTerrorFilters.finalize();
|
||||
mSensorFilters.finalize();
|
||||
mSensorFilterBuffers.finalize();
|
||||
}
|
||||
|
||||
bool Awareness::init(const Awareness::InitArg& arg, sead::Heap* heap) {
|
||||
mHeap = heap;
|
||||
|
||||
if (!loadSystemData())
|
||||
return false;
|
||||
|
||||
mInstances.instances.allocBufferAssert(arg.num_instances_max, heap);
|
||||
if (!mInstances.instances.isBufferReady())
|
||||
return false;
|
||||
|
||||
mLinks2.buffer.allocBufferAssert(arg.num_links2_max, heap);
|
||||
if (!mLinks2.buffer.isBufferReady())
|
||||
return false;
|
||||
|
||||
mLinks.buffer.allocBufferAssert(arg.num_links_max, heap);
|
||||
if (!mLinks.buffer.isBufferReady())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// agl::utl::ResParameter::getParam being a pain as usual
|
||||
#ifdef NON_MATCHING
|
||||
bool Awareness::loadSystemData() {
|
||||
if (!mHeap)
|
||||
return false;
|
||||
|
||||
res::Handle handle;
|
||||
res::LoadRequest req;
|
||||
req.mRequester = "AwarenessSystemData";
|
||||
req._26 = false;
|
||||
|
||||
{
|
||||
const auto* res = sead::DynamicCast<sead::DirectResource>(
|
||||
handle.load("Awareness/TerrorFilter.bawntable", &req));
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
const agl::utl::ResParameterArchive archive{res->getRawData()};
|
||||
const auto root = archive.getRootList();
|
||||
const auto list = agl::utl::getResParameterList(root, "TerrorFilter");
|
||||
if (list.getResParameterObjNum() == 0)
|
||||
return false;
|
||||
if (!mTerrorFilters.allocBuffer(list.getResParameterObjNum(), mHeap))
|
||||
return false;
|
||||
|
||||
for (auto it = list.objBegin(); it != list.objEnd(); ++it) {
|
||||
const auto obj = it.getObj();
|
||||
const u32 target = obj.getParameterObjNameHash();
|
||||
u32 flags = 0;
|
||||
for (auto it_p = obj.begin(); it_p != obj.end(); ++it_p) {
|
||||
const auto param = it_p.getParam();
|
||||
const auto enabled = *param.getData<int>();
|
||||
if (enabled)
|
||||
flags |= getAwarenessTerrorFlags(param.getParameterNameHash());
|
||||
}
|
||||
mTerrorFilters.insert(TerrorFilter{flags, target});
|
||||
}
|
||||
}
|
||||
|
||||
handle.requestUnload2();
|
||||
|
||||
{
|
||||
const auto* res = sead::DynamicCast<sead::DirectResource>(
|
||||
handle.load("Awareness/SensorFilter.bsft", &req));
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
const agl::utl::ResParameterArchive archive{res->getRawData()};
|
||||
const auto root = archive.getRootList();
|
||||
const auto list = agl::utl::getResParameterList(root, "SensorFilter");
|
||||
if (list.getResParameterObjNum() == 0)
|
||||
return false;
|
||||
if (!mSensorFilters.allocBuffer(list.getResParameterObjNum(), mHeap))
|
||||
return false;
|
||||
|
||||
for (auto it = list.objBegin(); it != list.objEnd(); ++it) {
|
||||
const auto obj = it.getObj();
|
||||
const u32 target = obj.getParameterObjNameHash();
|
||||
u32 flags = 0;
|
||||
for (auto it_p = obj.begin(); it_p != obj.end(); ++it_p) {
|
||||
const auto param = it_p.getParam();
|
||||
const auto enabled = *param.getData<int>();
|
||||
if (enabled)
|
||||
flags |= getAwarenessSensorFlags(param.getParameterNameHash());
|
||||
}
|
||||
mSensorFilters.insert(SensorFilter{flags, target});
|
||||
}
|
||||
}
|
||||
|
||||
handle.requestUnload2();
|
||||
|
||||
{
|
||||
const auto* res = sead::DynamicCast<sead::DirectResource>(
|
||||
handle.load("Awareness/SensorFilterBuffer.bsfbt", &req));
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
const agl::utl::ResParameterArchive archive{res->getRawData()};
|
||||
const auto root = archive.getRootList();
|
||||
const auto list = agl::utl::getResParameterList(root, "SensorFilterBuffer");
|
||||
if (list.getResParameterObjNum() == 0)
|
||||
return false;
|
||||
if (!mSensorFilterBuffers.allocBuffer(list.getResParameterObjNum(), mHeap))
|
||||
return false;
|
||||
|
||||
for (auto it = list.objBegin(); it != list.objEnd(); ++it) {
|
||||
const auto obj = it.getObj();
|
||||
const u32 target = obj.getParameterObjNameHash();
|
||||
|
||||
SensorFilterBuffer::Params params;
|
||||
for (auto it_p = obj.begin(); it_p != obj.end(); ++it_p) {
|
||||
const auto param = it_p.getParam();
|
||||
std::memcpy(¶ms.raw[it_p.getIndex()],
|
||||
param.ptrBytes() + param.ptr()->getOffset(), sizeof(int));
|
||||
if (it_p.getIndex() >= params.raw.size())
|
||||
return false;
|
||||
}
|
||||
|
||||
mSensorFilterBuffers.insert(SensorFilterBuffer{params, target});
|
||||
}
|
||||
}
|
||||
|
||||
handle.requestUnload2();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Awareness::initBeforeStageGen() {
|
||||
mInstances.count = 0;
|
||||
mInstances.ticks = 0;
|
||||
mLinks2.count = 0;
|
||||
mLinks.count = 0;
|
||||
mUnk.finalize();
|
||||
setPaused(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Awareness::setPaused(bool paused) {
|
||||
mFlags.changeBit(Flag(Flag::Paused), paused);
|
||||
if (paused) {
|
||||
mFlags.setBit(Flag(Flag::_2));
|
||||
} else {
|
||||
mFlags.setBit(Flag(Flag::_6));
|
||||
}
|
||||
}
|
||||
|
||||
void Awareness::setEventActive(bool active) {
|
||||
mFlags.changeBit(Flag(Flag::EventActive), active);
|
||||
if (active) {
|
||||
mFlags.setBit(Flag(Flag::_5));
|
||||
} else {
|
||||
mFlags.setBit(Flag(Flag::_6));
|
||||
}
|
||||
}
|
||||
|
||||
void Awareness::calc() {
|
||||
if (checkFlag(Flag::Paused)) {
|
||||
if (checkFlag(Flag::_2))
|
||||
resetFlag(Flag::_2);
|
||||
|
||||
} else if (checkFlag(Flag::EventActive)) {
|
||||
if (checkFlag(Flag::_5)) {
|
||||
mInstances.calcForEvent(true);
|
||||
resetFlag(Flag::_5);
|
||||
}
|
||||
|
||||
} else if (checkFlag(Flag::_3)) {
|
||||
resetFlag(Flag::_3);
|
||||
|
||||
} else if (checkFlag(Flag::_6)) {
|
||||
resetFlag(Flag::_6);
|
||||
|
||||
} else {
|
||||
mInstances.calc();
|
||||
}
|
||||
|
||||
mUnk.calc();
|
||||
mLinks2.calc();
|
||||
mLinks.calc();
|
||||
resetFlag(Flag::_0);
|
||||
}
|
||||
|
||||
void Awareness::Links2::calc() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
void Awareness::Links::calc() {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
void Awareness::Instances::calc() {
|
||||
++ticks;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if ((i + ticks) % 8 == 0) {
|
||||
get(i)->calc2();
|
||||
}
|
||||
get(i)->calc();
|
||||
}
|
||||
}
|
||||
|
||||
void Awareness::Instances::calcForEvent(bool check_334) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!check_334 || get(i)->_334 < 0)
|
||||
get(i)->calcForEvent();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ksys::act
|
|
@ -0,0 +1,154 @@
|
|||
#pragma once
|
||||
|
||||
#include <container/seadBuffer.h>
|
||||
#include <container/seadOrderedSet.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <heap/seadDisposer.h>
|
||||
#include <prim/seadEnum.h>
|
||||
#include <prim/seadTypedBitFlag.h>
|
||||
#include <thread/seadAtomic.h>
|
||||
#include <thread/seadCriticalSection.h>
|
||||
#include "KingSystem/ActorSystem/actBaseProcLink.h"
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
class AwarenessInstance;
|
||||
|
||||
class Awareness {
|
||||
SEAD_SINGLETON_DISPOSER(Awareness)
|
||||
|
||||
Awareness() = default;
|
||||
virtual ~Awareness();
|
||||
|
||||
public:
|
||||
struct InitArg {
|
||||
int num_instances_max;
|
||||
// TODO: rename
|
||||
int num_links_max;
|
||||
int num_links2_max;
|
||||
};
|
||||
|
||||
bool init(const InitArg& arg, sead::Heap* heap);
|
||||
bool initBeforeStageGen();
|
||||
void setPaused(bool paused);
|
||||
void setEventActive(bool active);
|
||||
void calc();
|
||||
|
||||
private:
|
||||
friend class AwarenessInstance;
|
||||
|
||||
SEAD_ENUM(Flag, _0, Paused, _2, _3, EventActive, _5, _6)
|
||||
|
||||
// FIXME: rename
|
||||
struct Unk1 {
|
||||
virtual ~Unk1() { finalize(); }
|
||||
void finalize();
|
||||
void calc();
|
||||
|
||||
void* _8{};
|
||||
void* _10{};
|
||||
};
|
||||
|
||||
struct TerrorFilter {
|
||||
bool operator<(const TerrorFilter& rhs) const { return target < rhs.target; }
|
||||
|
||||
u32 flags;
|
||||
u32 target;
|
||||
};
|
||||
|
||||
struct SensorFilter {
|
||||
bool operator<(const SensorFilter& rhs) const { return target < rhs.target; }
|
||||
|
||||
u32 flags;
|
||||
u32 target;
|
||||
};
|
||||
|
||||
struct SensorFilterBuffer {
|
||||
bool operator<(const SensorFilterBuffer& rhs) const { return target < rhs.target; }
|
||||
|
||||
union Params {
|
||||
struct {
|
||||
int system;
|
||||
int sense;
|
||||
int sight;
|
||||
int worry;
|
||||
int hearing;
|
||||
};
|
||||
sead::SafeArray<int, 5> raw;
|
||||
};
|
||||
Params params;
|
||||
u32 target;
|
||||
};
|
||||
|
||||
struct InstanceRef {
|
||||
AwarenessInstance* instance{};
|
||||
};
|
||||
|
||||
struct Instances {
|
||||
~Instances() { instances.freeBuffer(); }
|
||||
bool registerInstance(AwarenessInstance* instance);
|
||||
void deregisterInstance(AwarenessInstance* instance);
|
||||
void calc();
|
||||
void calcForEvent(bool check_334);
|
||||
AwarenessInstance*& get(int i) { return instances[i].instance; }
|
||||
AwarenessInstance*& operator[](int i) { return get(i); }
|
||||
|
||||
sead::Buffer<InstanceRef> instances;
|
||||
int count = 0;
|
||||
int ticks = 0;
|
||||
sead::CriticalSection critical_section;
|
||||
};
|
||||
|
||||
// FIXME: rename
|
||||
struct Link {
|
||||
BaseProcLink link;
|
||||
// TODO: physics body?
|
||||
void* _10{};
|
||||
};
|
||||
|
||||
// FIXME: rename
|
||||
struct Link2 {
|
||||
Link2() { _10 = 0; }
|
||||
BaseProcLink link;
|
||||
u8 _10{};
|
||||
u32 _14{};
|
||||
void* _18{};
|
||||
};
|
||||
|
||||
// FIXME: rename
|
||||
struct Links {
|
||||
void calc();
|
||||
|
||||
sead::Buffer<Link> buffer;
|
||||
sead::Atomic<int> count;
|
||||
};
|
||||
|
||||
// FIXME: rename
|
||||
struct Links2 {
|
||||
void calc();
|
||||
|
||||
sead::Buffer<Link2> buffer;
|
||||
sead::Atomic<int> count;
|
||||
};
|
||||
|
||||
void finalize();
|
||||
bool loadSystemData();
|
||||
|
||||
bool checkFlag(Flag flag) const { return (1u << flag) & mFlags.getDirect(); }
|
||||
void setFlag(Flag flag) { mFlags.setBit(flag); }
|
||||
void resetFlag(Flag flag) { mFlags.resetBit(flag); }
|
||||
|
||||
Instances mInstances;
|
||||
Links mLinks;
|
||||
Links2 mLinks2;
|
||||
Unk1 mUnk;
|
||||
sead::OrderedSet<TerrorFilter> mTerrorFilters;
|
||||
sead::OrderedSet<SensorFilter> mSensorFilters;
|
||||
sead::OrderedSet<SensorFilterBuffer> mSensorFilterBuffers;
|
||||
sead::BitFlag8 mFlags;
|
||||
sead::Heap* mHeap{};
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(Awareness, 0x138);
|
||||
|
||||
} // namespace ksys::act
|
|
@ -0,0 +1,47 @@
|
|||
#include "KingSystem/ActorSystem/Awareness/actAwarenessDefs.h"
|
||||
#include <agl/Utils/aglParameter.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
sead::SafeArray<const char*, 13> sAwarenessTerrorTypes = sead::toArray({
|
||||
"TerrorPlayer",
|
||||
"TerrorNpc",
|
||||
"TerrorEnemy",
|
||||
"TerrorGuardian",
|
||||
"TerrorImpulse",
|
||||
"TerrorFire",
|
||||
"TerrorInsect",
|
||||
"TerrorHorse",
|
||||
"TerrorAnimal",
|
||||
"TerrorWolfLink",
|
||||
"TerrorIce",
|
||||
"TerrorElectric",
|
||||
"TerrorManMadeFire",
|
||||
});
|
||||
|
||||
sead::SafeArray<const char*, 23> sAwarenessSensorTypes = sead::toArray({
|
||||
"Player", "PlayerBomb", "Horse", "Enemy", "Prey", "Predator", "Domestic", "Assassin",
|
||||
"Giant", "NPC", "Material", "Food", "Weapon", "Spirit", "Carry", "Tree",
|
||||
"WolfLink", "Chemical", "Bullet", "Door", "Captured", "Guardian", "All",
|
||||
});
|
||||
|
||||
u32 getAwarenessTerrorFlags(u32 hash) {
|
||||
for (u32 i = 0; i < u32(sAwarenessTerrorTypes.size()); ++i) {
|
||||
if (agl::utl::ParameterBase::calcHash(sAwarenessTerrorTypes(i)) == hash)
|
||||
return 1 << i;
|
||||
}
|
||||
|
||||
// XXX: wouldn't returning 0 be a better idea?
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
u32 getAwarenessSensorFlags(u32 hash) {
|
||||
for (u32 i = 0; i < u32(sAwarenessSensorTypes.size()); ++i) {
|
||||
if (agl::utl::ParameterBase::calcHash(sAwarenessSensorTypes(i)) == hash)
|
||||
return 1 << i;
|
||||
}
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
} // namespace ksys::act
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
u32 getAwarenessTerrorFlags(u32 hash);
|
||||
u32 getAwarenessSensorFlags(u32 hash);
|
||||
|
||||
} // namespace ksys::act
|
|
@ -0,0 +1 @@
|
|||
#include "KingSystem/ActorSystem/Awareness/actAwarenessInstance.h"
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys::act {
|
||||
|
||||
// FIXME
|
||||
class AwarenessInstance {
|
||||
public:
|
||||
AwarenessInstance();
|
||||
virtual ~AwarenessInstance();
|
||||
|
||||
void calcForEvent();
|
||||
void calc();
|
||||
void calc2();
|
||||
|
||||
u8 _8[0x334 - 0x8];
|
||||
s8 _334;
|
||||
u32 _338;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(AwarenessInstance, 0x340);
|
||||
|
||||
} // namespace ksys::act
|
|
@ -1,4 +1,14 @@
|
|||
target_sources(uking PRIVATE
|
||||
Attention/actAttention.cpp
|
||||
Attention/actAttention.h
|
||||
|
||||
Awareness/actAwareness.cpp
|
||||
Awareness/actAwareness.h
|
||||
Awareness/actAwarenessDefs.cpp
|
||||
Awareness/actAwarenessDefs.h
|
||||
Awareness/actAwarenessInstance.cpp
|
||||
Awareness/actAwarenessInstance.h
|
||||
|
||||
LOD/actLodState.cpp
|
||||
LOD/actLodState.h
|
||||
|
||||
|
@ -56,8 +66,6 @@ target_sources(uking PRIVATE
|
|||
actAiRoot.h
|
||||
actASSetting.cpp
|
||||
actASSetting.h
|
||||
Attention/actAttention.cpp
|
||||
Attention/actAttention.h
|
||||
actBaseProc.cpp
|
||||
actBaseProc.h
|
||||
actBaseProcCreateTask.cpp
|
||||
|
|
Loading…
Reference in New Issue