Skip to content
Draft
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
33 changes: 30 additions & 3 deletions include/Sato/ItemObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <JSystem/JGeometry.h>
#include "Inagaki/GameSoundMgr.h"
#include "JSystem/J3D/J3DModel.h"
#include "JSystem/JGeometry/Vec.h"
#include "Kaneshige/Course/CrsGround.h"
#include "Kaneshige/DarkAnmMgr.h"
Expand Down Expand Up @@ -221,6 +222,7 @@ class ItemObj
void setOwnerNum(int newOwnerNum) { mOwnerNum = newOwnerNum; }
int getOwnerNum() const { return mOwnerNum; }
void setOrigOwnerNum(int newOwnerNum) { mOrigOwnerNum = newOwnerNum; }
bool isSameOwner(int owner) const { return mOwnerNum == owner; }
int getState() const { return mState; }
int getKartReaction() const { return mKartReaction; }
int getDirectHitKartNo() const { return mDirectHitKartNo; }
Expand All @@ -240,6 +242,13 @@ class ItemObj
return mItemKind;
}

bool isStateEquip() const {
return mState == StateEquip;
}
bool isStateDivested() const {
return mState == StateDivested;
}

bool isCertainState() const { // brainrot
bool ret = false;
int state = mState;
Expand All @@ -248,12 +257,27 @@ class ItemObj
}
return ret;
}
bool IsState1or5() const { return (mState != 1 && mState != 5); }
bool IsState1or5AndSameOwner(int owner) const {

bool isHeld() const {
bool ret = false;
if (!isStateEquip()) {
if (!isStateDivested())
ret = true;
}
return ret;
}

bool isHeldByOwner(int owner) const {
bool ret = false;
if (owner == mOwnerNum) {
if ((mState != 1 && mState != 5))
bool ret2 = true;
if (!isStateEquip()) {
if (!isStateDivested())
ret2 = false;
}
if (ret2) {
ret = true;
}
}
return ret;
}
Expand Down Expand Up @@ -292,6 +316,8 @@ class ItemObj
const JGeometry::TVec3f &getVel() const { return mVel; }
const JGeometry::TVec3f getColPos() const { return mColPos; }
ItemObjSuc *getSuccessionParent() const { return mSuccessionParent; }
ExModel *getModel() { return &mModel; }
J3DModelData *getJ3DModelData() const { return mModel.getModelData(); }

void setSuccessionParent(ItemObjSuc *parent) { mSuccessionParent = parent;}
// private:
Expand All @@ -303,6 +329,7 @@ class ItemObj
ExModel::setLightMask(mModel.getModelData(), lightId);
}
void setTevColor() { mAnmPlayer->setTevColor(&mModel); }


typedef void (ItemObj::*StateFunc)();

Expand Down
69 changes: 52 additions & 17 deletions src/Sato/ItemObjMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "JSystem/J3D/J3DTransform.h"
#include "Kaneshige/ExModel.h"
#include "Kaneshige/Objects/GeoRabbitMark.h"
#include "Kaneshige/SimpleDrawer.h"
#include "Kaneshige/TexLODControl.h"
#include "Kaneshige/RaceMgr.h"
#include "Sato/GeographyObjMgr.h"
Expand All @@ -25,6 +26,7 @@

#include "Yamamoto/kartCtrl.h"
#include "dolphin/gx/GXEnum.h"
#include "dolphin/mtx.h"
#include "mathHelper.h"

