summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem/actActorCaptureMgr.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-11-08 18:47:26 +0100
committerLéo Lam <leo@leolam.fr>2020-11-08 22:26:54 +0100
commit7d2ef1d6b2a7cdfdc54c956a39e21abf994c5594 (patch)
tree4c0dd30fe1e3d72cc115e4234961af8b780ceefa /src/KingSystem/ActorSystem/actActorCaptureMgr.cpp
parentff3421d4eb65caecac9465ce84a376dad6dd3a8d (diff)
ksys/act: Start adding ActorCaptureMgr
Diffstat (limited to 'src/KingSystem/ActorSystem/actActorCaptureMgr.cpp')
-rw-r--r--src/KingSystem/ActorSystem/actActorCaptureMgr.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/KingSystem/ActorSystem/actActorCaptureMgr.cpp b/src/KingSystem/ActorSystem/actActorCaptureMgr.cpp
new file mode 100644
index 00000000..e1a530b5
--- /dev/null
+++ b/src/KingSystem/ActorSystem/actActorCaptureMgr.cpp
@@ -0,0 +1,66 @@
+#include "KingSystem/ActorSystem/actActorCaptureMgr.h"
+#include "KingSystem/ActorSystem/actActor.h"
+#include "KingSystem/Resource/resEntryFactory.h"
+#include "KingSystem/Resource/resLoadRequest.h"
+#include "KingSystem/Resource/resResourceMgrTask.h"
+#include "KingSystem/Resource/resSystem.h"
+#include "KingSystem/Utils/SafeDelete.h"
+
+namespace ksys::act {
+
+ActorCaptureMgr::ActorCaptureMgr() {
+ mRes.reset();
+ mTimer.reset(30.0);
+}
+
+ActorCaptureMgr::~ActorCaptureMgr() {
+ mActor = nullptr;
+ mCamera = nullptr;
+ res::unregisterEntryFactory(mFactory);
+ util::safeDelete(mFactory);
+}
+
+void ActorCaptureMgr::init(const InitArg& arg) {
+ mFactory = new (arg.heap) res::EntryFactory<res::ActorCapture>(1.0, 0x1000);
+ res::registerEntryFactory(mFactory, "bactcapt");
+
+ res::LoadRequest req;
+ req.mRequester = "ActorCaptureMgr";
+ req._26 = false;
+ mDummyFile.load("Actor/ActorCapture/Dummy.bactcapt", &req);
+}
+
+void ActorCaptureMgr::setCamera(Camera* camera) {
+ if (camera)
+ mCamera = camera;
+}
+
+void ActorCaptureMgr::loadCaptureParam() {
+ if (!mActor || !mActor->mActorParam)
+ return;
+
+ const char* name = getCapturedActorName();
+ if (!name)
+ return;
+
+ res::ActorCapture* param = nullptr;
+
+ {
+ res::LoadRequest req;
+ req.mRequester = "ActorCaptureMgr";
+ sead::FormatFixedSafeString<128> path("Actor/ActorCapture/%s.bactcapt", name);
+ res::ResourceMgrTask::instance()->controlField9c0d88(false);
+ auto* file = sead::DynamicCast<res::ActorCapture>(mCaptureParamFile.load(path, &req));
+ res::ResourceMgrTask::instance()->controlField9c0d88(true);
+ if (file)
+ param = file;
+ if (!param)
+ param = sead::DynamicCast<res::ActorCapture>(mDummyFile.getResource());
+ }
+
+ mRes.mCameraInfoObj.copy(param->mCameraInfoObj);
+ mRes.mActorInfoObj.copy(param->mActorInfoObj);
+ mRes.mLightInfoObj.copy(param->mLightInfoObj);
+}
+
+} // namespace ksys::act