2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/MP1/World/CRipper.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/Collision/CCollidableOBBTreeGroup.hpp"
|
2020-08-23 18:54:21 +00:00
|
|
|
#include "Runtime/Collision/CGameCollision.hpp"
|
2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/Weapon/CPlayerGun.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
#include "Runtime/World/CScriptGrapplePoint.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2019-08-11 03:02:54 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2019-08-11 03:02:54 +00:00
|
|
|
CRipper::CRipper(TUniqueId uid, std::string_view name, EFlavorType type, const CEntityInfo& info,
|
2019-08-11 15:14:52 +00:00
|
|
|
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
|
|
|
|
const CActorParameters& actParms, const CGrappleParameters& grappleParms)
|
2019-08-11 03:02:54 +00:00
|
|
|
: CPatterned(ECharacter::Ripper, uid, name, type, info, xf, std::move(mData), pInfo, EMovementType::Flyer,
|
2019-08-11 15:14:52 +00:00
|
|
|
EColliderType::One, EBodyType::Flyer, actParms, EKnockBackVariant::Medium)
|
2020-04-21 07:22:41 +00:00
|
|
|
, x568_grappleParams(grappleParms) {
|
2019-08-11 15:14:52 +00:00
|
|
|
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(
|
|
|
|
{EMaterialTypes::Solid},
|
|
|
|
{EMaterialTypes::NoStaticCollision, EMaterialTypes::NoPlatformCollision, EMaterialTypes::Platform}));
|
|
|
|
x460_knockBackController.SetAutoResetImpulse(false);
|
2020-04-11 14:29:06 +00:00
|
|
|
x460_knockBackController.SetAnimationStateRange(EKnockBackAnimationState::Flinch,
|
|
|
|
EKnockBackAnimationState::KnockBack);
|
2019-08-11 15:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRipper::Think(float dt, CStateManager& mgr) {
|
|
|
|
if (!GetActive())
|
|
|
|
return;
|
|
|
|
|
|
|
|
ProcessGrapplePoint(mgr);
|
|
|
|
const CPlayer& pl = mgr.GetPlayer();
|
|
|
|
CGrappleArm::EArmState armState = pl.GetPlayerGun()->GetGrappleArm().GetAnimState();
|
2020-08-23 18:08:25 +00:00
|
|
|
if (x598_grapplePoint != kInvalidUniqueId && pl.GetOrbitTargetId() == x598_grapplePoint &&
|
|
|
|
pl.GetGrappleState() != CPlayer::EGrappleState::None) {
|
2020-04-11 14:29:06 +00:00
|
|
|
if (pl.GetGrappleState() != CPlayer::EGrappleState::Firing && (armState > CGrappleArm::EArmState::Three)) {
|
2019-08-11 15:14:52 +00:00
|
|
|
Stop();
|
|
|
|
if (!x59c_24_muted) {
|
|
|
|
SetMuted(true);
|
|
|
|
x59c_24_muted = true;
|
|
|
|
}
|
2020-04-11 14:29:06 +00:00
|
|
|
} else {
|
|
|
|
CPatterned::Think(dt, mgr);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CPatterned::Think(dt, mgr);
|
|
|
|
if (x59c_24_muted) {
|
|
|
|
SetMuted(false);
|
|
|
|
x59c_24_muted = false;
|
2019-08-11 15:14:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRipper::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
|
|
|
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case EScriptObjectMessage::Deleted:
|
|
|
|
case EScriptObjectMessage::Deactivate: {
|
|
|
|
RemoveGrapplePoint(mgr);
|
|
|
|
RemovePlatform(mgr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Activate: {
|
|
|
|
AddGrapplePoint(mgr);
|
|
|
|
AddPlatform(mgr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Registered: {
|
|
|
|
x450_bodyController->Activate(mgr);
|
|
|
|
AddMaterial(EMaterialTypes::Immovable, mgr);
|
|
|
|
RemoveMaterial(EMaterialTypes::Solid, mgr);
|
2020-04-11 14:29:06 +00:00
|
|
|
if (x3fc_flavor == EFlavorType::One) {
|
2019-08-11 15:14:52 +00:00
|
|
|
AddGrapplePoint(mgr);
|
|
|
|
RemoveMaterial(EMaterialTypes::Orbit, mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
AddPlatform(mgr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-08-23 18:08:25 +00:00
|
|
|
|
2019-08-11 15:14:52 +00:00
|
|
|
void CRipper::KnockBack(const zeus::CVector3f& dir, CStateManager& mgr, const CDamageInfo& dInfo, EKnockBackType kb,
|
|
|
|
bool inDeferred, float mag) {
|
|
|
|
CPatterned::KnockBack(dir, mgr, dInfo, kb, inDeferred, mag);
|
2020-08-23 18:08:25 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockBackCmd(-dir, pas::ESeverity::One));
|
2019-08-11 15:14:52 +00:00
|
|
|
}
|
2020-08-23 18:08:25 +00:00
|
|
|
|
2019-08-11 15:14:52 +00:00
|
|
|
void CRipper::Patrol(CStateManager& mgr, EStateMsg msg, float arg) {
|
|
|
|
x450_bodyController->GetCommandMgr().SetSteeringBlendMode(ESteeringBlendMode::FullSpeed);
|
|
|
|
x450_bodyController->GetCommandMgr().SetSteeringSpeedRange(1.f, 1.f);
|
|
|
|
CPatterned::Patrol(mgr, msg, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRipper::ProcessGrapplePoint(CStateManager& mgr) {
|
2020-04-11 14:29:06 +00:00
|
|
|
if (x3fc_flavor != EFlavorType::One || x598_grapplePoint == kInvalidUniqueId)
|
2019-08-11 15:14:52 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (TCastToPtr<CScriptGrapplePoint> gp = mgr.ObjectById(x598_grapplePoint)) {
|
|
|
|
gp->SetTransform(GetTransform());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRipper::AddGrapplePoint(CStateManager& mgr) {
|
|
|
|
if (x598_grapplePoint != kInvalidUniqueId)
|
|
|
|
return;
|
|
|
|
|
|
|
|
x598_grapplePoint = mgr.AllocateUniqueId();
|
2020-04-11 14:29:06 +00:00
|
|
|
mgr.AddObject(new CScriptGrapplePoint(x598_grapplePoint, "RipperGrapplePoint"sv,
|
2020-08-23 18:08:25 +00:00
|
|
|
CEntityInfo(GetAreaIdAlways(), NullConnectionList), GetTransform(), true,
|
|
|
|
x568_grappleParams));
|
2019-08-11 15:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRipper::RemoveGrapplePoint(CStateManager& mgr) {
|
|
|
|
if (x598_grapplePoint == kInvalidUniqueId)
|
|
|
|
return;
|
|
|
|
mgr.FreeScriptObject(x598_grapplePoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRipper::AddPlatform(CStateManager& mgr) {
|
|
|
|
if (x59a_platformId != kInvalidUniqueId)
|
|
|
|
return;
|
|
|
|
|
|
|
|
x59a_platformId = mgr.AllocateUniqueId();
|
|
|
|
const zeus::CAABox bounds = GetModelData()->GetBounds(GetTransform().getRotation());
|
|
|
|
|
2020-08-23 18:08:25 +00:00
|
|
|
const auto& platform = new CRipperControlledPlatform(x59a_platformId, GetUniqueId(), "Ripper Controlled Platform"sv,
|
|
|
|
CEntityInfo(GetAreaIdAlways(), NullConnectionList),
|
|
|
|
GetTransform(), bounds, GetActive(), {});
|
|
|
|
mgr.AddObject(platform);
|
|
|
|
platform->AddMaterial(EMaterialTypes::ProjectilePassthrough);
|
2019-08-11 15:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRipper::RemovePlatform(CStateManager& mgr) {
|
|
|
|
if (x59a_platformId == kInvalidUniqueId)
|
|
|
|
return;
|
|
|
|
mgr.FreeScriptObject(x59a_platformId);
|
|
|
|
x59a_platformId = kInvalidUniqueId;
|
|
|
|
}
|
2020-08-23 18:08:25 +00:00
|
|
|
|
2019-08-11 15:14:52 +00:00
|
|
|
CRipperControlledPlatform::CRipperControlledPlatform(
|
|
|
|
TUniqueId uid, TUniqueId owner, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
|
|
|
const zeus::CAABox& bounds, bool active, const std::optional<TLockedToken<CCollidableOBBTreeGroup>>& colTree)
|
|
|
|
: CScriptPlatform(uid, name, info, xf, CModelData::CModelDataNull(), CActorParameters::None(), bounds, 0.f, false, 1.f,
|
2020-08-23 18:08:25 +00:00
|
|
|
active, CHealthInfo(FLT_MAX, 10.f), CDamageVulnerability::ImmuneVulnerabilty(), colTree, false, 1, 1)
|
2019-08-11 15:14:52 +00:00
|
|
|
, x358_owner(owner)
|
|
|
|
, x35c_yaw(GetYaw()) {}
|
2020-08-23 18:54:21 +00:00
|
|
|
|
|
|
|
constexpr float RCP_2PI = 0.15915494f;
|
|
|
|
constexpr float M_2PI = 6.2831855f;
|
|
|
|
|
|
|
|
zeus::CQuaternion CRipperControlledPlatform::Move(float arg, CStateManager& mgr) {
|
|
|
|
if (const auto* actor = static_cast<CActor*>(mgr.ObjectById(x358_owner))) {
|
|
|
|
MoveToWR(GetTranslation() + (actor->GetTranslation() - GetTranslation()), arg);
|
|
|
|
float yawDiff = actor->GetYaw() - x35c_yaw;
|
|
|
|
float zRot = yawDiff - static_cast<float>(static_cast<int>(yawDiff * RCP_2PI)) * M_2PI;
|
|
|
|
if (zRot < 0.f) {
|
|
|
|
zRot += M_2PI;
|
|
|
|
}
|
|
|
|
if (zRot > M_PIF) {
|
|
|
|
zRot -= M_2PI;
|
|
|
|
}
|
|
|
|
const auto quat = zeus::CQuaternion::fromAxisAngle({0.0f, 0.0f, 1.0f}, zRot);
|
|
|
|
RotateToOR(quat, arg);
|
|
|
|
|
2021-06-07 00:07:45 +00:00
|
|
|
EntityList nearList;
|
|
|
|
EntityList filteredNearList;
|
2020-08-23 18:54:21 +00:00
|
|
|
mgr.BuildColliderList(nearList, *this, GetMotionVolume(arg));
|
2020-09-18 21:04:50 +00:00
|
|
|
for (const auto& id : nearList) {
|
2020-08-23 18:54:21 +00:00
|
|
|
if (!IsRider(id) && !IsSlave(id)) {
|
|
|
|
filteredNearList.push_back(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xf8_24_movable = true;
|
|
|
|
CGameCollision::Move(mgr, *this, arg, &filteredNearList);
|
|
|
|
xf8_24_movable = false;
|
|
|
|
x35c_yaw = GetYaw();
|
|
|
|
return quat;
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|