Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions data/file_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154897,7 +154897,7 @@ Util/ItemUtil.o:
- offset: 0x556124
size: 196
label: _ZN2rs23appearRandomItemFromObjEPN2al9LiveActorEPNS0_9HitSensorEf
status: NotDecompiled
status: Matching
- offset: 0x5561e8
size: 184
label: _ZN2rs25tryAppearMultiCoinFromObjEPN2al9LiveActorERKN4sead7Vector3IfEEif
Expand Down Expand Up @@ -154969,11 +154969,11 @@ Util/ItemUtil.o:
- offset: 0x556a78
size: 24
label: _ZN2rs20addDemoRacePrizeCoinEPN2al9LiveActorE
status: NotDecompiled
status: Matching
- offset: 0x556a90
size: 96
label: _ZN18StageSceneFunction20appearPlayerDeadCoinEPN2al9LiveActorE
status: NotDecompiled
status: Matching
Util/JudgeUtil.o:
'.text':
- offset: 0x556af0
Expand Down
6 changes: 3 additions & 3 deletions lib/al/Library/Scene/ItemDirectorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class LiveActor;

class ItemDirectorBase {
public:
virtual void appearItem(const char*, const sead::Vector3f&, const sead::Quatf&,
const HitSensor*) = 0;
virtual void acquireItem(const LiveActor*, HitSensor*, const char*) = 0;
virtual LiveActor* appearItem(const char*, const sead::Vector3f&, const sead::Quatf&,
const HitSensor*) = 0;
virtual void acquireItem(const LiveActor*, HitSensor*, const char*) const = 0;
virtual void declareItem(const char*, const ActorInitInfo&) = 0;
virtual void endInit() = 0;
};
Expand Down
5 changes: 4 additions & 1 deletion src/Item/RandomItemSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Library/Scene/ISceneObj.h"

#include "Scene/SceneObjFactory.h"
#include "Util/ItemUtil.h"

