summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem
diff options
context:
space:
mode:
authornotyouraveragehooman <65437533+notyouraveragehooman@users.noreply.github.com>2020-08-21 14:18:47 -0700
committerLéo Lam <leo@leolam.fr>2020-08-22 10:17:05 +0200
commitff99d7763572fc5b463bc8ece39a2c40e90deaf0 (patch)
tree5f452a9692c0b4d81fa1d53c39ed05f66fe13b8f /src/KingSystem/ActorSystem
parentfc306aa5f06ef1d28f6d178dff28d39b9056199a (diff)
BaseProc::getConnectedCalcParent
BaseProc::setConnectedCalcParent
Diffstat (limited to 'src/KingSystem/ActorSystem')
-rw-r--r--src/KingSystem/ActorSystem/actBaseProc.cpp26
-rw-r--r--src/KingSystem/ActorSystem/actBaseProc.h2
-rw-r--r--src/KingSystem/ActorSystem/actBaseProcMgr.h7
3 files changed, 29 insertions, 6 deletions
diff --git a/src/KingSystem/ActorSystem/actBaseProc.cpp b/src/KingSystem/ActorSystem/actBaseProc.cpp
index 149386e2..79e2cc47 100644
--- a/src/KingSystem/ActorSystem/actBaseProc.cpp
+++ b/src/KingSystem/ActorSystem/actBaseProc.cpp
@@ -66,7 +66,7 @@ bool BaseProc::deleteLater(DeleteReason reason) {
}
}
- if (!BaseProcMgr::instance()->addToUpdateStateList(*this))
+ if (!BaseProcMgr::instance()->addToUpdateStateList(*this, StateFlags::RequestDelete))
onDeleteRequested_(reason);
if (!is_high_prio)
@@ -425,4 +425,28 @@ bool BaseProc::x00000071011ba9fc() {
return true;
}
+BaseProc* BaseProc::getConnectedCalcParent() const {
+ if (mConnectedCalcParent == nullptr || mConnectedCalcParent->mState == State::Delete)
+ return nullptr;
+
+ return mConnectedCalcParent;
+}
+
+bool BaseProc::setConnectedCalcParent(BaseProc* parent, bool delete_parent_on_delete) {
+ if (parent == nullptr)
+ return false;
+
+ if (isDeletedOrDeleting() || parent->isDeletedOrDeleting())
+ return false;
+
+ if (BaseProcMgr::instance()->addToUpdateStateList(*this, StateFlags::RequestSetParent))
+ return false;
+
+ mConnectedCalcParentNew = parent;
+
+ mFlags.change(Flags::DeleteParentOnDelete, delete_parent_on_delete);
+
+ return true;
+}
+
} // namespace ksys::act
diff --git a/src/KingSystem/ActorSystem/actBaseProc.h b/src/KingSystem/ActorSystem/actBaseProc.h
index e0fde4c1..41393c0b 100644
--- a/src/KingSystem/ActorSystem/actBaseProc.h
+++ b/src/KingSystem/ActorSystem/actBaseProc.h
@@ -107,7 +107,7 @@ public:
void release();
BaseProc* getConnectedCalcParent() const;
- void setConnectedCalcParent(BaseProc* parent, bool delete_parent_on_delete);
+ bool setConnectedCalcParent(BaseProc* parent, bool delete_parent_on_delete);
void resetConnectedCalcParent(bool clear_existing_set_request);
BaseProc* getConnectedCalcChild() const;
diff --git a/src/KingSystem/ActorSystem/actBaseProcMgr.h b/src/KingSystem/ActorSystem/actBaseProcMgr.h
index 87fd4e19..9f278515 100644
--- a/src/KingSystem/ActorSystem/actBaseProcMgr.h
+++ b/src/KingSystem/ActorSystem/actBaseProcMgr.h
@@ -69,7 +69,7 @@ public:
void unregisterProc(BaseProc& proc);
void addToPreDeleteList(BaseProc& proc);
- bool addToUpdateStateList(BaseProc& proc);
+ bool addToUpdateStateList(BaseProc& proc, BaseProc::StateFlags flags);
void eraseFromPreDeleteList(BaseProc& proc);
void eraseFromUpdateStateList(BaseProc& proc);
void processPreDeleteList();
@@ -210,11 +210,10 @@ private:
};
KSYS_CHECK_SIZE_NX150(BaseProcMgr, 0x21a0);
-inline bool BaseProcMgr::addToUpdateStateList(BaseProc& proc) {
+inline bool BaseProcMgr::addToUpdateStateList(BaseProc& proc, BaseProc::StateFlags flag) {
auto lock = sead::makeScopedLock(mProcUpdateStateListCS);
doAddToUpdateStateList_(proc);
- return (proc.mStateFlags.set(BaseProc::StateFlags::RequestDelete) &
- u32(BaseProc::StateFlags::RequestDelete)) != 0;
+ return (proc.mStateFlags.set(flag) & u32(flag)) != 0;
}
} // namespace ksys::act