SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
ActorLightCtrl.cpp
1#include "Game/LiveActor/ActorLightCtrl.hpp"
2#include "Game/Map/LightFunction.hpp"
3#include "Game/NameObj/NameObjExecuteHolder.hpp"
4
5ActorLightCtrl::ActorLightCtrl(const LiveActor *pActor)
6 : mActor(pActor), _4(-1), _8(0), _C(0), mAreaLightInf(0), mLightID() {
7 _1C = 0;
8 mInterpolate = -1;
9 _54 = -1;
10}
11
12#ifdef NON_MATCHING
13// initActorLightInfo call is getting inlined
14void ActorLightCtrl::init(int interpolate, bool /* unused */) {
15 if (interpolate >= 0) {
16 _4 = interpolate;
17 _C = 1;
18 }
19
20 initActorLightInfo();
21 tryFindNewAreaLight(false);
22 mAreaLightInf = LightFunction::getAreaLightInfo(mLightID);
23 mLightInfo = *getTargetActorLight(mAreaLightInf);
24}
25#endif
26
27void ActorLightCtrl::update(bool direct) {
28 if (!MR::isHiddenModel(mActor)) {
29 tryFindNewAreaLight(direct);
30 updateLightBlend();
31 }
32}
33
34void ActorLightCtrl::loadLight() const {
35 if (mAreaLightInf) {
36 if (_1C) {
37 LightFunction::loadActorLightInfo(&mLightInfo);
38 }
39 else {
40 LightFunction::loadActorLightInfo(getTargetActorLight(mAreaLightInf));
41 }
42 }
43}
44
45bool ActorLightCtrl::isSameLight(const ActorLightCtrl *pLight) const {
46 if (_1C) {
47 return false;
48 }
49
50 return mAreaLightInf == pLight->mAreaLightInf;
51}
52
53const ActorLightInfo* ActorLightCtrl::getActorLight() const {
54 if (_1C) {
55 return &mLightInfo;
56 }
57
58 return getTargetActorLight(mAreaLightInf);
59}
60
61void ActorLightCtrl::initActorLightInfo() {
62 if (_C) {
63 return;
64 }
65
66 MR::findActorLightInfo(mActor);
67 return;
68}
69
70void ActorLightCtrl::resetCurrentLightInfo() {
71 mAreaLightInf = LightFunction::getAreaLightInfo(mLightID);
72 mInterpolate = mAreaLightInf->mInterpolate;
73 mLightInfo.mInfo0.mIsFollowCamera = getTargetActorLight(mAreaLightInf)->mInfo0.mIsFollowCamera;
74 mLightInfo.mInfo1.mIsFollowCamera = getTargetActorLight(mAreaLightInf)->mInfo1.mIsFollowCamera;
75 _54 = 0;
76}
77
78const ActorLightInfo* ActorLightCtrl::getTargetActorLight(const AreaLightInfo *pInfo) const {
79 s32 type = _4;
80
81 if (type == 0) {
82 return &pInfo->mPlayerLight;
83 }
84 else if (type == 1) {
85 return &pInfo->mStrongLight;
86 }
87 else if (type == 2) {
88 return &pInfo->mWeakLight;
89 }
90 else if (type == 3) {
91 return &pInfo->mPlanetLight;
92 }
93
94 return 0;
95}
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24