namespace al {
Expand All @@ -10,8 +11,10 @@ class IUseSceneObjHolder;

class RandomItemSelector : public al::ISceneObj {
public:
static constexpr s32 sSceneObjId = SceneObjID_RandomItemSelector;

RandomItemSelector();
rs::ItemType::ValueType getRandomItemType();
rs::ItemType::ValueType getRandomItemType(const al::IUseSceneObjHolder*);

private:
char filler[0x10];
Expand Down
8 changes: 4 additions & 4 deletions src/MapObj/BlockQuestion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ void BlockQuestion::init(const al::ActorInitInfo& initInfo) {
al::initMapPartsActor(this, initInfo, suffix);

mItemType = rs::getItemType(initInfo);
if (mItemType > rs::ItemType::ValueType::None)
if (mItemType > rs::ItemType::None)
rs::initItemByPlacementInfo(this, initInfo, false);

al::tryAddDisplayOffset(this, initInfo);
mShadowLength = rs::setShadowDropLength(this, initInfo, "本体");
al::expandClippingRadiusByShadowLength(this, &_134, mShadowLength);

if (mItemType == rs::ItemType::ValueType::Coin10) {
if (mItemType == rs::ItemType::Coin10) {
mBlockStateTenCoin = new BlockStateTenCoin(this, false);
al::initNerve(this, &NrvBlockQuestion.TenCoin, 1);
al::initNerveState(this, mBlockStateTenCoin, &NrvBlockQuestion.TenCoin, "10コイン");
} else {
mBlockStateSingleItem = new BlockStateSingleItem(this, mItemType, false);
al::initNerve(this, &NrvBlockQuestion.SingleItem, 1);
al::initNerveState(this, mBlockStateSingleItem, &NrvBlockQuestion.SingleItem, "アイテム");
if (mItemType == rs::ItemType::ValueType::Random)
if (mItemType == rs::ItemType::Random)
rs::createRandomItemSelector(this);
}

Expand Down Expand Up @@ -137,7 +137,7 @@ bool BlockQuestion::receiveMsg(const al::SensorMsg* message, al::HitSensor* othe
const sead::Vector3f& selfPos = al::getSensorPos(self);
if (al::isNerve(this, &NrvBlockQuestion.SingleItem) &&
mBlockStateSingleItem->isEnableAppearItem()) {
if (mItemType != rs::ItemType::ValueType::None)
if (mItemType != rs::ItemType::None)
mBlockStateSingleItem->setItemOffsetY(150.0f);

if (rs::isMsgCapAttack(message)) {
Expand Down
39 changes: 39 additions & 0 deletions src/Scene/ProjectItemDirector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <math/seadQuat.h>
#include <math/seadVector.h>

#include "Library/HostIO/HioNode.h"
#include "Library/Scene/ItemDirectorBase.h"

namespace al {
struct ActorInitInfo;
class HitSensor;
class LiveActor;
} // namespace al

class GameDataHolder;

class ProjectItemDirector : public al::HioNode, public al::ItemDirectorBase {
public:
ProjectItemDirector();
ProjectItemDirector(const al::ActorInitInfo&);

al::LiveActor* appearItem(const char*, const sead::Vector3f&, const sead::Quatf&,
const al::HitSensor*) override;

void tryAppearPlayerDeadCoin(const al::LiveActor*, const sead::Vector3f&);
void acquireItem(const al::LiveActor*, al::HitSensor*, const char*) const override;
void declareItem(const char*, const al::ActorInitInfo&) override;
void endInit() override;
void tryAddDemoCountUpCoin();
void initPlayerDeadCoin(GameDataHolder*, const al::ActorInitInfo&);
void setCoinTransForDeadPlayer(GameDataHolder*);
void tryHidePlayerDeadCoinForDemo();
void tryShowPlayerDeadCoinForDemo();

private:
char filler[0x60];
};

static_assert(sizeof(ProjectItemDirector) == 0x68);
37 changes: 33 additions & 4 deletions src/Util/ItemUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
#include "Library/Scene/SceneObjUtil.h"
#include "Library/Stage/StageRhythm.h"

#include "Item/RandomItemSelector.h"
#include "Item/Shine.h"
#include "Scene/ProjectItemDirector.h"
#include "System/GameDataFunction.h"
#include "System/GameDataHolder.h"
#include "System/WorldList.h"
#include "Util/PlayerUtil.h"
#include "Util/SensorMsgFunction.h"

const char* sItem2DNames[] = {
Expand Down Expand Up @@ -517,8 +520,24 @@ void appearItemFromObjGravity(al::LiveActor* actor, al::HitSensor* sensor,
al::appearItem(actor, al::getTrans(actor), quat, nullptr);
}

// TODO: Requires RandomItemSelector
// void appearRandomItemFromObj(al::LiveActor* actor, al::HitSensor* sensor, f32 offset) {}
void appearRandomItemFromObj(al::LiveActor* actor, al::HitSensor* sensor, f32 offset) {
sead::Vector3f upDir = {0.0f, 0.0f, 0.0f};
al::calcUpDir(&upDir, actor);

al::setAppearItemOffset(actor, upDir * offset);
al::setAppearItemAttackerSensor(actor, sensor);

switch (al::getSceneObj<RandomItemSelector>(actor)->getRandomItemType(actor)) {
case rs::ItemType::Coin:
al::appearItemTiming(actor, "コイン");
return;
case rs::ItemType::LifeUpItem:
al::appearItemTiming(actor, "ライフアップ");
return;
default:
return;
}
}

bool tryAppearMultiCoinFromObj(al::LiveActor* actor, const sead::Vector3f& trans, s32 step,
f32 offsetAbove) {
Expand Down Expand Up @@ -670,11 +689,21 @@ void setProjectionMtxAsEmptyModel2d(al::LiveActor* actor, const sead::Vector2f&
al::setModelProjMtx0(actor->getModelKeeper(), matrix);
}

// void addDemoRacePrizeCoin(al::LiveActor* actor); TODO
void addDemoRacePrizeCoin(al::LiveActor* actor) {
ProjectItemDirector* itemDirector =
static_cast<ProjectItemDirector*>(actor->getSceneInfo()->itemDirector);

itemDirector->tryAddDemoCountUpCoin();
}

} // namespace rs

namespace StageSceneFunction {
// void appearPlayerDeadCoin(al::LiveActor* actor); TODO
void appearPlayerDeadCoin(al::LiveActor* actor) {
ProjectItemDirector* itemDirector =
static_cast<ProjectItemDirector*>(actor->getSceneInfo()->itemDirector);
itemDirector->appearItem("コイン[プレイヤー死亡]", rs::getPlayerPos(actor), sead::Quatf::unit,
nullptr);
}

} // namespace StageSceneFunction