// WIP
Expand Down Expand Up @@ -500,6 +502,7 @@ ItemObj *ItemObjMgr::equipItemSuccession(u32 kind, int kart_index, u8 driver_ind

void ItemObjMgr::appendItemSuccession(ItemObj *obj, u32 kind, u8 driver_index)
{

}

bool ItemObjMgr::robRivalOfItem(int kart_index1, int kart_index2, u8 driver_index)
Expand Down Expand Up @@ -608,7 +611,7 @@ bool ItemObjMgr::equipItemToKart(int kind, int kart_index, u8 driver_index, bool
bool ret = false;
if (mEquipItem[kart_index][driver_index] == nullptr)
{
ItemObj *obj = equipItem2(kind, kart_index, driver_index); // fabricated inline
ItemObj *obj = equipItem2(kind, kart_index, driver_index);

if (obj == nullptr)
{
Expand Down Expand Up @@ -1405,22 +1408,18 @@ void ItemObjMgr::removeMiniGameList(ItemObj *obj)
mMiniGameList.remove(&obj->mMiniGameLink);
}

void ItemObjMgr::update(ItemObjMgr::eDrawSimplModelItemType type, int id) {
void ItemObjMgr::update(ItemObjMgr::eDrawSimplModelItemType type, int owner) {

for(int i = 0; i < 15; i++) {
for (JSUListIterator<ItemObj> it(_3e8[sJ3DUpdateItemKind[i]].getFirst()); it.isAvailable(); ++it) {
bool doUpdate = true;
switch(type) {
case ItemType_1: {
if (it->IsState1or5AndSameOwner(id))
doUpdate = false;
doUpdate = it->isHeldByOwner(owner);
break;
}
case ItemType_2: {
doUpdate = false;
int state = it->getState();
if (state != 1 && state != 5)
doUpdate = true;
doUpdate = it->isHeld();
break;
}
}
Expand Down Expand Up @@ -1464,27 +1463,63 @@ void ItemObjMgr::setCurrentViewNo(u32 viewNo)
}
}

void ItemObjMgr::drawSimpleModel(u32 viewNo, ItemObjMgr::eDrawSimplModelItemType type, int owner, LightObj *lightObj) {
void ItemObjMgr::drawSimpleModel(u32 viewNo, ItemObjMgr::eDrawSimplModelItemType type, int owner, LightObj *lightObj) {
J3DUClipper *clipper = GetKartCtrl()->getKartCam(viewNo)->GetClipper();
MtxPtr viewMtx = j3dSys.getViewMtx();
MtxPtr effectMtx = nullptr;
if (lightObj) {
effectMtx = lightObj->getEffectMtx();
}

SimpleDrawer drawer;

for(int i = 0; i < 5; i++) {
JSUList<ItemObj> &list = _3e8[sSimpleDrawItemKind[i]];
if (!list.getFirst())
continue;

ExModel *mdl = list.getFirst()->getObject()->getModel();
if (!mdl->getModelData())
continue;

drawer.drawInit(mdl);
while (drawer.loadPreDrawSetting()) {
for (JSUListIterator<ItemObj> it(list.getFirst()); it.isAvailable(); ++it) {
bool doUpdate = true;
switch(type) {
case ItemType_1: {
doUpdate = it->isHeldByOwner(owner);
break;
}
case ItemType_2: {
doUpdate = it->isHeld();
break;
}
}

if (doUpdate) {
it->setTevColor();
it->simpleDraw(viewNo, effectMtx, sSimpleDrawSpeqEnvTexMapID[i]);
}
}
}
}

for (JSUListIterator<ItemObj> it(_3e8[7].getFirst()); it.isAvailable(); ++it) {
bool doUpdate = true;
switch(type) {
case ItemType_1: {
if (it->IsState1or5AndSameOwner(owner))
doUpdate = false;
doUpdate = it->isHeldByOwner(owner);
break;
}
case ItemType_2: {
doUpdate = false;
int state = it->getState();
if (state != 1 && state != 5)
doUpdate = true;
doUpdate = it->isHeld();
break;
}
}

if (doUpdate) {
//it->drawSimpleModel(viewNo, j3dSys.getViewMtx(), );
it->drawSimpleModel(viewNo, viewMtx, clipper, effectMtx);
}
}
}
Expand Down Expand Up @@ -1610,7 +1645,7 @@ u32 ItemShuffleMgr::getRndItemKindPossibilityGetting(stRandom *rnd, const int ka

u32 randomNum = rnd->getRandomMax(numItems + numSpecialItems - 1);
if (randomNum < numItems) {
return sRndSpecialSlotIndex[randomNum];
return sRndNormalSlotIndex[randomNum];
}

if (!special) {
Expand Down