-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90caa37
commit fb48170
Showing
6 changed files
with
236 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#include "KingSystem/ActorSystem/actLinkTag.h" | ||
|
||
#include "KingSystem/Map/mapObject.h" | ||
#include "KingSystem/Map/mapObjectLink.h" | ||
#include "KingSystem/System/SystemTimers.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; | ||
else if (mName == "LinkTagNOr") | ||
mLinkTagType = Type::NOr; | ||
else if (mName == "LinkTagNAnd") | ||
mLinkTagType = Type::NAnd; | ||
else if (mName == "LinkTagXOr") | ||
mLinkTagType = Type::XOr; | ||
else if (mName == "LinkTagAnd") | ||
mLinkTagType = Type::And; | ||
else if (mName == "LinkTagCount") | ||
mLinkTagType = Type::Count; | ||
else if (mName == "LinkTagPulse") | ||
mLinkTagType = Type::Pulse; | ||
else if (mName == "LinkTagNone") | ||
mLinkTagType = Type::None; | ||
|
||
if (mName == "LinkTagNAnd" || mName == "LinkTagNOr") | ||
mFlags.set(LinkTagFlag::_4); | ||
|
||
int noChangeSignalValue = 0; | ||
mMubinIter.tryGetParamIntByKey(&noChangeSignalValue, "NoChangeSignal"); | ||
if (noChangeSignalValue != 0) | ||
mFlags.set(LinkTagFlag::_40); | ||
|
||
int saveFlagOnOffTypeValue = 0; | ||
if (mMubinIter.tryGetParamIntByKey(&saveFlagOnOffTypeValue, "SaveFlagOnOffType")) { | ||
if (saveFlagOnOffTypeValue == 2) | ||
mFlags.set(LinkTagFlag::_200); | ||
else if (saveFlagOnOffTypeValue == 1) | ||
mFlags.set(LinkTagFlag::_100); | ||
} | ||
|
||
bool flagSet = false; | ||
isFlagSet(&flagSet, 0, mMapObj); | ||
updateIsFlagSetFlag(flagSet, 1, 1); | ||
if (flagSet) { | ||
mFlags.set(LinkTagFlag::_10); | ||
mTriggeredLinkFlags.makeAllOne(); | ||
mFlags.set(LinkTagFlag::_30); | ||
} else { | ||
mFlags.reset(LinkTagFlag::_10); | ||
mTriggeredLinkFlags.makeAllZero(); | ||
mFlags.reset(LinkTagFlag::_30); | ||
} | ||
return true; | ||
} | ||
|
||
void LinkTag::updateIsFlagSetFlag(bool isFlagSet, bool a3, bool a4) { | ||
if (!mMapObj) | ||
return; | ||
|
||
/*if (isFlagSet) | ||
mFlags.set(LinkTagFlag::_8); | ||
else | ||
mFlags.reset(LinkTagFlag::_8);*/ | ||
mFlags.change(LinkTagFlag::_8, isFlagSet); | ||
|
||
if (mFlags.isOff(LinkTagFlag::_40) || a3) { | ||
mMapObj->getFlags0().change(map::Object::Flag0::_100, isFlagSet); | ||
|
||
if (mFlags.isOff(LinkTagFlag::_40)) { | ||
int frameCounter = SystemTimers::instance()->mFrameCounter; | ||
auto mapLinkData = mMapObj->getLinkData(); | ||
if (mapLinkData) { | ||
auto mapLinks = mapLinkData->mLinksOther.links; | ||
if (isFlagSet != mMapObj->getFlags().isOn(map::Object::Flag::IsLinkTagNAndOrNOr)) { | ||
for (int i = 0; i < mapLinks.size(); i++) { | ||
auto& mapLink = mapLinks[i]; | ||
if (mapLink.other_obj) { | ||
if (mapLink.type == map::MapLinkDefType::Create || | ||
mapLink.type == map::MapLinkDefType::MtxCopyCreate) { | ||
if (_1E8 == frameCounter) { | ||
mapLink.other_obj->getFlags0().reset( | ||
map::Object::Flag0::_10000000); | ||
} | ||
} else if (mapLink.type == map::MapLinkDefType::Delete && | ||
(mapLink.other_obj->getFlags0().isOff( | ||
map::Object::Flag0::_20000000))) { | ||
mapLink.other_obj->getFlags0().set(map::Object::Flag0::_20000000); | ||
_1E8 = frameCounter; | ||
} | ||
} | ||
} | ||
} else { | ||
for (int i = 0; i < mapLinks.size(); i++) { | ||
auto& mapLink = mapLinks[i]; | ||
if (mapLink.other_obj) { | ||
switch (mapLink.type) { | ||
case map::MapLinkDefType::Create: | ||
case map::MapLinkDefType::MtxCopyCreate: | ||
if (mapLink.other_obj->getFlags0().isOff( | ||
map::Object::Flag0::_10000000)) { | ||
mapLink.other_obj->getFlags0().set( | ||
map::Object::Flag0::_10000000); | ||
_1E8 = frameCounter; | ||
} | ||
break; | ||
case map::MapLinkDefType::Delete: | ||
if (_1E8 == frameCounter) | ||
mapLink.other_obj->getFlags0().reset( | ||
map::Object::Flag0::_10000000); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (a4) { | ||
mFlags.reset(LinkTagFlag::_800); | ||
} | ||
if (isFlagSet != mMapObj->getFlags().isOn(map::Object::Flag::IsLinkTagNAndOrNOr)) { | ||
if (mFlags.isOff(LinkTagFlag::_800)) { | ||
mFlags.set(LinkTagFlag::_800); | ||
} | ||
mFlags.set(LinkTagFlag::_400); | ||
} | ||
if (mFlags.isOn(LinkTagFlag::_800)) { | ||
mFlags.set(LinkTagFlag::_C00); | ||
} | ||
|
||
if (!a3) { | ||
auto mapLinkData = mMapObj->getLinkData(); | ||
if (mapLinkData) { | ||
if (mapLinkData->isGenGroupInitState3() && | ||
(mapLinkData->findLinkWithType(map::MapLinkDefType::Create) || | ||
mapLinkData->findLinkWithType(map::MapLinkDefType::Delete) || | ||
mapLinkData->findLinkWithType(map::MapLinkDefType::MtxCopyCreate))) { | ||
mapLinkData->sub_7100D4FA90(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} // namespace ksys::act |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#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 : u16 { | ||
_4 = 0x4, | ||
_8 = 0x8, | ||
_10 = 0x10, | ||
_20 = 0x20, | ||
_40 = 0x40, | ||
_100 = 0x100, | ||
_200 = 0x200, | ||
_400 = 0x400, | ||
_800 = 0x800, | ||
|
||
_30 = _10 | _20, | ||
_C00 = _400 | _800 | ||
}; | ||
|
||
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; | ||
sead::Atomic<u8> _1de = 0; | ||
u8 _1df = 0xFF; | ||
sead::TypedBitFlag<LinkTagFlag> mFlags; | ||
u8 mTagCount = 0; | ||
u8 _1E3 = 0; | ||
u32 mCounter = 0; | ||
int _1E8 = 0; | ||
sead::TypedBitFlag<JobFlag, sead::Atomic<u32>> mJobFlags; | ||
u32 mHashId = 0; | ||
map::MubinIter mMubinIter; | ||
map::Object* mMapObj = nullptr; | ||
}; | ||
KSYS_CHECK_SIZE_NX150(LinkTag, 0x210); | ||
|
||
} // namespace ksys::act |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters