1#include "MapObj/AllDeadWatcherWithShine.h"
2
3#include "Library/LiveActor/ActorFlagFunction.h"
4#include "Library/LiveActor/ActorInitFunction.h"
5#include "Library/LiveActor/ActorInitUtil.h"
6#include "Library/LiveActor/ActorPoseUtil.h"
7#include "Library/Nerve/NerveSetupUtil.h"
8#include "Library/Nerve/NerveUtil.h"
9#include "Library/Placement/PlacementFunction.h"
10
11#include "Item/Shine.h"
12#include "Util/ItemUtil.h"
13
14namespace {
15NERVE_IMPL(AllDeadWatcherWithShine, Watch);
16NERVE_IMPL(AllDeadWatcherWithShine, Wait);
17
18NERVES_MAKE_NOSTRUCT(AllDeadWatcherWithShine, Watch, Wait);
19} // namespace
20
21AllDeadWatcherWithShine::AllDeadWatcherWithShine(const char* name) : al::LiveActor(name) {}
22
23void AllDeadWatcherWithShine::init(const al::ActorInitInfo& info) {
24 al::initActorSceneInfo(actor: this, info);
25 al::initExecutorWatchObj(actor: this, info);
26 al::initNerve(actor: this, nerve: &Watch, maxStates: 0);
27
28 mChildCount = al::calcLinkChildNum(initInfo: info, linkName: "WatchTargetEnemy");
29 mChildActors = new LiveActor*[mChildCount];
30
31 for (s32 i = 0; i < mChildCount; i++)
32 mChildActors[i] = al::createLinksActorFromFactory(initInfo: info, linkName: "WatchTargetEnemy", linkNum: i);
33
34 al::tryGetArg(arg: &mSwitchOnDelayStep, initInfo: info, key: "SwitchOnDelayStep");
35 mIsNotControlActorAppear = al::tryGetBoolArgOrFalse(initInfo: info, key: "IsNotControlActorAppear");
36
37 mShine = rs::tryInitLinkShine(info, name: "ShineActor", linkIndex: 0);
38
39 makeActorAlive();
40}
41
42void AllDeadWatcherWithShine::appear() {
43 al::LiveActor::appear();
44
45 if (!mIsNotControlActorAppear)
46 for (s32 i = 0; i < mChildCount; i++)
47 mChildActors[i]->appear();
48}
49
50void AllDeadWatcherWithShine::kill() {
51 al::LiveActor::kill();
52}
53
54void AllDeadWatcherWithShine::exeWatch() {
55 for (s32 i = 0; i < mChildCount; i++) {
56 if (al::isAlive(actor: mChildActors[i])) {
57 rs::updateHintTrans(shine: mShine, trans: al::getTrans(actor: mChildActors[i]));
58 return;
59 }
60 }
61
62 al::setNerve(user: this, nerve: &Wait);
63}
64
65void AllDeadWatcherWithShine::exeWait() {
66 if (al::isGreaterEqualStep(user: this, step: mSwitchOnDelayStep)) {
67 kill();
68
69 mShine->appearPopup();
70 rs::updateHintTrans(shine: mShine, trans: al::getTrans(actor: mShine));
71 }
72}
73