Use private fields + getters for CEntity

This commit is contained in:
Luke Street 2022-10-22 11:56:07 -04:00
parent 1ddf72b492
commit 3e2ea84c7e
25 changed files with 59 additions and 59 deletions

View File

@ -30,7 +30,7 @@ public:
TUniqueId GetUniqueId() const { return x8_uid; }
TEditorId GetEditorId() const { return xc_editorId; }
TAreaId GetAreaId() const;
TAreaId GetAreaIdAlways() const { return x4_areaId; }
TAreaId GetCurrentAreaId() const { return x4_areaId; }
bool GetActive() const { return x30_24_active; }
bool IsScriptingBlocked() const { return x30_26_scriptingBlocked; }
@ -40,7 +40,7 @@ public:
static rstl::vector< SConnection > NullConnectionList;
protected:
private:
TAreaId x4_areaId;
TUniqueId x8_uid;
TEditorId xc_editorId;

View File

@ -152,7 +152,7 @@ public:
const CEnvFxManager* GetEnvFxManager() const { return x880_envFxManager; }
CRumbleManager* GetRumbleManager() { return x88c_rumbleManager; }
CRandom16* GetActiveRandom() const { return x900_random; }
CRandom16* Random() const { return x900_random; }
CObjectList& GetObjectListById(EGameObjectList id) { return *x808_objectLists[id]; }

View File

@ -61,9 +61,9 @@ public:
int IGetAreaCount() const override;
const CGameArea& GetAreaAlways(TAreaId id) const { return *x18_areas[id.Value()]; }
const CGameArea* GetArea(TAreaId id) const { return x18_areas[id.Value()].get(); }
CGameArea* Area(TAreaId id) { return x18_areas[id.Value()].get(); }
bool IsAreaValid(TAreaId id) const { return x18_areas[id.Value()]->IsLoaded(); }
const CGameArea* GetArea(TAreaId id) const { return x18_areas[id.Value()].get(); }
bool IsAreaValid(TAreaId id) const { return GetArea(id)->IsLoaded(); }
CAssetId GetWorldAssetId() const { return x8_mlvlId; }
TAreaId GetAreaIdForSaveId(int saveId) const;

View File

