mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Player: Implement PlayerUtil (#650)
This commit is contained in:
parent
7173a10a3a
commit
ec1bd72b9f
|
|
@ -273366,7 +273366,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a3e74
|
||||
size: 24
|
||||
label: _ZN2al15getPlayerNumMaxEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a3e8c
|
||||
size: 4
|
||||
label: _ZN2al15getPlayerNumMaxEPKNS_12PlayerHolderE
|
||||
|
|
@ -273374,7 +273374,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a3e90
|
||||
size: 116
|
||||
label: _ZN2al17getAlivePlayerNumEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a3f04
|
||||
size: 108
|
||||
label: _ZN2al17getAlivePlayerNumEPKNS_12PlayerHolderE
|
||||
|
|
@ -273382,7 +273382,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a3f70
|
||||
size: 40
|
||||
label: _ZN2al14getPlayerActorEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a3f98
|
||||
size: 4
|
||||
label: _ZN2al14getPlayerActorEPKNS_12PlayerHolderEi
|
||||
|
|
@ -273390,7 +273390,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a3f9c
|
||||
size: 48
|
||||
label: _ZN2al12getPlayerPosEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a3fcc
|
||||
size: 24
|
||||
label: _ZN2al12getPlayerPosEPKNS_12PlayerHolderEi
|
||||
|
|
@ -273398,7 +273398,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a3fe4
|
||||
size: 40
|
||||
label: _ZN2al17tryGetPlayerActorEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a400c
|
||||
size: 4
|
||||
label: _ZN2al17tryGetPlayerActorEPKNS_12PlayerHolderEi
|
||||
|
|
@ -273406,7 +273406,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a4010
|
||||
size: 44
|
||||
label: _ZN2al12isPlayerDeadEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a403c
|
||||
size: 20
|
||||
label: _ZN2al12isPlayerDeadEPKNS_12PlayerHolderEi
|
||||
|
|
@ -273414,7 +273414,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a4050
|
||||
size: 44
|
||||
label: _ZN2al18isPlayerAreaTargetEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a407c
|
||||
size: 20
|
||||
label: _ZN2al18isPlayerAreaTargetEPKNS_12PlayerHolderEi
|
||||
|
|
@ -273422,7 +273422,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a4090
|
||||
size: 104
|
||||
label: _ZN2al28tryFindAlivePlayerActorFirstEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a40f8
|
||||
size: 96
|
||||
label: _ZN2al28tryFindAlivePlayerActorFirstEPKNS_12PlayerHolderE
|
||||
|
|
@ -273430,7 +273430,7 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a4158
|
||||
size: 104
|
||||
label: _ZN2al25findAlivePlayerActorFirstEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a41c0
|
||||
size: 96
|
||||
label: _ZN2al25findAlivePlayerActorFirstEPKNS_12PlayerHolderE
|
||||
|
|
@ -273438,131 +273438,131 @@ Library/Player/PlayerUtil.o:
|
|||
- offset: 0x9a4220
|
||||
size: 40
|
||||
label: _ZN2al24getPlayerPadRumbleKeeperEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4248
|
||||
size: 24
|
||||
label: _ZN2al13getPlayerPortEPKNS_12PlayerHolderEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4260
|
||||
size: 48
|
||||
label: _ZN2al13getPlayerPortEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4290
|
||||
size: 4
|
||||
label: _ZN2al28findAlivePlayerActorFromPortEPKNS_12PlayerHolderEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4294
|
||||
size: 160
|
||||
label: _ZN2al31tryFindAlivePlayerActorFromPortEPKNS_12PlayerHolderEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4334
|
||||
size: 40
|
||||
label: _ZN2al28findAlivePlayerActorFromPortEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a435c
|
||||
size: 40
|
||||
label: _ZN2al31tryFindAlivePlayerActorFromPortEPKNS_9LiveActorEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4384
|
||||
size: 256
|
||||
label: _ZN2al19findNearestPlayerIdEPKNS_9LiveActorEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4484
|
||||
size: 256
|
||||
label: ''
|
||||
status: NotDecompiled
|
||||
label: _ZN2al28findNearestPlayerIdConditionEPKNS_9LiveActorERKN4sead7Vector3IfEEPFbS2_Ef
|
||||
status: Matching
|
||||
- offset: 0x9a4584
|
||||
size: 56
|
||||
label: _ZN2al22findNearestPlayerActorEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a45bc
|
||||
size: 76
|
||||
label: _ZN2al25tryFindNearestPlayerActorEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4608
|
||||
size: 64
|
||||
label: _ZN2al20findNearestPlayerPosEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4648
|
||||
size: 124
|
||||
label: _ZN2al23tryFindNearestPlayerPosEPN4sead7Vector3IfEEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a46c4
|
||||
size: 344
|
||||
label: _ZN2al39tryFindNearestPlayerDisatanceFromTargetEPfPKNS_9LiveActorERKN4sead7Vector3IfEE
|
||||
status: NotDecompiled
|
||||
status: NonMatchingMinor
|
||||
- offset: 0x9a481c
|
||||
size: 28
|
||||
label: _ZN2al12isNearPlayerEPKNS_9LiveActorEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4838
|
||||
size: 264
|
||||
label: _ZN2al13isNearPlayerHEPKNS_9LiveActorEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4940
|
||||
size: 120
|
||||
label: _ZN2al22isNearPlayerHConditionEPKNS_9LiveActorEfPFbS2_E
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a49b8
|
||||
size: 180
|
||||
label: _ZN2al19getFarPlayerPosMaxXEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4a6c
|
||||
size: 180
|
||||
label: _ZN2al19getFarPlayerPosMinXEPKNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4b20
|
||||
size: 508
|
||||
label: _ZN2al29calcPlayerListOrderByDistanceEPKNS_9LiveActorEPS2_j
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4d1c
|
||||
size: 200
|
||||
label: _ZN2al20calcAlivePlayerActorEPKNS_9LiveActorEPS2_j
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4de4
|
||||
size: 96
|
||||
label: _ZN2al34tryFindNearestPlayerActorConditionEPKNS_9LiveActorEPFbS2_E
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4e44
|
||||
size: 144
|
||||
label: _ZN2al32tryFindNearestPlayerPosConditionEPN4sead7Vector3IfEEPKNS_9LiveActorEPFbS6_E
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4ed4
|
||||
size: 84
|
||||
label: _ZN2al20isResetablePlayerPosEPKNS_9LiveActorERKN4sead7Vector3IfEEff
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4f28
|
||||
size: 108
|
||||
label: _ZN2al20isResetablePlayerPosEPKNS_9LiveActorEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4f94
|
||||
size: 80
|
||||
label: _ZN2al12faceToPlayerEPNS_9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a4fe4
|
||||
size: 48
|
||||
label: _ZN16alPlayerFunction14registerPlayerEPN2al9LiveActorEPNS0_15PadRumbleKeeperE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a5014
|
||||
size: 24
|
||||
label: _ZN16alPlayerFunction18isFullPlayerHolderEPN2al9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a502c
|
||||
size: 108
|
||||
label: _ZN16alPlayerFunction21findPlayerHolderIndexEPKN2al9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a5098
|
||||
size: 112
|
||||
label: _ZN16alPlayerFunction21findPlayerHolderIndexEPKN2al9HitSensorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a5108
|
||||
size: 112
|
||||
label: _ZN16alPlayerFunction13isPlayerActorEPKN2al9LiveActorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9a5178
|
||||
size: 116
|
||||
label: _ZN16alPlayerFunction13isPlayerActorEPKN2al9HitSensorE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
Library/PostProcessing/CameraBlurController.o:
|
||||
'.text':
|
||||
- offset: 0x9a51ec
|
||||
|
|
|
|||
|
|
@ -1,56 +1,92 @@
|
|||
#include "Library/Player/PlayerUtil.h"
|
||||
|
||||
#include "Library/Controller/PadRumbleDirector.h"
|
||||
#include "Library/LiveActor/ActorClippingFunction.h"
|
||||
#include "Library/LiveActor/ActorFlagFunction.h"
|
||||
#include "Library/LiveActor/ActorModelFunction.h"
|
||||
#include "Library/LiveActor/ActorMovementFunction.h"
|
||||
#include "Library/LiveActor/ActorPoseUtil.h"
|
||||
#include "Library/LiveActor/ActorSceneInfo.h"
|
||||
#include "Library/LiveActor/ActorSensorUtil.h"
|
||||
#include "Library/LiveActor/LiveActor.h"
|
||||
#include "Library/Player/PlayerHolder.h"
|
||||
#include "Project/Controller/PadRumbleKeeper.h"
|
||||
|
||||
namespace al {
|
||||
|
||||
s32 getPlayerNumMax(const LiveActor* actor) {
|
||||
return getPlayerNumMax(actor->getSceneInfo()->playerHolder);
|
||||
}
|
||||
|
||||
s32 getPlayerNumMax(const PlayerHolder* holder) {
|
||||
return holder->getPlayerNum();
|
||||
}
|
||||
|
||||
s32 getAlivePlayerNum(const PlayerHolder* holder) {
|
||||
s32 player_num = holder->getPlayerNum();
|
||||
s32 alive_players = 0;
|
||||
s32 getAlivePlayerNum(const LiveActor* actor) {
|
||||
return getAlivePlayerNum(actor->getSceneInfo()->playerHolder);
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < player_num; i++) {
|
||||
LiveActor* player = holder->tryGetPlayer(i);
|
||||
s32 getAlivePlayerNum(const PlayerHolder* holder) {
|
||||
s32 playerNum = getPlayerNumMax(holder);
|
||||
s32 alivePlayers = 0;
|
||||
|
||||
for (s32 i = 0; i < playerNum; i++) {
|
||||
LiveActor* player = getPlayerActor(holder, i);
|
||||
if (isAlive(player))
|
||||
alive_players++;
|
||||
alivePlayers++;
|
||||
}
|
||||
|
||||
return alive_players;
|
||||
return alivePlayers;
|
||||
}
|
||||
|
||||
LiveActor* getPlayerActor(const LiveActor* actor, s32 index) {
|
||||
return getPlayerActor(actor->getSceneInfo()->playerHolder, index);
|
||||
}
|
||||
|
||||
LiveActor* getPlayerActor(const PlayerHolder* holder, s32 index) {
|
||||
return holder->tryGetPlayer(index);
|
||||
return tryGetPlayerActor(holder, index);
|
||||
}
|
||||
|
||||
const sead::Vector3f& getPlayerPos(const LiveActor* actor, s32 index) {
|
||||
return getPlayerPos(actor->getSceneInfo()->playerHolder, index);
|
||||
}
|
||||
|
||||
const sead::Vector3f& getPlayerPos(const PlayerHolder* holder, s32 index) {
|
||||
LiveActor* player = holder->tryGetPlayer(index);
|
||||
return getTrans(player);
|
||||
return getTrans(getPlayerActor(holder, index));
|
||||
}
|
||||
|
||||
LiveActor* tryGetPlayerActor(const LiveActor* actor, s32 index) {
|
||||
return tryGetPlayerActor(actor->getSceneInfo()->playerHolder, index);
|
||||
}
|
||||
|
||||
LiveActor* tryGetPlayerActor(const PlayerHolder* holder, s32 index) {
|
||||
return holder->tryGetPlayer(index);
|
||||
}
|
||||
|
||||
bool isPlayerDead(const LiveActor* actor, s32 index) {
|
||||
return isPlayerDead(actor->getSceneInfo()->playerHolder, index);
|
||||
}
|
||||
|
||||
bool isPlayerDead(const PlayerHolder* holder, s32 index) {
|
||||
LiveActor* player = holder->tryGetPlayer(index);
|
||||
return isDead(player);
|
||||
return isDead(getPlayerActor(holder, index));
|
||||
}
|
||||
|
||||
bool isPlayerAreaTarget(const LiveActor* actor, s32 index) {
|
||||
return isPlayerAreaTarget(actor->getSceneInfo()->playerHolder, index);
|
||||
}
|
||||
|
||||
bool isPlayerAreaTarget(const PlayerHolder* holder, s32 index) {
|
||||
LiveActor* player = holder->tryGetPlayer(index);
|
||||
return isAreaTarget(player);
|
||||
return isAreaTarget(getPlayerActor(holder, index));
|
||||
}
|
||||
|
||||
LiveActor* tryFindAlivePlayerActorFirst(const LiveActor* actor) {
|
||||
return tryFindAlivePlayerActorFirst(actor->getSceneInfo()->playerHolder);
|
||||
}
|
||||
|
||||
LiveActor* tryFindAlivePlayerActorFirst(const PlayerHolder* holder) {
|
||||
u32 player_num = holder->getPlayerNum();
|
||||
u32 playerNum = getPlayerNumMax(holder);
|
||||
|
||||
for (u32 i = 0; i < player_num; i++) {
|
||||
for (u32 i = 0; i < playerNum; i++) {
|
||||
LiveActor* player = holder->tryGetPlayer(i);
|
||||
if (!isDead(player))
|
||||
return player;
|
||||
|
|
@ -59,15 +95,331 @@ LiveActor* tryFindAlivePlayerActorFirst(const PlayerHolder* holder) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
LiveActor* findAlivePlayerActorFirst(const LiveActor* actor) {
|
||||
return findAlivePlayerActorFirst(actor->getSceneInfo()->playerHolder);
|
||||
}
|
||||
|
||||
LiveActor* findAlivePlayerActorFirst(const PlayerHolder* holder) {
|
||||
u32 player_num = holder->getPlayerNum();
|
||||
return tryFindAlivePlayerActorFirst(holder);
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < player_num; i++) {
|
||||
LiveActor* player = holder->tryGetPlayer(i);
|
||||
if (!isDead(player))
|
||||
static inline PadRumbleKeeper* getPlayerPadRumbleKeeper(const PlayerHolder* holder, s32 index) {
|
||||
return holder->getPadRumbleKeeper(index);
|
||||
}
|
||||
|
||||
PadRumbleKeeper* getPlayerPadRumbleKeeper(const LiveActor* actor, s32 index) {
|
||||
return getPlayerPadRumbleKeeper(actor->getSceneInfo()->playerHolder, index);
|
||||
}
|
||||
|
||||
s32 getPlayerPort(const PlayerHolder* holder, s32 index) {
|
||||
return getPlayerPadRumbleKeeper(holder, index)->getPort();
|
||||
}
|
||||
|
||||
s32 getPlayerPort(const LiveActor* actor, s32 index) {
|
||||
return getPlayerPort(actor->getSceneInfo()->playerHolder, index);
|
||||
}
|
||||
|
||||
LiveActor* findAlivePlayerActorFromPort(const PlayerHolder* holder, s32 port) {
|
||||
return tryFindAlivePlayerActorFromPort(holder, port);
|
||||
}
|
||||
|
||||
LiveActor* tryFindAlivePlayerActorFromPort(const PlayerHolder* holder, s32 port) {
|
||||
s32 playerNum = getPlayerNumMax(holder);
|
||||
|
||||
for (s32 i = 0; i < playerNum; i++) {
|
||||
LiveActor* player = tryGetPlayerActor(holder, i);
|
||||
if (getPlayerPort(player, i) == port && !isPlayerDead(player, i))
|
||||
return player;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LiveActor* findAlivePlayerActorFromPort(const LiveActor* actor, s32 port) {
|
||||
return tryFindAlivePlayerActorFromPort(actor, port);
|
||||
}
|
||||
|
||||
LiveActor* tryFindAlivePlayerActorFromPort(const LiveActor* actor, s32 port) {
|
||||
return tryFindAlivePlayerActorFromPort(actor->getSceneInfo()->playerHolder, port);
|
||||
}
|
||||
|
||||
s32 findNearestPlayerIdCondition(const LiveActor* actor, const sead::Vector3f& pos,
|
||||
bool (*condition)(const LiveActor*), f32 threshold) {
|
||||
PlayerHolder* holder = actor->getSceneInfo()->playerHolder;
|
||||
s32 playerNum = getPlayerNumMax(holder);
|
||||
|
||||
f32 minDistance = sead::Mathf::maxNumber();
|
||||
s32 nearestPlayerId = -1;
|
||||
for (s32 i = 0; i < playerNum; i++) {
|
||||
LiveActor* player = holder->getPlayer(i);
|
||||
if (!player || condition(player))
|
||||
continue;
|
||||
const sead::Vector3f& playerPos = getTrans(player);
|
||||
f32 distance = (playerPos - pos).squaredLength();
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
nearestPlayerId = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (threshold * threshold < minDistance && threshold > 0.0f)
|
||||
return -1;
|
||||
|
||||
return nearestPlayerId;
|
||||
}
|
||||
|
||||
s32 findNearestPlayerId(const LiveActor* actor, f32 threshold) {
|
||||
return findNearestPlayerIdCondition(actor, getTrans(actor), &isDead, threshold);
|
||||
}
|
||||
|
||||
LiveActor* findNearestPlayerActor(const LiveActor* actor) {
|
||||
return getPlayerActor(actor, findNearestPlayerId(actor, -1.0f));
|
||||
}
|
||||
|
||||
LiveActor* tryFindNearestPlayerActor(const LiveActor* actor) {
|
||||
s32 nearestPlayerId = findNearestPlayerId(actor, -1.0f);
|
||||
if (nearestPlayerId < 0)
|
||||
return nullptr;
|
||||
return getPlayerActor(actor, nearestPlayerId);
|
||||
}
|
||||
|
||||
const sead::Vector3f& findNearestPlayerPos(const LiveActor* actor) {
|
||||
return getPlayerPos(actor, findNearestPlayerId(actor, -1.0f));
|
||||
}
|
||||
|
||||
bool tryFindNearestPlayerPos(sead::Vector3f* pos, const LiveActor* actor) {
|
||||
s32 nearestPlayerId = findNearestPlayerId(actor, -1.0f);
|
||||
if (nearestPlayerId < 0)
|
||||
return false;
|
||||
LiveActor* player = getPlayerActor(actor, nearestPlayerId);
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
*pos = getTrans(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
// NON_MATCHING: regalloc (https://decomp.me/scratch/XLeWX)
|
||||
bool tryFindNearestPlayerDisatanceFromTarget(f32* distance, const LiveActor* actor,
|
||||
const sead::Vector3f& target) {
|
||||
s32 nearestPlayerId = findNearestPlayerIdCondition(actor, target, &isDead, -1.0f);
|
||||
if (nearestPlayerId < 0)
|
||||
return false;
|
||||
|
||||
LiveActor* player = getPlayerActor(actor, nearestPlayerId);
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
*distance = (getTrans(player) - target).length();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isNearPlayer(const LiveActor* actor, f32 threshold) {
|
||||
return findNearestPlayerId(actor, threshold) >= 0;
|
||||
}
|
||||
|
||||
// BUG: This only checks the nearest player (overall), not all players
|
||||
bool isNearPlayerH(const LiveActor* actor, f32 threshold) {
|
||||
s32 nearestPlayerId = findNearestPlayerId(actor, -1.0f);
|
||||
if (nearestPlayerId < 0)
|
||||
return false;
|
||||
|
||||
sead::Vector3f playerPos = getPlayerPos(actor, nearestPlayerId);
|
||||
sead::Vector3f diff = playerPos - getTrans(actor);
|
||||
f32 hDiff = diff.dot(getGravity(actor));
|
||||
return (diff - getGravity(actor) * hDiff).length() <= threshold;
|
||||
}
|
||||
|
||||
// BUG: This only checks the nearest player (overall), not all players
|
||||
bool isNearPlayerHCondition(const LiveActor* actor, f32 threshold,
|
||||
bool (*condition)(const LiveActor*)) {
|
||||
s32 nearestPlayerId = findNearestPlayerIdCondition(actor, getTrans(actor), condition, -1.0f);
|
||||
if (nearestPlayerId < 0)
|
||||
return false;
|
||||
|
||||
return calcDistanceH(getPlayerActor(actor, nearestPlayerId), actor) <= threshold;
|
||||
}
|
||||
|
||||
const sead::Vector3f& getFarPlayerPosMaxX(const LiveActor* actor) {
|
||||
PlayerHolder* holder = actor->getSceneInfo()->playerHolder;
|
||||
getTrans(actor);
|
||||
|
||||
const LiveActor* farPlayer = nullptr;
|
||||
f32 maxX = -1.0f;
|
||||
for (s32 i = 0; i < getPlayerNumMax(holder); i++) {
|
||||
LiveActor* player = holder->getPlayer(i);
|
||||
if (!farPlayer || maxX < getTrans(player).x) {
|
||||
maxX = getTrans(player).x;
|
||||
farPlayer = player;
|
||||
}
|
||||
}
|
||||
|
||||
return getTrans(farPlayer);
|
||||
}
|
||||
|
||||
const sead::Vector3f& getFarPlayerPosMinX(const LiveActor* actor) {
|
||||
PlayerHolder* holder = actor->getSceneInfo()->playerHolder;
|
||||
getTrans(actor);
|
||||
|
||||
const LiveActor* farPlayer = nullptr;
|
||||
f32 minX = -1.0f;
|
||||
for (s32 i = 0; i < getPlayerNumMax(holder); i++) {
|
||||
LiveActor* player = holder->getPlayer(i);
|
||||
if (!farPlayer || getTrans(player).x < minX) {
|
||||
minX = getTrans(player).x;
|
||||
farPlayer = player;
|
||||
}
|
||||
}
|
||||
|
||||
return getTrans(farPlayer);
|
||||
}
|
||||
|
||||
u32 calcPlayerListOrderByDistance(const LiveActor* actor, const LiveActor** actorList, u32 size) {
|
||||
u32 playerNum = getPlayerNumMax(actor);
|
||||
const sead::Vector3f& pos = getTrans(actor);
|
||||
|
||||
f32 distances[64];
|
||||
for (s32 i = 0; i != playerNum; i++) {
|
||||
LiveActor* player = getPlayerActor(actor, i);
|
||||
f32 distance = sead::Mathf::maxNumber();
|
||||
if (!isDead(player)) {
|
||||
sead::Vector3f playerPos = getTrans(player);
|
||||
distance = (playerPos - pos).squaredLength();
|
||||
}
|
||||
distances[i] = distance;
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < size; i++) {
|
||||
f32 min_distance = sead::Mathf::maxNumber();
|
||||
s32 min_index = -1;
|
||||
|
||||
for (u32 i = 0; i < playerNum; i++) {
|
||||
if (distances[i] <= min_distance) {
|
||||
min_distance = distances[i];
|
||||
min_index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (min_index == -1)
|
||||
return i;
|
||||
|
||||
actorList[i] = getPlayerActor(actor, min_index);
|
||||
distances[min_index] = sead::Mathf::maxNumber();
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// TODO: flag-loop issue, this shouldn't be written like this
|
||||
static s32 blackBox(s32 value) {
|
||||
__asm__("" : "+r"(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
u32 calcAlivePlayerActor(const LiveActor* actor, const LiveActor** actorList, u32 size) {
|
||||
u32 playerNum = getPlayerNumMax(actor);
|
||||
s32 flag = 2;
|
||||
u32 result;
|
||||
u32 resultNum = 0;
|
||||
|
||||
if (playerNum != 0) {
|
||||
for (u32 i = 0; i < playerNum; i++) {
|
||||
LiveActor* player = getPlayerActor(actor, i);
|
||||
if (!isDead(player)) {
|
||||
actorList[resultNum] = player;
|
||||
resultNum++;
|
||||
if (resultNum >= size) {
|
||||
result = size;
|
||||
flag = 1;
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
} else {
|
||||
flag = 4;
|
||||
}
|
||||
|
||||
if ((blackBox(flag | 4) & 7) != 4)
|
||||
goto end;
|
||||
}
|
||||
flag = 2;
|
||||
}
|
||||
end:
|
||||
if (flag != 2)
|
||||
resultNum = result;
|
||||
return resultNum;
|
||||
}
|
||||
|
||||
LiveActor* tryFindNearestPlayerActorCondition(const LiveActor* actor,
|
||||
bool (*condition)(const LiveActor*)) {
|
||||
s32 nearestPlayerId = findNearestPlayerIdCondition(actor, getTrans(actor), condition, -1.0f);
|
||||
if (nearestPlayerId < 0)
|
||||
return nullptr;
|
||||
return getPlayerActor(actor, nearestPlayerId);
|
||||
}
|
||||
|
||||
bool tryFindNearestPlayerPosCondition(sead::Vector3f* pos, const LiveActor* actor,
|
||||
bool (*condition)(const LiveActor*)) {
|
||||
LiveActor* nearestPlayer = tryFindNearestPlayerActorCondition(actor, condition);
|
||||
if (!nearestPlayer)
|
||||
return false;
|
||||
*pos = getTrans(nearestPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isResetablePlayerPos(const LiveActor* actor, const sead::Vector3f& pos, f32 clippingRadius,
|
||||
f32 threshold) {
|
||||
if (isJudgedToClipFrustum(actor, pos, clippingRadius, 300.0f) &&
|
||||
!isNearPlayer(actor, threshold))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isResetablePlayerPos(const LiveActor* actor, f32 threshold) {
|
||||
return isResetablePlayerPos(actor, getTrans(actor), getClippingRadius(actor), threshold);
|
||||
}
|
||||
|
||||
void faceToPlayer(LiveActor* actor) {
|
||||
sead::Vector3f dir;
|
||||
calcDirToActorH(&dir, actor, getPlayerActor(actor, 0));
|
||||
faceToDirection(actor, dir);
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
|
||||
namespace alPlayerFunction {
|
||||
|
||||
void registerPlayer(al::LiveActor* actor, al::PadRumbleKeeper* padRumbleKeeper) {
|
||||
return actor->getSceneInfo()->playerHolder->registerPlayer(actor, padRumbleKeeper);
|
||||
}
|
||||
|
||||
bool isFullPlayerHolder(al::LiveActor* actor) {
|
||||
return actor->getSceneInfo()->playerHolder->isFull();
|
||||
}
|
||||
|
||||
s32 findPlayerHolderIndex(const al::LiveActor* actor) {
|
||||
al::PlayerHolder* playerHolder = actor->getSceneInfo()->playerHolder;
|
||||
s32 playerNum = playerHolder->getPlayerNum();
|
||||
for (s32 i = 0; i < playerNum; i++)
|
||||
if (playerHolder->getPlayer(i) == actor)
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 findPlayerHolderIndex(const al::HitSensor* sensor) {
|
||||
return findPlayerHolderIndex(al::getSensorHost(sensor));
|
||||
}
|
||||
|
||||
bool isPlayerActor(const al::LiveActor* actor) {
|
||||
al::PlayerHolder* playerHolder = actor->getSceneInfo()->playerHolder;
|
||||
s32 playerNum = playerHolder->getPlayerNum();
|
||||
for (s32 i = 0; i < playerNum; i++)
|
||||
if (playerHolder->getPlayer(i) == actor)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isPlayerActor(const al::HitSensor* sensor) {
|
||||
return isPlayerActor(al::getSensorHost(sensor));
|
||||
}
|
||||
|
||||
} // namespace alPlayerFunction
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class PadRumbleKeeper {
|
|||
public:
|
||||
PadRumbleKeeper(s32 port);
|
||||
|
||||
s32 getPort() const { return mPort; }
|
||||
|
||||
private:
|
||||
s32 mPort;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue