begin work on join/disconnect particle effect, fix index oob error

This commit is contained in:
CraftyBoss 2022-07-08 15:09:04 -07:00
parent 88de1dcecf
commit 4f2bb984f2
6 changed files with 39 additions and 34 deletions

View file

@ -66,27 +66,29 @@ class PuppetActor : public al::LiveActor {
void debugTeleportCapture(const sead::Vector3f& pos, int index);
bool mIsDebug = false;
void emitJoinEffect();
float mClosingSpeed = 0;
bool mIsDebug = false;
NameTag *mNameTag = nullptr; // temp public
private:
void changeModel(const char* newModel);
bool setCapture(const char* captureName);
void syncPose();
PlayerCostumeInfo *mCostumeInfo = nullptr;
PuppetInfo *mInfo = nullptr;
PuppetCapActor *mPuppetCap = nullptr;
PlayerModelHolder *mModelHolder = nullptr;
HackModelHolder* mCaptures = nullptr;
NameTag *mNameTag = nullptr;
CaptureTypes::Type mCurCapture = CaptureTypes::Type::Unknown;
bool mIs2DModel = false;
bool mIsCaptureModel = false;
float mClosingSpeed = 0;
};

View file

@ -51,8 +51,6 @@
#include "Keyboard.hpp"
#include "server/DeltaTime.hpp"
static const int playBufSize = 8;
static bool isInGame = false;
static bool debugMode = false;

View file

@ -167,12 +167,6 @@ void drawMainHook(HakoniwaSequence *curSequence, sead::Viewport *viewport, sead:
al::LiveActor *curModel = debugPuppet->getCurrentModel();
gTextWriter->printf("Is Nametag Visible: %s\n", BTOC(debugPuppet->mNameTag->isVisible()));
gTextWriter->printf("Is Nametag Alive: %s\n", BTOC(debugPuppet->mNameTag->mIsAlive));
gTextWriter->printf("Nametag Normalized Dist: %f\n", debugPuppet->mNameTag->mNormalizedDist);
gTextWriter->printf("Nametag State: %s\n", debugPuppet->mNameTag->getCurrentState());
gTextWriter->printf("Is Current Model Clipped: %s\n",
BTOC(al::isClipped(curModel)));
gTextWriter->printf("Is Debug Puppet Tagged: %s\n", BTOC(debugInfo->isIt));
}
@ -370,9 +364,13 @@ bool hakoniwaSequenceHook(HakoniwaSequence* sequence) {
}
if (al::isPadTriggerUp(-1)) {
if (debugMode) {
PuppetInfo* debugPuppet = Client::getDebugPuppetInfo();
PuppetActor* debugPuppet = Client::getDebugPuppet();
if (debugPuppet) {
debugPuppet->isIt = !debugPuppet->isIt;
PuppetInfo *info = debugPuppet->getInfo();
// info->isIt = !info->isIt;
debugPuppet->emitJoinEffect();
}
} else {
isDisableMusic = !isDisableMusic;

View file

@ -1,4 +1,5 @@
#include <cmath>
#include <cstddef>
#include "al/util/SensorUtil.h"
#include "rs/util/SensorUtil.h"
#include "server/Client.hpp"
@ -217,19 +218,15 @@ void PuppetActor::makeActorAlive() {
curModel->makeActorAlive();
}
if (al::isDead(this)) {
// update name tag when puppet becomes active again
if (mInfo) {
if (mNameTag) {
mNameTag->setText(mInfo->puppetName);
}
// update name tag when puppet becomes active again
if (mInfo) {
if (mNameTag) {
mNameTag->setText(mInfo->puppetName);
}
al::LiveActor::makeActorAlive();
}
al::LiveActor::makeActorAlive();
}
void PuppetActor::makeActorDead() {
@ -240,11 +237,9 @@ void PuppetActor::makeActorDead() {
curModel->makeActorDead();
}
if (!al::isDead(this)) {
mPuppetCap->makeActorDead(); // make sure we kill the cap puppet along with regular puppet
al::LiveActor::makeActorDead();
}
mPuppetCap->makeActorDead();
al::LiveActor::makeActorDead();
}
void PuppetActor::attackSensor(al::HitSensor* source, al::HitSensor* target) {
@ -403,3 +398,10 @@ void PuppetActor::syncPose() {
al::setTrans(curModel, al::getTrans(this));
}
void PuppetActor::emitJoinEffect() {
al::tryDeleteEffect(this, "Disappear"); // remove previous effect (if played previously)
al::tryEmitEffect(this, "Disappear", nullptr);
}

View file

@ -2,6 +2,7 @@
#include <math.h>
#include "actors/PuppetActor.h"
#include "al/util.hpp"
#include "al/util/LiveActorUtil.h"
#include "container/seadPtrArray.h"
#include "heap/seadHeap.h"
#include "heap/seadHeapMgr.h"
@ -78,10 +79,14 @@ void PuppetHolder::update() {
curInfo->isInSameStage = checkInfoIsInStage(curInfo);
if(curInfo->isInSameStage) {
if(curInfo->isInSameStage && al::isDead(curPuppet)) {
curPuppet->makeActorAlive();
}else if(!curInfo->isInSameStage) {
curPuppet->emitJoinEffect();
}else if(!curInfo->isInSameStage && !al::isDead(curPuppet)) {
curPuppet->makeActorDead();
curPuppet->emitJoinEffect();
}
}
}

View file

@ -82,13 +82,13 @@ Client::Client() {
nn::account::GetLastOpenedUser(&mUserID);
mUserID.print();
nn::account::Nickname playerName;
nn::account::GetNickname(&playerName, mUserID);
Logger::setLogName(playerName.name); // set Debug logger name to player name
mUsername = playerName.name;
mUserID.print();
Logger::log("Player Name: %s\n", playerName.name);
@ -1064,7 +1064,7 @@ PuppetInfo* Client::findPuppetInfo(const nn::account::Uid& id, bool isFindAvaila
PuppetInfo *firstAvailable = nullptr;
for (size_t i = 0; i < getMaxPlayerCount(); i++) {
for (size_t i = 0; i < getMaxPlayerCount() - 1; i++) {
PuppetInfo* curInfo = mPuppetInfoArr[i];