@ -21,7 +21,7 @@ void CABSFlinch::Start(CBodyController& bc, CStateManager& mgr) {
const CPASDatabase& pasDB = bc.GetPASDatabase();
CPASAnimParmData parms(pas::kAS_AdditiveFlinch);
rstl::pair< float, int > best = pasDB.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
rstl::pair< float, int > best = pasDB.FindBestAnimation(parms, *mgr.Random(), -1);
x8_anim = best.second;
CAnimData& animData = *bc.GetOwner().ModelData()->AnimationData();

View File

@ -110,7 +110,7 @@ CAdvancementDeltas CActor::UpdateAnimation(float dt, CStateManager& mgr, bool ad
UpdateSfxEmitters();
if (HasAnimation()) {
ushort maxVol = xd4_maxVol;
int aid = x4_areaId.Value();
int aid = GetCurrentAreaId().Value();
const CGameCamera* camera = mgr.GetCameraManager()->GetCurrentCamera(mgr);
const CVector3f origin = GetTranslation();
@ -236,8 +236,8 @@ void CActor::PreRender(CStateManager& mgr, const CFrustumPlanes& planes) {
ActorLights()->BuildConstantAmbientLighting();
} else {
if (lightsDirty == true) {
if (x4_areaId != kInvalidAreaId) {
TAreaId aid = x4_areaId;
if (GetCurrentAreaId() != kInvalidAreaId) {
TAreaId aid = GetCurrentAreaId();
if (mgr.GetWorld()->IsAreaValid(aid)) {
const CGameArea* area = mgr.GetWorld()->GetArea(aid);
if (ActorLights()->BuildAreaLightList(mgr, *area, bounds)) {

View File

@ -44,7 +44,7 @@ rstl::optional_object< CAABox > CAmbientAI::GetTouchBounds() const {
}
void CAmbientAI::RandomizePlaybackRate(CStateManager& mgr) {
ModelData()->AnimationData()->MultiplyPlaybackRate(0.4f * mgr.GetActiveRandom()->Float() + 0.8f);
ModelData()->AnimationData()->MultiplyPlaybackRate(0.4f * mgr.Random()->Float() + 0.8f);
}
void CAmbientAI::Think(float dt, CStateManager& mgr) {

View File

@ -28,7 +28,7 @@ void CBurstFire::Start(CStateManager& mgr) {
burstIdx = xc_firstBurstIdx >= 0 ? xc_firstBurstIdx : 0;
} else {
int random = mgr.GetActiveRandom()->Range(0, 100);
int random = mgr.Random()->Range(0, 100);
int advanceAccum = 0;
do {
burstIdx += 1;
@ -59,7 +59,7 @@ void CBurstFire::Update(CStateManager& mgr, float dt) {
x14_24_shouldFire = true;
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
x8_timeToNextShot +=
(mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
(mgr.Random()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
} else {
x18_curBursts = nullptr;
}

View File

@ -114,7 +114,7 @@ CFidget::EState CFidget::Update(int fireButtonStates, bool bobbing, bool inStrik
if ((x8_delayTriggerBits & 0x3) == 0x3) {
EState newState = kS_MinorFidget;
x0_state = 50 < (mgr.GetActiveRandom()->Next() % 100) ? kS_MajorFidget : kS_MinorFidget;
x0_state = 50 < (mgr.Random()->Next() % 100) ? kS_MajorFidget : kS_MinorFidget;
} else if ((x8_delayTriggerBits & 0x1)) {
x0_state = kS_MinorFidget;
} else {
@ -131,17 +131,17 @@ CFidget::EState CFidget::Update(int fireButtonStates, bool bobbing, bool inStrik
x34_24_loading = true;
x10_delayTimerEnableBits = 2;
x8_delayTriggerBits &= ~0x1;
kMinorFidgetDelay = mgr.GetActiveRandom()->Range(20.f, 29.f);
kMinorFidgetDelay = mgr.Random()->Range(20.f, 29.f);
x4_type = SamusGun::kFT_Minor;
xc_animSet = mgr.GetActiveRandom()->Range(0, 4);
xc_animSet = mgr.Random()->Range(0, 4);
break;
case kS_MajorFidget:
x34_24_loading = true;
x10_delayTimerEnableBits = 1;
x8_delayTriggerBits &= ~0x2;
kMajorFidgetDelay = mgr.GetActiveRandom()->Range(20.f, 30.f);
kMajorFidgetDelay = mgr.Random()->Range(20.f, 30.f);
x4_type = SamusGun::kFT_Major;
xc_animSet = mgr.GetActiveRandom()->Range(0, 5);
xc_animSet = mgr.Random()->Range(0, 5);
break;
case kS_HolsterBeam:
x4_type = SamusGun::kFT_Minor;

View File

@ -957,8 +957,8 @@ void CPlayerGun::CMotionState::Update(bool firing, float dt, CTransform4f& xf, C
x18_startRotation = x1c_endRotation;
x14_rotationT = 0.f;
if (x24_fireState == kFS_StartFire) {
x1c_endRotation = mgr.GetActiveRandom()->Next() % 15;
x1c_endRotation *= (mgr.GetActiveRandom()->Next() % 100) > 45 ? 1.f : -1.f;
x1c_endRotation = mgr.Random()->Next() % 15;
x1c_endRotation *= (mgr.Random()->Next() % 100) > 45 ? 1.f : -1.f;
} else {
x1c_endRotation = 0.f;
if (x18_startRotation == x1c_endRotation) {

View File

@ -24,8 +24,8 @@ void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId oth
switch (msg) {
case kSM_InitializedInArea:
rstl::vector< SConnection >::const_iterator conn = x20_conns.begin();
for (; conn != x20_conns.end(); ++conn) {
rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin();
for (; conn != GetConnectionList().end(); ++conn) {
if (conn->x0_state != kSS_Arrived || conn->x4_msg != kSM_Next) {
continue;
}

View File

@ -19,21 +19,22 @@ void CScriptAreaAttributes::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
CStateManager& stateMgr) override {
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
if (x4_areaId == kInvalidAreaId) {
if (GetCurrentAreaId() == kInvalidAreaId) {
return;
}
switch (msg) {
case kSM_InitializedInArea: {
stateMgr.World()->Area(GetAreaIdAlways())->SetAreaAttributes(this);
stateMgr.World()->Area(GetCurrentAreaId())->SetAreaAttributes(this);
stateMgr.EnvFxManager()->SetFxDensity(500, x3c_envFxDensity);
break;
}
case kSM_Deleted: {
if (stateMgr.World()->Area(GetAreaIdAlways())->IsLoaded()) {
stateMgr.World()->Area(GetAreaIdAlways())->SetAreaAttributes(nullptr);
if (stateMgr.World()->IsAreaValid(GetCurrentAreaId())) {
stateMgr.World()->Area(GetCurrentAreaId())->SetAreaAttributes(nullptr);
}
break;
}
}
}

View File

@ -29,14 +29,13 @@ void CScriptCameraWaypoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
TUniqueId CScriptCameraWaypoint::GetRandomNextWaypointId(const CStateManager& mgr) const {
rstl::vector< TUniqueId > candidateIds;
rstl::vector< SConnection >::const_iterator conn = x20_conns.begin();
for (; conn != x20_conns.end(); ++conn) {
rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin();
for (; conn != GetConnectionList().end(); ++conn) {
if (conn->x0_state == kSS_Arrived && conn->x4_msg == kSM_Next) {
TUniqueId uid = mgr.GetIdForScript(conn->x8_objId);
if (uid == kInvalidUniqueId)
if (uid == kInvalidUniqueId) {
continue;
}
candidateIds.reserve(candidateIds.size() + 1);
candidateIds.push_back(uid);
}
@ -45,7 +44,7 @@ TUniqueId CScriptCameraWaypoint::GetRandomNextWaypointId(const CStateManager& mg
if (candidateIds.empty())
return kInvalidUniqueId;
return candidateIds[mgr.GetActiveRandom()->Range(0, s32(candidateIds.size() - 1))];
return candidateIds[mgr.Random()->Range(0, s32(candidateIds.size() - 1))];
}
void CScriptCameraWaypoint::AddToRenderer(const CFrustumPlanes&,

View File

@ -34,11 +34,11 @@ void CScriptDistanceFog::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj
CStateManager& stateMgr) {
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
if (GetAreaIdAlways() != kInvalidAreaId && GetActive()) {
if (GetCurrentAreaId() != kInvalidAreaId && GetActive()) {
switch (msg) {
case kSM_InitializedInArea:
if (x60_explicit) {
CAreaFog* fog = stateMgr.World()->Area(GetAreaIdAlways())->AreaFog();
CAreaFog* fog = stateMgr.World()->Area(GetCurrentAreaId())->AreaFog();
if (x34_mode == kRFM_None) {
fog->DisableFog();
} else {
@ -48,7 +48,7 @@ void CScriptDistanceFog::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj
break;
case kSM_Action:
if (x61_nonZero) {
CAreaFog* fog = stateMgr.World()->Area(GetAreaIdAlways())->AreaFog();
CAreaFog* fog = stateMgr.World()->Area(GetCurrentAreaId())->AreaFog();
if (x34_mode != kRFM_None) {
fog->FadeFog(x34_mode, x38_color, x3c_range, x44_colorDelta, x48_rangeDelta);
} else {
@ -57,10 +57,10 @@ void CScriptDistanceFog::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj
}
if (!close_enough(x54_thermalSpeed, 0.f)) {
stateMgr.World()->Area(GetAreaIdAlways())->SetThermalSpeedAndTarget(x54_thermalSpeed, x50_thermalTarget);
stateMgr.World()->Area(GetCurrentAreaId())->SetThermalSpeedAndTarget(x54_thermalSpeed, x50_thermalTarget);
}
if (!close_enough(x5c_xraySpeed, 0.f)) {
stateMgr.World()->Area(GetAreaIdAlways())->SetXRaySpeedAndTarget(x5c_xraySpeed, x58_xrayTarget);
stateMgr.World()->Area(GetCurrentAreaId())->SetXRaySpeedAndTarget(x5c_xraySpeed, x58_xrayTarget);
}
break;
}

View File

@ -13,8 +13,8 @@ void CScriptDockAreaChange::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
switch (msg) {
case kSM_Action:
if (GetActive()) {
rstl::vector< SConnection >::const_iterator it = x20_conns.begin();
for (; it != x20_conns.end(); ++it) {
rstl::vector< SConnection >::const_iterator it = GetConnectionList().begin();
for (; it != GetConnectionList().end(); ++it) {
if (it->x0_state != kSS_Play || it->x4_msg == kSM_UNKM0) {
continue;
}

View File

@ -338,7 +338,7 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
if (mgr.CurrentMaze() == nullptr) {
rstl::single_ptr< CMazeState > maze =
new CMazeState(skEnterCol, skEnterRow, skTargetCol, skTargetRow);
maze->Reset(sMazeSeeds[mgr.GetActiveRandom()->Next() % 300]);
maze->Reset(sMazeSeeds[mgr.Random()->Next() % 300]);
maze->Initialize();
maze->GenerateObstacles();
mgr.SetCurrentMaze(maze);

View File

@ -155,7 +155,7 @@ void CScriptPickup::Touch(CActor& act, CStateManager& mgr) {
if (mgr.GetPlayerState()->GetActiveVisor(mgr) != CPlayerState::kPV_Thermal) {
mgr.AddObject(new CExplosion(
*x27c_pickupParticleDesc, mgr.AllocateUniqueId(), true,
CEntityInfo(GetAreaIdAlways(), CEntity::NullConnectionList, kInvalidEditorId),
CEntityInfo(GetCurrentAreaId(), CEntity::NullConnectionList, kInvalidEditorId),
rstl::string_l("Explosion - Pickup Effect"), GetTransform(), 0,
CVector3f(1.f, 1.f, 1.f), CColor::White()));
}

View File

@ -25,7 +25,7 @@ void CScriptRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId,
switch (msg) {
case kSM_SetToZero: {
if (!x30_24_active) {
if (!GetActive()) {
return;
}

View File

@ -17,8 +17,8 @@ void CScriptRipple::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
return;
}
rstl::vector< SConnection >::const_iterator conn = x20_conns.begin();
for (; conn != x20_conns.end(); ++conn) {
rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin();
for (; conn != GetConnectionList().end(); ++conn) {
if (conn->x0_state != kSS_Active || conn->x4_msg != kSM_Next) {
continue;
}

View File

@ -41,7 +41,7 @@ void CScriptSpawnPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objI
case kSM_SetToZero:
if (GetActive()) {
CPlayer* player = stateMgr.Player();
TAreaId thisAreaId = x4_areaId;
TAreaId thisAreaId = GetCurrentAreaId();
TAreaId nextAreaId = stateMgr.GetNextAreaId();
if (thisAreaId != nextAreaId) {

View File

@ -566,7 +566,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
}
case kSF_PlayerInAreaRelay: {
if ((msg == kSM_Action || msg == kSM_SetToZero) &&
GetAreaIdAlways() == mgr.GetPlayer()->GetAreaIdAlways()) {
GetCurrentAreaId() == mgr.GetPlayer()->GetCurrentAreaId()) {
SendScriptMsgs(kSS_Zero, mgr, kSM_None);
}
break;
@ -627,7 +627,7 @@ void CScriptSpecialFunction::RingScramble(CStateManager& mgr) {
float dir = x1b8_ringReverse ? 1.f : -1.f;
for (int i = 0; i < x198_ringControllers.size(); ++i) {
x198_ringControllers[i].x4_rotateSpeed =
dir * mgr.GetActiveRandom()->Range(x100_float2, x104_float3);
dir * mgr.Random()->Range(x100_float2, x104_float3);
dir = -dir;
x198_ringControllers[i].x8_reachedTarget = false;
}
@ -994,7 +994,7 @@ void CScriptSpecialFunction::ThinkChaffTarget(float dt, CStateManager& mgr) {
if (CEnergyProjectile* proj = TCastToPtr< CEnergyProjectile >(mgr.ObjectById(nearList[i]))) {
if (proj->GetHomingTargetId() == GetUniqueId()) {
proj->Set3d0_26(true);
if (mgr.GetPlayer()->GetAreaIdAlways() == GetAreaIdAlways()) {
if (mgr.GetPlayer()->GetCurrentAreaId() == GetCurrentAreaId()) {
mgr.Player()->SetHudDisable(x100_float2);
x194_ = xfc_float1;
@ -1009,7 +1009,7 @@ void CScriptSpecialFunction::ThinkChaffTarget(float dt, CStateManager& mgr) {
bool addedInterference = false;
x194_ = CMath::Max(0.f, x194_ - dt);
if (x194_ && mgr.GetPlayer()->GetAreaIdAlways() == GetAreaIdAlways()) {
if (x194_ && mgr.GetPlayer()->GetCurrentAreaId() == GetCurrentAreaId()) {
addedInterference = true;
float intfMag = x104_float3 * (0.5f + ((0.5f * x194_) / xfc_float1));
if (x194_ < 1.f) {
@ -1034,7 +1034,7 @@ void CScriptSpecialFunction::ThinkRainSimulator(float, CStateManager& mgr) {
void CScriptSpecialFunction::ThinkAreaDamage(float dt, CStateManager& mgr) {
const CPlayer* player = mgr.GetPlayer();
bool inArea = player->GetAreaIdAlways() == GetAreaIdAlways();
bool inArea = player->GetCurrentAreaId() == GetCurrentAreaId();
bool immune = mgr.GetPlayerState()->GetCurrentSuitRaw() > CPlayerState::kPS_Power;
if (x1e4_31_inAreaDamage) {
if (!inArea || immune) {
@ -1090,7 +1090,7 @@ void CScriptSpecialFunction::ThinkActorScale(float dt, CStateManager& mgr) {
}
void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) {
if (mgr.GetPlayer()->GetAreaIdAlways() == GetAreaIdAlways()) {
if (mgr.GetPlayer()->GetCurrentAreaId() == GetCurrentAreaId()) {
if (x1e5_25_playerInArea) {
return;
}

View File

@ -24,7 +24,7 @@ void CScriptTargetingPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
}
bool CScriptTargetingPoint::GetLocked() const {
return x20_conns.size() > 0;
return GetConnectionList().size() > 0;
}
void CScriptTargetingPoint::Think(float dt, CStateManager&) {

View File

@ -16,7 +16,7 @@ CScriptTimer::CScriptTimer(TUniqueId uid, const rstl::string& name, const CEntit
CScriptTimer::~CScriptTimer() {}
void CScriptTimer::Reset(CStateManager& mgr) {
const float rDt = mgr.GetActiveRandom()->Float();
const float rDt = mgr.Random()->Float();
x34_time = (x3c_maxRandDelay * rDt) + x38_startTime;
}

View File

@ -137,7 +137,7 @@ CAABox CScriptTrigger::GetTriggerBoundsWR() const {
}
rstl::optional_object< CAABox > CScriptTrigger::GetTouchBounds() const override {
if (x30_24_active) {
if (GetActive()) {
return GetTriggerBoundsWR();
}
return rstl::optional_object_null();
@ -159,7 +159,7 @@ void CScriptTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid,
x148_29_didPhazonDamage = false;
}
if (x8_uid == mgr.GetLastTriggerId()) {
if (GetUniqueId() == mgr.GetLastTriggerId()) {
mgr.SetLastTriggerId(kInvalidUniqueId);
}
}
@ -174,7 +174,7 @@ void CScriptTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid,
x148_29_didPhazonDamage = false;
}
if (x8_uid == mgr.GetLastTriggerId()) {
if (GetUniqueId() == mgr.GetLastTriggerId()) {
mgr.SetLastTriggerId(kInvalidUniqueId);
}
}

View File

@ -45,7 +45,7 @@ int CGSFreeLook::SetAnim(CAnimData& data, int gunId, int setId, int loopState, C
rstl::pair< float, int > anim = pas.FindBestAnimation(
CPASAnimParmData(pas::kAS_Step, CPASAnimParm::FromInt32(gunId),
CPASAnimParm::FromInt32(setId), CPASAnimParm::FromEnum(useLoopState)),
*mgr.GetActiveRandom(), -1);
*mgr.Random(), -1);
CPASAnimParm animParm = pas.GetAnimState(pas::kAS_Step)->GetAnimParmData(anim.second, 1);
xc_gunId = gunId;

View File

@ -26,13 +26,13 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr
switch (state) {
case SamusGun::kAS_Wander: {
CPASAnimParmData parms((pas::EAnimationState(state)));
rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.Random(), -1);
animId = anim.second;
break;
}
case SamusGun::kAS_Idle: {
CPASAnimParmData parms(pas::EAnimationState(state), CPASAnimParm::FromEnum(0));
rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.Random(), -1);
animId = anim.second;
break;
}
@ -40,7 +40,7 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr
CPASAnimParmData parms(pas::EAnimationState(state), CPASAnimParm::FromInt32(0),
CPASAnimParm::FromReal32(angle), CPASAnimParm::FromBool(bigStrike),
CPASAnimParm::FromBool(false));
rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.Random(), -1);
animId = anim.second;
loop = false;
break;