Skip to content

Commit

Permalink
ksys/act: Add LinkTag
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsterDruide1 committed Aug 5, 2021
1 parent 40530f0 commit 37befbc
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/uking_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -73599,7 +73599,7 @@ Address,Quality,Size,Name
0x0000007100d375e4,U,000076,LazyTraverseList::dtor
0x0000007100d37630,U,000132,LazyTraverseList::updateFlags
0x0000007100d376b4,U,000216,
0x0000007100d3778c,U,000204,LinkTag::construct
0x0000007100d3778c,O,000204,_ZN4ksys3act7LinkTag9constructERKNS0_8BaseProc9CreateArgEPN4sead4HeapE
0x0000007100d37858,U,000280,LinkTag::calc
0x0000007100d37970,U,000064,LinkTag::dtor
0x0000007100d379b0,U,000072,LinkTag::dtorDelete
Expand Down
2 changes: 2 additions & 0 deletions src/KingSystem/ActorSystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ target_sources(uking PRIVATE
actInstParamPack.cpp
actInstParamPack.h
actLifeRecoveryInfo.h
actLinkTag.cpp
actLinkTag.h
actPlayerInfo.cpp
actPlayerInfo.h
actTag.h
Expand Down
63 changes: 63 additions & 0 deletions src/KingSystem/ActorSystem/actLinkTag.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "KingSystem/ActorSystem/actLinkTag.h"

namespace ksys::act {

LinkTag* LinkTag::construct(const BaseProc::CreateArg& arg, sead::Heap* heap) {
return new (heap, std::nothrow) LinkTag(arg);
}

LinkTag::LinkTag(const BaseProc::CreateArg& arg) : BaseProc(arg), mJob(this, &LinkTag::calc) {
mJobHandlers[3] = &mJob;
}

bool LinkTag::init(){
if(mName == "LinkTagOr")
mLinkTagType = Type::Or;
if(mName == "LinkTagNOr")
mLinkTagType = Type::NOr;
if(mName == "LinkTagNAnd")
mLinkTagType = Type::NAnd;
if(mName == "LinkTagXOr")
mLinkTagType = Type::XOr;
if(mName == "LinkTagAnd")
mLinkTagType = Type::And;
if(mName == "LinkTagCount")
mLinkTagType = Type::Count;
if(mName == "LinkTagPulse")
mLinkTagType = Type::Pulse;
if(mName == "LinkTagNone")
mLinkTagType = Type::None;

if(mName == "LinkTagNAnd" || mName == "LinkTagNOr")
mFlags.set(LinkTagFlag::FLAG_PLACEHOLDER_4);

int noChangeSignalValue = 0;
mMubinIter.tryGetParamIntByKey(&noChangeSignalValue, "NoChangeSignal");
if(noChangeSignalValue != 0)
mFlags.set(LinkTagFlag::FLAG_PLACEHOLDER_40);

int saveFlagOnOffTypeValue = 0;
if(mMubinIter.tryGetParamIntByKey(&saveFlagOnOffTypeValue, "SaveFlagOnOffType")){
if(saveFlagOnOffTypeValue == 2)
mFlags.set(LinkTagFlag::FLAG_PLACEHOLDER_200);
else if(saveFlagOnOffTypeValue == 1)
mFlags.set(LinkTagFlag::FLAG_PLACEHOLDER_100);
}

bool flagSet = false;
isFlagSet(&flagSet, 0, mMapObj);
updateIsFlagSetFlag(flagSet, 1, 1);
if(flagSet){
mFlags.set(LinkTagFlag::FLAG_PLACEHOLDER_10);
mTriggeredLinkFlags.makeAllOne();
mFlags.set(LinkTagFlag::FLAG_PLACEHOLDER_30);
}
else {
mFlags.reset(LinkTagFlag::FLAG_PLACEHOLDER_10);
mTriggeredLinkFlags.makeAllZero();
mFlags.reset(LinkTagFlag::FLAG_PLACEHOLDER_30);
}
return true;
}

} // namespace ksys::act
63 changes: 63 additions & 0 deletions src/KingSystem/ActorSystem/actLinkTag.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once

#include <prim/seadLongBitFlag.h>
#include <prim/seadTypedBitFlag.h>
#include <thread/seadAtomic.h>
#include "KingSystem/ActorSystem/actBaseProc.h"
#include "KingSystem/ActorSystem/actBaseProcJobHandler.h"
#include "KingSystem/Map/mapMubinIter.h"
#include "KingSystem/Utils/Types.h"

namespace ksys::map {
class Object;
} // namespace ksys::map

namespace ksys::act {

class LinkTag : public BaseProc {
SEAD_RTTI_OVERRIDE(LinkTag, BaseProc)

public:
enum class Type : u8 { And, Or, NAnd, NOr, XOr, Count, Pulse, None };
enum class JobFlag {};
enum class LinkTagFlag {
FLAG_PLACEHOLDER_4 = 0x4,
FLAG_PLACEHOLDER_10 = 0x10,
FLAG_PLACEHOLDER_20 = 0x20,
FLAG_PLACEHOLDER_40 = 0x40,
FLAG_PLACEHOLDER_100 = 0x100,
FLAG_PLACEHOLDER_200 = 0x200,

FLAG_PLACEHOLDER_30 = FLAG_PLACEHOLDER_10 | FLAG_PLACEHOLDER_20
};

static LinkTag* construct(const BaseProc::CreateArg& arg, sead::Heap* heap);

explicit LinkTag(const BaseProc::CreateArg& arg);
void calc();
bool init();
void updateIsFlagSetFlag(bool isFlagSet, bool a3, bool a4);

// this doesn't even belong in this namespace, but is used as a placeholder for init()
void isFlagSet(bool* isSet, int unk, map::Object* object);

BaseProcJobHandlerT<LinkTag> mJob;
sead::LongBitFlag<96> mTriggeredLinkFlags;
Type mLinkTagType = Type::And;
u8 _1dd = 0xFF;
u8 _1de = 0;
u8 _1df = 0xFF;
sead::TypedBitFlag<LinkTagFlag, u16> mFlags;
u8 mTagCount = 0;
u8 field_1E3 = 0;
u32 mCounter = 0;
int field_1E8 = 0;
sead::TypedBitFlag<JobFlag, sead::Atomic<u32>> mJobFlags;
u32 mHashId = 0;
int field_1F4 = 0;
map::MubinIter mMubinIter;
map::Object* mMapObj = nullptr;
};
KSYS_CHECK_SIZE_NX150(LinkTag, 0x210);

} // namespace ksys::act

0 comments on commit 37befbc

Please sign in to comment.