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