mirror of https://github.com/AxioDL/metaforce.git
CFlaahgraTentacle: Make use of TCastToConstPtr where applicable
Same behavior, but makes the read-only semantics explicit.
This commit is contained in:
parent
ef70d894f5
commit
b8afcb42a3
|
@ -39,13 +39,13 @@ void CFlaahgraTentacle::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid,
|
||||||
}
|
}
|
||||||
case EScriptObjectMessage::Deleted: {
|
case EScriptObjectMessage::Deleted: {
|
||||||
x56c_collisionManager->Destroy(mgr);
|
x56c_collisionManager->Destroy(mgr);
|
||||||
if (TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
if (const TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
||||||
trigger->SetForceVector(x580_forceVector);
|
trigger->SetForceVector(x580_forceVector);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EScriptObjectMessage::Touched: {
|
case EScriptObjectMessage::Touched: {
|
||||||
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(uid)) {
|
if (const TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(uid)) {
|
||||||
if (colAct->GetLastTouchedObject() == mgr.GetPlayer().GetUniqueId() && x420_curDamageRemTime <= 0.f) {
|
if (colAct->GetLastTouchedObject() == mgr.GetPlayer().GetUniqueId() && x420_curDamageRemTime <= 0.f) {
|
||||||
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), GetContactDamage(),
|
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), GetContactDamage(),
|
||||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
||||||
|
@ -82,17 +82,20 @@ void CFlaahgraTentacle::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid,
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFlaahgraTentacle::Think(float dt, CStateManager& mgr) {
|
void CFlaahgraTentacle::Think(float dt, CStateManager& mgr) {
|
||||||
if (!GetActive())
|
if (!GetActive()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CPatterned::Think(dt, mgr);
|
CPatterned::Think(dt, mgr);
|
||||||
x56c_collisionManager->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
x56c_collisionManager->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
||||||
|
|
||||||
if (x574_ > 0.f)
|
if (x574_ > 0.f) {
|
||||||
x574_ -= dt;
|
x574_ -= dt;
|
||||||
|
}
|
||||||
|
|
||||||
if (x578_ > 0.f)
|
if (x578_ > 0.f) {
|
||||||
x578_ -= dt;
|
x578_ -= dt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFlaahgraTentacle::AddSphereCollisionList(const SSphereJointInfo* sphereJoints, size_t jointCount,
|
void CFlaahgraTentacle::AddSphereCollisionList(const SSphereJointInfo* sphereJoints, size_t jointCount,
|
||||||
|
@ -119,7 +122,7 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) {
|
||||||
|
|
||||||
for (u32 i = 0; i < x56c_collisionManager->GetNumCollisionActors(); ++i) {
|
for (u32 i = 0; i < x56c_collisionManager->GetNumCollisionActors(); ++i) {
|
||||||
const CJointCollisionDescription& desc = x56c_collisionManager->GetCollisionDescFromIndex(i);
|
const CJointCollisionDescription& desc = x56c_collisionManager->GetCollisionDescFromIndex(i);
|
||||||
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(desc.GetCollisionActorId())) {
|
if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(desc.GetCollisionActorId())) {
|
||||||
colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player},
|
colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player},
|
||||||
{EMaterialTypes::Character,
|
{EMaterialTypes::Character,
|
||||||
EMaterialTypes::CollisionActor,
|
EMaterialTypes::CollisionActor,
|
||||||
|
@ -128,8 +131,9 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) {
|
||||||
colAct->AddMaterial(EMaterialTypes::ScanPassthrough);
|
colAct->AddMaterial(EMaterialTypes::ScanPassthrough);
|
||||||
colAct->SetDamageVulnerability(*GetDamageVulnerability());
|
colAct->SetDamageVulnerability(*GetDamageVulnerability());
|
||||||
|
|
||||||
if (x57c_tentacleTipAct == kInvalidUniqueId && desc.GetName() == skpTentacleTip)
|
if (x57c_tentacleTipAct == kInvalidUniqueId && desc.GetName() == skpTentacleTip) {
|
||||||
x57c_tentacleTipAct = desc.GetCollisionActorId();
|
x57c_tentacleTipAct = desc.GetCollisionActorId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,35 +142,38 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) {
|
||||||
|
|
||||||
}
|
}
|
||||||
zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, float dt) const {
|
zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, float dt) const {
|
||||||
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct))
|
if (const TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct)) {
|
||||||
return colAct->GetTranslation();
|
return colAct->GetTranslation();
|
||||||
|
}
|
||||||
|
|
||||||
return CPatterned::GetAimPosition(mgr, dt);
|
return CPatterned::GetAimPosition(mgr, dt);
|
||||||
}
|
}
|
||||||
void CFlaahgraTentacle::ExtractTentacle(CStateManager& mgr) {
|
void CFlaahgraTentacle::ExtractTentacle(CStateManager& mgr) {
|
||||||
if (!Inside(mgr, 0.f))
|
if (!Inside(mgr, 0.f)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x58e_24_ = true;
|
x58e_24_ = true;
|
||||||
|
|
||||||
if (TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
if (const TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
||||||
trigger->SetForceVector(x580_forceVector);
|
trigger->SetForceVector(x580_forceVector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFlaahgraTentacle::RetractTentacle(CStateManager& mgr) {
|
void CFlaahgraTentacle::RetractTentacle(CStateManager& mgr) {
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
|
||||||
if (TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
if (const TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
||||||
trigger->SetForceVector({});
|
trigger->SetForceVector({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) {
|
void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) {
|
||||||
for (const SConnection& conn : GetConnectionList()) {
|
for (const SConnection& conn : GetConnectionList()) {
|
||||||
if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::ToggleActive)
|
if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::ToggleActive) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
|
const TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
|
||||||
if (TCastToConstPtr<CScriptTrigger> trigger = mgr.GetObjectById(uid)) {
|
if (const TCastToConstPtr<CScriptTrigger> trigger = mgr.GetObjectById(uid)) {
|
||||||
x58c_triggerId = uid;
|
x58c_triggerId = uid;
|
||||||
x580_forceVector = trigger->GetForceVector();
|
x580_forceVector = trigger->GetForceVector();
|
||||||
return;
|
return;
|
||||||
|
@ -175,14 +182,16 @@ void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFlaahgraTentacle::ShouldAttack(CStateManager& mgr, float) {
|
bool CFlaahgraTentacle::ShouldAttack(CStateManager& mgr, float) {
|
||||||
if (x578_ > 0.f)
|
if (x578_ > 0.f) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (x574_ > 0.f || mgr.GetPlayer().IsInWaterMovement())
|
if (x574_ > 0.f || mgr.GetPlayer().IsInWaterMovement()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct)) {
|
if (const TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct)) {
|
||||||
float mag = (colAct->GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()).magSquared();
|
const float mag = (colAct->GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()).magSquared();
|
||||||
return mag >= (x2fc_minAttackRange * x2fc_minAttackRange) && mag <= (x300_maxAttackRange * x300_maxAttackRange);
|
return mag >= (x2fc_minAttackRange * x2fc_minAttackRange) && mag <= (x300_maxAttackRange * x300_maxAttackRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,11 +203,12 @@ void CFlaahgraTentacle::Attack(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
x568_ = 0;
|
x568_ = 0;
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
if (x568_ == 0) {
|
if (x568_ == 0) {
|
||||||
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::MeleeAttack)
|
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::MeleeAttack) {
|
||||||
x568_ = 2;
|
x568_ = 2;
|
||||||
else
|
} else {
|
||||||
x450_bodyController->GetCommandMgr().DeliverCmd(
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
||||||
CBCMeleeAttackCmd((x578_ > 0.f ? pas::ESeverity::Zero : pas::ESeverity::One), {}));
|
CBCMeleeAttackCmd((x578_ > 0.f ? pas::ESeverity::Zero : pas::ESeverity::One), {}));
|
||||||
|
}
|
||||||
|
|
||||||
} else if (x568_ == 2 && x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
|
} else if (x568_ == 2 && x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
|
||||||
x568_ = 3;
|
x568_ = 3;
|
||||||
|
@ -211,15 +221,18 @@ void CFlaahgraTentacle::Attack(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
}
|
}
|
||||||
void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) {
|
void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
if (msg == EStateMsg::Update) {
|
if (msg == EStateMsg::Update) {
|
||||||
if (!x58e_24_)
|
if (!x58e_24_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (x330_stateMachineState.GetTime() <= 1.f)
|
if (x330_stateMachineState.GetTime() <= 1.f) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
if (const TCastToConstPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
||||||
if (trigger->IsPlayerTriggerProc())
|
if (trigger->IsPlayerTriggerProc()) {
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x58e_24_ = false;
|
x58e_24_ = false;
|
||||||
|
@ -229,16 +242,18 @@ void CFlaahgraTentacle::InActive(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x570_ = 0.f;
|
x570_ = 0.f;
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
if (Inside(mgr, 0.f))
|
if (Inside(mgr, 0.f)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
if (const TCastToConstPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
|
||||||
if (trigger->IsPlayerTriggerProc()) {
|
if (trigger->IsPlayerTriggerProc()) {
|
||||||
if (x570_ > 1.f) {
|
if (x570_ > 1.f) {
|
||||||
RetractTentacle(mgr);
|
RetractTentacle(mgr);
|
||||||
ExtractTentacle(mgr);
|
ExtractTentacle(mgr);
|
||||||
} else
|
} else {
|
||||||
x570_ += arg;
|
x570_ += arg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue