2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/MP1/World/CPuddleToadGamma.hpp"
|
|
|
|
|
2022-02-26 22:52:05 +00:00
|
|
|
#include "Runtime/Factory/CSimplePool.hpp"
|
2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/Collision/CGameCollision.hpp"
|
|
|
|
#include "Runtime/Weapon/CBomb.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2018-02-11 05:27:00 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2020-02-07 20:51:16 +00:00
|
|
|
namespace {
|
|
|
|
constexpr zeus::CVector3f skBellyOffset(0.f, 0.1f, -.3f);
|
2018-02-11 05:27:00 +00:00
|
|
|
|
2020-02-07 20:51:16 +00:00
|
|
|
constexpr std::string_view skMouthLocatorName = "MOUTH_LCTR_SDK"sv;
|
|
|
|
constexpr std::string_view skBellyLocatorName = "SAMUS_POS_LCTR_SDK"sv;
|
|
|
|
|
|
|
|
constexpr CMaterialFilter skSolidFilter =
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Character, EMaterialTypes::Player,
|
|
|
|
EMaterialTypes::ProjectilePassthrough});
|
|
|
|
} // Anonymous namespace
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-02-11 05:27:00 +00:00
|
|
|
CPuddleToadGamma::CPuddleToadGamma(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
|
|
|
|
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
|
2019-06-21 06:02:56 +00:00
|
|
|
const CActorParameters& aParms, float suckForceMultiplier, float suckAngle,
|
|
|
|
float playerSuckRange, const zeus::CVector3f& localShootDir, float playerShootSpeed,
|
|
|
|
float shouldAttackWaitTime, float spotPlayerWaitTime,
|
|
|
|
const CDamageInfo& playerShootDamage, const CDamageInfo& dInfo2, CAssetId dcln)
|
2018-12-08 05:30:43 +00:00
|
|
|
: CPatterned(ECharacter::PuddleToad, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer,
|
|
|
|
EColliderType::Zero, EBodyType::Restricted, aParms, EKnockBackVariant::Large)
|
2019-06-21 06:02:56 +00:00
|
|
|
, x570_playerShootDamage(playerShootDamage)
|
2018-12-08 05:30:43 +00:00
|
|
|
, x58c_(dInfo2)
|
2019-06-21 06:02:56 +00:00
|
|
|
, x5a8_suckForceMultiplier(suckForceMultiplier)
|
|
|
|
, x5ac_minSuckAngleProj(std::cos(zeus::degToRad(suckAngle * 0.5f)))
|
|
|
|
, x5b0_playerSuckRange(playerSuckRange)
|
|
|
|
, x5b4_localShootDir(localShootDir)
|
|
|
|
, x5c0_playerShootSpeed(playerShootSpeed)
|
|
|
|
, x5c4_shouldAttackWaitTime(shouldAttackWaitTime)
|
2020-04-21 07:22:41 +00:00
|
|
|
, x5c8_spotPlayerWaitTime(spotPlayerWaitTime) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x401_26_disableMove = true;
|
|
|
|
x460_knockBackController.SetEnableBurn(false);
|
|
|
|
x460_knockBackController.SetEnableLaggedBurnDeath(false);
|
|
|
|
x460_knockBackController.SetEnableShock(false);
|
|
|
|
x460_knockBackController.SetX81_31(false);
|
|
|
|
SetMovable(false);
|
|
|
|
if (dcln.IsValid() && g_ResFactory->GetResourceTypeById(dcln) != 0) {
|
|
|
|
TLockedToken<CCollidableOBBTreeGroupContainer> container = g_SimplePool->GetObj({FOURCC('DCLN'), dcln});
|
2019-09-12 03:50:38 +00:00
|
|
|
x5e4_collisionTreePrim = std::make_unique<CCollidableOBBTreeGroup>(container.GetObj(), GetMaterialList());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::SetSolid(CStateManager& mgr, bool solid) {
|
|
|
|
if (solid) {
|
|
|
|
AddMaterial(EMaterialTypes::Solid, mgr);
|
|
|
|
RemoveMaterial(EMaterialTypes::NonSolidDamageable, mgr);
|
|
|
|
} else {
|
|
|
|
RemoveMaterial(EMaterialTypes::Solid, mgr);
|
|
|
|
AddMaterial(EMaterialTypes::NonSolidDamageable, mgr);
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
const CCollisionPrimitive* CPuddleToadGamma::GetCollisionPrimitive() const {
|
|
|
|
if (!x5e4_collisionTreePrim)
|
|
|
|
return CPhysicsActor::GetCollisionPrimitive();
|
|
|
|
return x5e4_collisionTreePrim.get();
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CTransform CPuddleToadGamma::GetPrimitiveTransform() const {
|
|
|
|
zeus::CTransform xf = GetTransform();
|
|
|
|
xf.origin += GetPrimitiveOffset();
|
|
|
|
return xf;
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
|
|
|
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
|
|
|
|
if (msg == EScriptObjectMessage::Registered) {
|
|
|
|
x450_bodyController->Activate(mgr);
|
2020-02-07 20:51:16 +00:00
|
|
|
const zeus::CTransform bellyXf = GetLctrTransform(skBellyLocatorName);
|
|
|
|
const zeus::CVector3f bellyOffset = GetTransform().rotate(skBellyOffset);
|
2019-06-21 06:02:56 +00:00
|
|
|
x5d8_damageablePoint = x5cc_suckPoint = bellyXf.origin + bellyOffset;
|
2018-12-08 05:30:43 +00:00
|
|
|
RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);
|
|
|
|
AddMaterial(EMaterialTypes::Immovable, mgr);
|
|
|
|
AddMaterial(EMaterialTypes::SolidCharacter);
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::Think(float dt, CStateManager& mgr) {
|
|
|
|
CPatterned::Think(dt, mgr);
|
2019-06-21 06:02:56 +00:00
|
|
|
if (x5e8_25_waitTimerActive)
|
|
|
|
x56c_waitTimer += dt;
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<zeus::CAABox> CPuddleToadGamma::GetTouchBounds() const {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!GetActive())
|
|
|
|
return {};
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return (x5e4_collisionTreePrim ? x5e4_collisionTreePrim->CalculateAABox(GetTransform()) : GetBoundingBox());
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::CenterPlayer(CStateManager& mgr, const zeus::CVector3f& pos, float dt) {
|
2019-06-21 06:02:56 +00:00
|
|
|
zeus::CVector3f dir = (pos - mgr.GetPlayer().GetTranslation()).normalized();
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().SetVelocityWR((1.f / (2.f * dt)) * dir);
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const CDamageVulnerability* CPuddleToadGamma::GetDamageVulnerability(const zeus::CVector3f& pos,
|
|
|
|
const zeus::CVector3f& dir,
|
2018-12-08 05:30:43 +00:00
|
|
|
const CDamageInfo& dInfo) const {
|
2019-06-21 06:02:56 +00:00
|
|
|
if (x5e8_24_playerInside && (x5d8_damageablePoint - pos).magSquared() < 4.f)
|
2018-12-08 05:30:43 +00:00
|
|
|
return CAi::GetDamageVulnerability();
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return &CDamageVulnerability::ImmuneVulnerabilty();
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
|
|
|
|
if (type == EUserEventType::Projectile) {
|
2019-06-21 06:02:56 +00:00
|
|
|
ShootPlayer(mgr, x5c0_playerShootSpeed);
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CPatterned::DoUserAnimEvent(mgr, node, type, dt);
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-21 06:02:56 +00:00
|
|
|
bool CPuddleToadGamma::SpotPlayer(CStateManager&, float arg) { return x56c_waitTimer >= x5c8_spotPlayerWaitTime; }
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2019-06-21 06:02:56 +00:00
|
|
|
bool CPuddleToadGamma::ShouldAttack(CStateManager&, float) { return x56c_waitTimer >= x5c4_shouldAttackWaitTime; }
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CPuddleToadGamma::LostInterest(CStateManager& mgr, float) {
|
|
|
|
zeus::CAABox box = *GetTouchBounds();
|
|
|
|
zeus::CAABox plBox = mgr.GetPlayer().GetBoundingBox();
|
|
|
|
return !box.intersects(plBox);
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-21 06:02:56 +00:00
|
|
|
void CPuddleToadGamma::ShootPlayer(CStateManager& mgr, float speed) {
|
|
|
|
zeus::CVector3f shootDir = x34_transform.rotate(x5b4_localShootDir.normalized());
|
|
|
|
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
|
|
|
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed) {
|
|
|
|
x5e8_26_shotPlayer = true;
|
|
|
|
mgr.GetPlayer().Stop();
|
|
|
|
mgr.GetPlayer().SetVelocityWR(zeus::skZero3f);
|
|
|
|
mgr.GetPlayer().ApplyImpulseWR(mgr.GetPlayer().GetMass() * shootDir * speed, {});
|
|
|
|
mgr.GetPlayer().SetMoveState(CPlayer::EPlayerMovementState::ApplyJump, mgr);
|
|
|
|
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), x570_playerShootDamage,
|
2021-06-07 19:29:18 +00:00
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), zeus::skZero3f);
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.GetPlayer().GetMorphBall()->SetAsProjectile();
|
2021-06-07 00:07:45 +00:00
|
|
|
EntityList nearList;
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.BuildNearList(nearList, GetBoundingBox(), CMaterialFilter::MakeInclude({EMaterialTypes::Bomb}), this);
|
|
|
|
for (TUniqueId id : nearList) {
|
|
|
|
if (TCastToPtr<CBomb> bomb = mgr.ObjectById(id)) {
|
|
|
|
bomb->SetVelocityWR((mgr.GetActiveRandom()->Float() * 5.f + 20.f) * shootDir);
|
2019-07-16 15:54:07 +00:00
|
|
|
bomb->SetConstantAccelerationWR({0.f, 0.f, -CPhysicsActor::GravityConstant()});
|
2019-06-21 06:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CPuddleToadGamma::InAttackPosition(CStateManager& mgr, float) {
|
|
|
|
return mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed &&
|
|
|
|
PlayerInVortexArea(mgr);
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2019-08-14 10:04:11 +00:00
|
|
|
bool CPuddleToadGamma::PlayerInVortexArea(const CStateManager& mgr) const {
|
|
|
|
const CPlayer& player = mgr.GetPlayer();
|
2020-02-07 20:51:16 +00:00
|
|
|
const zeus::CTransform xf = GetLctrTransform(skMouthLocatorName);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2019-08-14 10:04:11 +00:00
|
|
|
const zeus::CVector3f playerOffset =
|
2018-12-08 05:30:43 +00:00
|
|
|
player.GetTranslation() + zeus::CVector3f{0.f, 0.f, player.GetMorphBall()->GetBallRadius()};
|
2019-08-14 10:04:11 +00:00
|
|
|
const zeus::CVector3f rotatedDir = GetTransform().rotate(zeus::skForward);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2019-08-14 10:04:11 +00:00
|
|
|
const zeus::CVector3f suckPointToPlayer = (playerOffset - (xf.origin - (1.f * rotatedDir)));
|
|
|
|
const float suckProj = suckPointToPlayer.normalized().dot(rotatedDir);
|
|
|
|
const float playerDist = suckPointToPlayer.magnitude();
|
|
|
|
const float suckAngleProj = (player.GetTranslation() - (xf.origin - (4.f * rotatedDir))).normalized().dot(rotatedDir);
|
2019-06-21 06:02:56 +00:00
|
|
|
if (playerDist > 2.f) {
|
2019-08-14 10:04:11 +00:00
|
|
|
const CRayCastResult result =
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.RayStaticIntersection(suckPointToPlayer, 1.f / playerDist * suckPointToPlayer,
|
2021-06-07 19:29:18 +00:00
|
|
|
playerDist - player.GetMorphBall()->GetBallRadius(), skSolidFilter);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (result.IsValid())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-06-21 06:02:56 +00:00
|
|
|
return (playerDist < x5b0_playerSuckRange && suckProj > 0.f && suckAngleProj > x5ac_minSuckAngleProj);
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::InActive(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
SetSolid(mgr, true);
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
2018-12-08 05:30:43 +00:00
|
|
|
x330_stateMachineState.SetDelay(2.f);
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::Active(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
2020-02-07 20:51:16 +00:00
|
|
|
const zeus::CTransform xf = GetLctrTransform(skBellyLocatorName);
|
2019-06-21 06:02:56 +00:00
|
|
|
x5cc_suckPoint = xf.origin + GetTransform().rotate(skBellyOffset);
|
|
|
|
x56c_waitTimer = 0.f;
|
|
|
|
x5e8_25_waitTimerActive = true;
|
2018-12-08 05:30:43 +00:00
|
|
|
SetSolid(mgr, true);
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
2019-06-21 06:02:56 +00:00
|
|
|
x5e8_25_waitTimerActive = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::Suck(CStateManager& mgr, EStateMsg msg, float arg) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
SetSolid(mgr, false);
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.GetPlayer().SetLeaveMorphBallAllowed(false);
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().GetMorphBall()->DisableHalfPipeStatus();
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
2019-06-21 06:02:56 +00:00
|
|
|
if (x568_stateProg == 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::LoopReaction) {
|
2019-06-21 06:02:56 +00:00
|
|
|
x568_stateProg = 1;
|
2018-12-01 00:44:33 +00:00
|
|
|
return;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLoopReactionCmd(pas::EReactionType::Zero));
|
2019-06-21 06:02:56 +00:00
|
|
|
} else if (x568_stateProg == 1)
|
2018-12-08 05:30:43 +00:00
|
|
|
SuckPlayer(mgr, arg);
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::ExitState));
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::SuckPlayer(CStateManager& mgr, float arg) {
|
|
|
|
CPlayer& player = mgr.GetPlayer();
|
|
|
|
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed)
|
2018-12-02 02:32:26 +00:00
|
|
|
return;
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2019-06-21 06:02:56 +00:00
|
|
|
zeus::CVector3f posDiff = player.GetTranslation() - x5cc_suckPoint;
|
|
|
|
float posMag = posDiff.magnitude();
|
|
|
|
if (posMag < 3.f) {
|
2018-12-01 00:44:33 +00:00
|
|
|
player.Stop();
|
2019-06-21 06:02:56 +00:00
|
|
|
CenterPlayer(mgr, x5cc_suckPoint, arg);
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2019-06-21 06:02:56 +00:00
|
|
|
float forceMag = x5a8_suckForceMultiplier * (x5b0_playerSuckRange / (posMag * posMag));
|
|
|
|
zeus::CVector3f force = forceMag * (player.GetMass() * -posDiff);
|
2019-02-24 07:15:54 +00:00
|
|
|
player.ApplyForceWR(force, zeus::CAxisAngle());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::Attack(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
mgr.GetPlayer().Stop();
|
|
|
|
mgr.GetPlayer().SetVelocityWR({});
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(pas::ESeverity::One));
|
2019-06-21 06:02:56 +00:00
|
|
|
x5e8_26_shotPlayer = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().GetMorphBall()->SetBombJumpState(CMorphBall::EBombJumpState::BombJumpDisabled);
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
2019-06-21 06:02:56 +00:00
|
|
|
if (!x5e8_26_shotPlayer) {
|
2020-02-07 20:51:16 +00:00
|
|
|
const zeus::CTransform xf = GetLctrTransform(skBellyLocatorName);
|
2019-06-21 06:02:56 +00:00
|
|
|
x5cc_suckPoint = xf.origin + GetTransform().rotate(skBellyOffset);
|
|
|
|
SetPlayerPosition(mgr, x5cc_suckPoint);
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (LostInterest(mgr, 0.f))
|
|
|
|
SetSolid(mgr, true);
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
SetSolid(mgr, true);
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().GetMorphBall()->SetBombJumpState(CMorphBall::EBombJumpState::BombJumpAvailable);
|
2019-06-21 06:02:56 +00:00
|
|
|
x5e8_24_playerInside = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::SetPlayerPosition(CStateManager& mgr, const zeus::CVector3f& targetPos) {
|
|
|
|
float preThinkDt = x500_preThinkDt;
|
|
|
|
CPlayer& player = mgr.GetPlayer();
|
|
|
|
player.Stop();
|
|
|
|
player.SetVelocityWR({});
|
|
|
|
bool hadPlayerMaterial = player.GetMaterialList().HasMaterial(EMaterialTypes::Player);
|
|
|
|
|
|
|
|
if (hadPlayerMaterial)
|
|
|
|
player.RemoveMaterial(EMaterialTypes::GroundCollider, mgr);
|
|
|
|
player.RemoveMaterial(EMaterialTypes::Player, mgr);
|
|
|
|
|
|
|
|
bool hadSolidMaterial = GetMaterialList().HasMaterial(EMaterialTypes::Solid);
|
|
|
|
if (hadSolidMaterial)
|
|
|
|
RemoveMaterial(EMaterialTypes::Solid, mgr);
|
|
|
|
|
|
|
|
CPhysicsState physState = player.GetPhysicsState();
|
|
|
|
player.Stop();
|
|
|
|
player.MoveToWR(targetPos, preThinkDt);
|
|
|
|
CGameCollision::Move(mgr, player, preThinkDt, nullptr);
|
|
|
|
physState.SetTranslation(player.GetTranslation());
|
|
|
|
player.SetPhysicsState(physState);
|
|
|
|
if (hadPlayerMaterial)
|
|
|
|
player.AddMaterial(EMaterialTypes::GroundCollider, mgr);
|
|
|
|
player.AddMaterial(EMaterialTypes::Player, mgr);
|
|
|
|
if (hadSolidMaterial)
|
|
|
|
AddMaterial(EMaterialTypes::Solid, mgr);
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CPuddleToadGamma::Inside(CStateManager& mgr, float) {
|
|
|
|
if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed)
|
|
|
|
return false;
|
2018-12-01 00:44:33 +00:00
|
|
|
|
2019-06-21 06:02:56 +00:00
|
|
|
zeus::CVector3f posDiff = mgr.GetPlayer().GetTranslation() - x5cc_suckPoint;
|
2018-12-08 05:30:43 +00:00
|
|
|
return posDiff.dot(GetTransform().frontVector()) <= 0.f && posDiff.magSquared() < 2.f;
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPuddleToadGamma::Crouch(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
2019-06-21 06:02:56 +00:00
|
|
|
x568_stateProg = 0;
|
|
|
|
x56c_waitTimer = 0.f;
|
|
|
|
x5e8_25_waitTimerActive = true;
|
|
|
|
x5e8_24_playerInside = true;
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().Stop();
|
|
|
|
mgr.GetPlayer().SetVelocityWR({});
|
|
|
|
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
|
|
|
|
if (!mgr.GetPlayer().AttachActorToPlayer(GetUniqueId(), false))
|
2019-06-21 06:02:56 +00:00
|
|
|
x56c_waitTimer = 100.f;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
SetSolid(mgr, false);
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.GetPlayer().SetLeaveMorphBallAllowed(false);
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().GetMorphBall()->DisableHalfPipeStatus();
|
|
|
|
SetSolid(mgr, false);
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
2020-02-07 20:51:16 +00:00
|
|
|
const zeus::CTransform xf = GetLctrTransform(skBellyLocatorName);
|
2019-06-21 06:02:56 +00:00
|
|
|
x5cc_suckPoint = xf.origin + GetTransform().rotate(skBellyOffset);
|
|
|
|
SetPlayerPosition(mgr, x5cc_suckPoint);
|
|
|
|
if (x568_stateProg == 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Locomotion)
|
2019-06-21 06:02:56 +00:00
|
|
|
x568_stateProg = 1;
|
2018-12-08 05:30:43 +00:00
|
|
|
else
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
|
2018-12-01 00:44:33 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
if (mgr.GetPlayer().GetAttachedActor() == GetUniqueId())
|
|
|
|
mgr.GetPlayer().DetachActorFromPlayer();
|
2019-06-21 06:02:56 +00:00
|
|
|
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
|
|
|
x5e8_25_waitTimerActive = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-02-11 05:27:00 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|