1#include "Npc/RaceAudienceNpc.h"
2
3#include "Library/LiveActor/ActorActionFunction.h"
4#include "Library/LiveActor/ActorInitUtil.h"
5#include "Library/Math/MathUtil.h"
6#include "Library/Nerve/NerveSetupUtil.h"
7#include "Library/Nerve/NerveUtil.h"
8#include "Library/Placement/PlacementFunction.h"
9
10namespace {
11NERVE_IMPL(RaceAudienceNpc, Wait);
12NERVE_IMPL(RaceAudienceNpc, Dance);
13NERVE_IMPL(RaceAudienceNpc, Jump);
14NERVE_IMPL(RaceAudienceNpc, DanceRandom);
15
16NERVES_MAKE_STRUCT(RaceAudienceNpc, Wait, Dance, Jump, DanceRandom);
17} // namespace
18
19RaceAudienceNpc::RaceAudienceNpc(const char* name) : al::LiveActor(name) {}
20
21void RaceAudienceNpc::init(const al::ActorInitInfo& info) {
22 al::initActor(actor: this, initInfo: info);
23 al::getArg(arg: (s32*)&mAudienceActionType, initInfo: info, key: "AudienceActionType");
24 switch (mAudienceActionType) {
25 case ActionType::Wait:
26 al::initNerve(actor: this, nerve: &NrvRaceAudienceNpc.Wait, maxStates: 0);
27 break;
28 case ActionType::Dance:
29 al::initNerve(actor: this, nerve: &NrvRaceAudienceNpc.Dance, maxStates: 0);
30 break;
31 case ActionType::Jump:
32 al::initNerve(actor: this, nerve: &NrvRaceAudienceNpc.Jump, maxStates: 0);
33 break;
34 }
35 makeActorAlive();
36}
37
38void RaceAudienceNpc::exeWait() {
39 if (al::isFirstStep(user: this))
40 al::startAction(actor: this, actionName: "WaitHappy");
41}
42
43void RaceAudienceNpc::exeDance() {
44 if (al::isFirstStep(user: this)) {
45 al::startAction(actor: this, actionName: "Excited");
46 mDanceTimer = al::getRandom(max: 600) + 600;
47 }
48 if (al::isGreaterEqualStep(user: this, step: mDanceTimer)) {
49 if (mAudienceActionType == ActionType::Jump)
50 al::setNerve(user: this, nerve: &NrvRaceAudienceNpc.Jump);
51 else
52 al::setNerve(user: this, nerve: &NrvRaceAudienceNpc.DanceRandom);
53 }
54}
55
56void RaceAudienceNpc::exeDanceRandom() {
57 if (al::isFirstStep(user: this))
58 al::startAction(actor: this, actionName: "ExcitedRandom");
59 if (al::isActionEnd(actor: this))
60 al::setNerve(user: this, nerve: &NrvRaceAudienceNpc.Dance);
61}
62
63void RaceAudienceNpc::exeJump() {
64 if (al::isFirstStep(user: this))
65 al::startAction(actor: this, actionName: "ExcitedJump");
66}
67