1#include "Library/MapObj/KeyMoveMapPartsGenerator.h"
2
3#include "Library/KeyPose/KeyPoseKeeperUtil.h"
4#include "Library/LiveActor/ActorClippingFunction.h"
5#include "Library/LiveActor/ActorInitFunction.h"
6#include "Library/LiveActor/ActorInitUtil.h"
7#include "Library/LiveActor/LiveActorGroup.h"
8#include "Library/MapObj/KeyMoveMapParts.h"
9#include "Library/Nerve/NerveSetupUtil.h"
10#include "Library/Nerve/NerveUtil.h"
11#include "Library/Placement/PlacementFunction.h"
12
13namespace {
14using namespace al;
15
16NERVE_IMPL(KeyMoveMapPartsGenerator, Generate)
17NERVE_IMPL(KeyMoveMapPartsGenerator, Delay)
18
19NERVES_MAKE_STRUCT(KeyMoveMapPartsGenerator, Generate, Delay)
20} // namespace
21
22namespace al {
23KeyMoveMapPartsGenerator::KeyMoveMapPartsGenerator(const char* name) : LiveActor(name) {}
24
25void KeyMoveMapPartsGenerator::init(const ActorInitInfo& info) {
26 initActorSceneInfo(actor: this, info);
27 initExecutorMapObjMovement(actor: this, info);
28 initActorPoseTQSV(actor: this);
29
30 s32 partsCount = 4;
31 tryGetArg(arg: &partsCount, initInfo: info, key: "PartsCount");
32 tryGetArg(arg: &mGenerateInterval, initInfo: info, key: "GenerateInterval");
33 tryGetArg(arg: &mDelayTime, initInfo: info, key: "DelayTime");
34
35 initSubActorKeeperNoFile(this, info, partsCount);
36
37 mKeyMoveMapPartsGroup =
38 new DeriveActorGroup<KeyMoveMapParts>("キー移動マップパーツリスト", partsCount);
39
40 if (calcLinkChildNum(initInfo: info, linkName: "Generate") == 0) {
41 makeActorDead();
42
43 return;
44 }
45
46 for (s32 i = 0; i < partsCount; i++) {
47 KeyMoveMapParts* keyMoveMapParts = new KeyMoveMapParts("キー移動マップマップパーツ");
48
49 initLinksActor(actor: keyMoveMapParts, initInfo: info, suffix: "Generate", linkIndex: 0);
50
51 keyMoveMapParts->setIsStopKill(true);
52 keyMoveMapParts->makeActorDead();
53
54 mKeyMoveMapPartsGroup->registerActor(keyMoveMapParts);
55 }
56
57 KeyMoveMapParts* keyMoveMapParts = mKeyMoveMapPartsGroup->getDeriveActor(idx: 0);
58 f32 clippingRadius = 0.0f;
59 calcKeyMoveClippingInfo(&mClippingTrans, &clippingRadius, keyMoveMapParts->getKeyPoseKeeper(),
60 500.0f);
61 initActorClipping(actor: this, initInfo: info);
62 setClippingInfo(actor: this, clippingRadius, &mClippingTrans);
63 initGroupClipping(actor: this, initInfo: info);
64
65 initNerve(actor: this, nerve: &NrvKeyMoveMapPartsGenerator.Generate, maxStates: 0);
66 if (mDelayTime > 0)
67 setNerve(user: this, nerve: &NrvKeyMoveMapPartsGenerator.Delay);
68 getNerveKeeper()->update();
69
70 initStageSwitch(this, info);
71
72 makeActorAlive();
73}
74
75void KeyMoveMapPartsGenerator::exeDelay() {
76 if (isGreaterEqualStep(user: this, step: mDelayTime - 1))
77 setNerve(user: this, nerve: &NrvKeyMoveMapPartsGenerator.Generate);
78}
79
80void KeyMoveMapPartsGenerator::exeGenerate() {
81 if (isIntervalStep(user: this, interval: mGenerateInterval, offset: 0)) {
82 KeyMoveMapParts* keyMoveMapParts = mKeyMoveMapPartsGroup->tryFindDeadDeriveActor();
83 if (keyMoveMapParts != nullptr)
84 keyMoveMapParts->appearAndSetStart();
85 }
86}
87} // namespace al
88