diff options
| author | Léo Lam <leo@leolam.fr> | 2022-03-20 15:08:26 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2022-03-20 15:11:28 +0100 |
| commit | a98e5f65579055d72a8c72201b0c7f119ec8d242 (patch) | |
| tree | 897a59e3bc0f43da411d2481ea9a3a1236279277 /src/KingSystem/Physics/System/physSystem.h | |
| parent | cc270ee3ff82d7766dcbc0eee54cdc34d09bff4c (diff) | |
ksys/phys: Add ScopedWorldLock to simplify world locking/unlocking
Diffstat (limited to 'src/KingSystem/Physics/System/physSystem.h')
| -rw-r--r-- | src/KingSystem/Physics/System/physSystem.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/KingSystem/Physics/System/physSystem.h b/src/KingSystem/Physics/System/physSystem.h index 6b130476..1f9647c1 100644 --- a/src/KingSystem/Physics/System/physSystem.h +++ b/src/KingSystem/Physics/System/physSystem.h @@ -86,8 +86,11 @@ public: void removeSystemGroupHandler(SystemGroupHandler* handler); hkpWorld* getHavokWorld(ContactLayerType type) const; + + // 0x0000007101215754 void lockWorld(ContactLayerType type, const char* description = nullptr, int b = 0, OnlyLockIfNeeded only_lock_if_needed = OnlyLockIfNeeded::No); + // 0x0000007101215784 void unlockWorld(ContactLayerType type, const char* description = nullptr, int b = 0, OnlyLockIfNeeded only_lock_if_needed = OnlyLockIfNeeded::No); @@ -146,4 +149,27 @@ private: }; KSYS_CHECK_SIZE_NX150(System, 0x480); +class ScopedWorldLock { +public: + explicit ScopedWorldLock(ContactLayerType type, const char* description = nullptr, int unk = 0, + OnlyLockIfNeeded only_lock_if_needed = OnlyLockIfNeeded::No) + : mType(type), mDescription(description), mUnk(unk), + mOnlyLockIfNeeded(only_lock_if_needed) { + System::instance()->lockWorld(mType, mDescription, mUnk, mOnlyLockIfNeeded); + } + + ~ScopedWorldLock() { + System::instance()->unlockWorld(mType, mDescription, mUnk, mOnlyLockIfNeeded); + } + + ScopedWorldLock(const ScopedWorldLock&) = delete; + auto operator=(const ScopedWorldLock&) = delete; + +private: + ContactLayerType mType; + const char* mDescription; + int mUnk; + OnlyLockIfNeeded mOnlyLockIfNeeded; +}; + } // namespace ksys::phys |
