mirror of https://github.com/AxioDL/metaforce.git
Final CThardusRockProjectile imps, cleanup needed
This commit is contained in:
parent
2c59420177
commit
2ca0cd2bdd
|
@ -616,8 +616,8 @@ void CThardus::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (x658_ == 1) {
|
if (x658_ == 1) {
|
||||||
const zeus::CVector3f offset = thisPos + zeus::CVector3f{0.f, 0.f, 10.f};
|
const zeus::CVector3f offset = thisPos + zeus::CVector3f{0.f, 0.f, 10.f};
|
||||||
CRayCastResult result = mgr.RayStaticIntersection(
|
CRayCastResult result = mgr.RayStaticIntersection(
|
||||||
offset, zeus::CQuaternion(GetTransform().buildMatrix3f()).toTransform() * zeus::CVector3f{0.f, 1.f, 0.f}, 100.f,
|
offset, zeus::CQuaternion(GetTransform().buildMatrix3f()).toTransform() * zeus::CVector3f{0.f, 1.f, 0.f},
|
||||||
CMaterialFilter::MakeInclude({EMaterialTypes::Wall, EMaterialTypes::Floor, EMaterialTypes::Ceiling}));
|
100.f, CMaterialFilter::MakeInclude({EMaterialTypes::Wall, EMaterialTypes::Floor, EMaterialTypes::Ceiling}));
|
||||||
if (result.IsValid()) {
|
if (result.IsValid()) {
|
||||||
zeus::CVector2f vec = sub801dac30(mgr);
|
zeus::CVector2f vec = sub801dac30(mgr);
|
||||||
if (vec != zeus::skZero2f) {
|
if (vec != zeus::skZero2f) {
|
||||||
|
@ -1131,4 +1131,43 @@ zeus::CVector3f CThardus::sub801de550(const CStateManager& mgr) const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
zeus::CVector2f CThardus::sub801dac30(CStateManager& mgr) const { return {}; }
|
zeus::CVector2f CThardus::sub801dac30(CStateManager& mgr) const { return {}; }
|
||||||
|
bool CThardus::sub801db5b4(CStateManager& mgr) const {
|
||||||
|
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal) {
|
||||||
|
return !x93a_ || x7c4_ == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void CThardus::ApplyCameraShake(float magnitude, float sfxDistance, float duration, CStateManager& mgr, const zeus::CVector3f& v1,
|
||||||
|
const zeus::CVector3f& v2) {
|
||||||
|
float bounceIntensity = std::max(0.f, -((v1 - mgr.GetPlayer().GetTranslation()).magnitude() * (magnitude / sfxDistance) - magnitude));
|
||||||
|
if (mgr.GetCameraManager()->GetFirstPersonCamera()->GetUniqueId() == mgr.GetCameraManager()->GetCurrentCameraId()) {
|
||||||
|
mgr.GetCameraManager()->AddCameraShaker(
|
||||||
|
CCameraShakeData::BuildMissileCameraShake(duration, magnitude, sfxDistance, GetTranslation()), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x908_) {
|
||||||
|
BouncePlayer(bounceIntensity, mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CThardus::BouncePlayer(float intensity, CStateManager& mgr) {
|
||||||
|
if (intensity <= 0.f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::CVector3f posDiff = GetTranslation() - mgr.GetPlayer().GetTranslation();
|
||||||
|
CPlayer::ESurfaceRestraints restraints = mgr.GetPlayer().GetSurfaceRestraint();
|
||||||
|
if (restraints != CPlayer::ESurfaceRestraints::Air && !mgr.GetPlayer().IsInWaterMovement()) {
|
||||||
|
zeus::CVector3f baseImpulse = intensity * (40.f * zeus::skUp);
|
||||||
|
zeus::CVector3f additionalImpulse;
|
||||||
|
if (posDiff.magnitude() > 10.f) {
|
||||||
|
zeus::CVector3f tmpVec = posDiff.toVec2f();
|
||||||
|
if (tmpVec.canBeNormalized()) {
|
||||||
|
additionalImpulse = intensity * (12.5f * tmpVec.normalized());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mgr.GetPlayer().ApplyImpulseWR(mgr.GetPlayer().GetMass() * (baseImpulse + additionalImpulse), zeus::CAxisAngle());
|
||||||
|
mgr.GetPlayer().SetMoveState(CPlayer::EPlayerMovementState::ApplyJump, mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace urde::MP1
|
} // namespace urde::MP1
|
||||||
|
|
|
@ -173,7 +173,7 @@ class CThardus : public CPatterned {
|
||||||
|
|
||||||
zeus::CVector2f sub801dac30(CStateManager& mgr) const;
|
zeus::CVector2f sub801dac30(CStateManager& mgr) const;
|
||||||
void sub801db148(CStateManager& mgr) const {}
|
void sub801db148(CStateManager& mgr) const {}
|
||||||
|
void BouncePlayer(float f1, CStateManager& mgr);
|
||||||
public:
|
public:
|
||||||
DEFINE_PATTERNED(Thardus);
|
DEFINE_PATTERNED(Thardus);
|
||||||
CThardus(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
CThardus(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||||
|
@ -234,6 +234,10 @@ public:
|
||||||
bool ShouldCallForBackup(CStateManager& mgr, float arg) override { return x330_stateMachineState.GetTime() > .5f; }
|
bool ShouldCallForBackup(CStateManager& mgr, float arg) override { return x330_stateMachineState.GetTime() > .5f; }
|
||||||
|
|
||||||
CPathFindSearch* GetSearchPath() override { return &x7f0_pathFindSearch; }
|
CPathFindSearch* GetSearchPath() override { return &x7f0_pathFindSearch; }
|
||||||
|
|
||||||
|
u32 Get_x7c4() const { return x7c4_; }
|
||||||
|
bool sub801db5b4(CStateManager& mgr) const;
|
||||||
|
void ApplyCameraShake(float magnitude, float sfxDistance, float duration, CStateManager& mgr, const zeus::CVector3f& v1, const zeus::CVector3f& v2);
|
||||||
};
|
};
|
||||||
} // namespace MP1
|
} // namespace MP1
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
#include "Runtime/MP1/World/CThardusRockProjectile.hpp"
|
#include "Runtime/MP1/World/CThardusRockProjectile.hpp"
|
||||||
|
|
||||||
|
#include "Runtime/CStateManager.hpp"
|
||||||
#include "Runtime/Camera/CCameraManager.hpp"
|
#include "Runtime/Camera/CCameraManager.hpp"
|
||||||
#include "Runtime/Camera/CFirstPersonCamera.hpp"
|
#include "Runtime/Camera/CFirstPersonCamera.hpp"
|
||||||
#include "Runtime/CStateManager.hpp"
|
#include "Runtime/Collision/CCollisionActor.hpp"
|
||||||
#include "Runtime/Collision/CJointCollisionDescription.hpp"
|
#include "Runtime/Collision/CCollisionActorManager.hpp"
|
||||||
|
#include "Runtime/Collision/CGameCollision.hpp"
|
||||||
|
#include "Runtime/World/CActorParameters.hpp"
|
||||||
|
#include "Runtime/World/CDestroyableRock.hpp"
|
||||||
|
#include "Runtime/World/CExplosion.hpp"
|
||||||
|
#include "Runtime/World/CLightParameters.hpp"
|
||||||
#include "Runtime/World/CPlayer.hpp"
|
#include "Runtime/World/CPlayer.hpp"
|
||||||
|
|
||||||
|
#include "Runtime/CSimplePool.hpp"
|
||||||
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
|
|
||||||
#include "Runtime/MP1/World/CThardus.hpp"
|
#include "Runtime/MP1/World/CThardus.hpp"
|
||||||
|
|
||||||
#include "TCastTo.hpp" // Generated file, do not modify include path
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
||||||
|
@ -19,23 +28,159 @@ constexpr std::array<SSphereJointInfo, 1> skRockCollisions{{
|
||||||
CThardusRockProjectile::CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
CThardusRockProjectile::CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
||||||
const zeus::CTransform& xf, CModelData&& modelData,
|
const zeus::CTransform& xf, CModelData&& modelData,
|
||||||
const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
||||||
std::vector<std::unique_ptr<CModelData>>&& mDataVec,
|
std::vector<CStaticRes>&& mDataVec, CAssetId stateMachine, float f1)
|
||||||
CAssetId stateMachine, float)
|
|
||||||
: CPatterned(ECharacter::ThardusRockProjectile, uid, name, EFlavorType::Zero, info, xf, std::move(modelData),
|
: CPatterned(ECharacter::ThardusRockProjectile, uid, name, EFlavorType::Zero, info, xf, std::move(modelData),
|
||||||
patternedInfo, EMovementType::Flyer, EColliderType::One, EBodyType::Flyer, aParms,
|
patternedInfo, EMovementType::Flyer, EColliderType::One, EBodyType::Flyer, aParms,
|
||||||
EKnockBackVariant::Medium)
|
EKnockBackVariant::Medium)
|
||||||
, x57c_(std::move(mDataVec)) {}
|
, x57c_(std::move(mDataVec))
|
||||||
|
, x59c_stateMachine(stateMachine)
|
||||||
|
, x5c0_(f1) {
|
||||||
|
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
|
||||||
|
exclude.Add(EMaterialTypes::Player);
|
||||||
|
exclude.Add(EMaterialTypes::Character);
|
||||||
|
exclude.Add(EMaterialTypes::NoPlatformCollision);
|
||||||
|
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(GetMaterialFilter().GetIncludeList(), exclude));
|
||||||
|
x50c_baseDamageMag = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
void CThardusRockProjectile::Think(float dt, CStateManager& mgr) {
|
void CThardusRockProjectile::Think(float dt, CStateManager& mgr) {
|
||||||
if (!GetActive()) {
|
if (!GetActive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto* thardus = static_cast<CThardus*>(mgr.ObjectById(x5d0_thardusId))) {
|
||||||
|
if (!thardus->sub801db5b4(mgr)) {
|
||||||
|
RemoveMaterial(EMaterialTypes::Orbit, mgr);
|
||||||
|
RemoveMaterial(EMaterialTypes::Target, mgr);
|
||||||
|
ModifyActorMaterial(mgr, true, EMaterialTypes::Orbit);
|
||||||
|
ModifyActorMaterial(mgr, true, EMaterialTypes::Target);
|
||||||
|
} else {
|
||||||
|
AddMaterial(EMaterialTypes::Orbit, mgr);
|
||||||
|
AddMaterial(EMaterialTypes::Target, mgr);
|
||||||
|
ModifyActorMaterial(mgr, false, EMaterialTypes::Orbit);
|
||||||
|
ModifyActorMaterial(mgr, false, EMaterialTypes::Target);
|
||||||
|
}
|
||||||
|
}
|
||||||
CPatterned::Think(dt, mgr);
|
CPatterned::Think(dt, mgr);
|
||||||
|
x3b4_speed = x5de_ ? 0.7f : 0.65f;
|
||||||
|
xe6_27_thermalVisorFlags = 1;
|
||||||
|
x578_collisionManager->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
||||||
|
UpdateDestroyableRockPositions(mgr);
|
||||||
|
UpdateDestroyableRockCollisionActors(mgr);
|
||||||
|
if (x58c_destroyableRocks.size() <= x5a0_) {
|
||||||
|
ExplodeAndShake(mgr, GetTranslation());
|
||||||
|
DeathDelete(mgr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CThardusRockProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) {
|
void CThardusRockProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) {
|
||||||
CPatterned::AcceptScriptMsg(msg, other, mgr);
|
CPatterned::AcceptScriptMsg(msg, other, mgr);
|
||||||
|
|
||||||
|
switch (msg) {
|
||||||
|
case EScriptObjectMessage::Touched: {
|
||||||
|
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(other)) {
|
||||||
|
if (TCastToPtr<CPlayer> player = mgr.ObjectById(colAct->GetLastTouchedObject())) {
|
||||||
|
if (x420_curDamageRemTime <= 0.f) {
|
||||||
|
mgr.ApplyDamage(GetUniqueId(), player->GetUniqueId(), GetUniqueId(), GetContactDamage(),
|
||||||
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), zeus::skZero3f);
|
||||||
|
x420_curDamageRemTime = x424_damageWaitTime;
|
||||||
|
if (mgr.GetPlayer().GetFrozenState()) {
|
||||||
|
mgr.GetPlayer().UnFreeze(mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TUniqueId rockId = kInvalidUniqueId;
|
||||||
|
for (size_t j = 0; j < x578_collisionManager->GetNumCollisionActors(); ++j) {
|
||||||
|
if (x578_collisionManager->GetCollisionDescFromIndex(j).GetCollisionActorId() == other) {
|
||||||
|
rockId = x58c_destroyableRocks[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rockId != kInvalidUniqueId) {
|
||||||
|
if (auto rock = static_cast<CDestroyableRock*>(mgr.ObjectById(rockId))) {
|
||||||
|
if (rock->GetActive()) {
|
||||||
|
rock->SetActive(false);
|
||||||
|
colAct->SetActive(false);
|
||||||
|
++x5a0_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EScriptObjectMessage::Deactivate: {
|
||||||
|
SetChildrenActive(mgr, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EScriptObjectMessage::Activate: {
|
||||||
|
SetChildrenActive(mgr, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EScriptObjectMessage::Deleted: {
|
||||||
|
x578_collisionManager->Destroy(mgr);
|
||||||
|
for (TUniqueId& uid : x58c_destroyableRocks) {
|
||||||
|
mgr.FreeScriptObject(uid);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EScriptObjectMessage::Registered: {
|
||||||
|
RemoveMaterial(EMaterialTypes::Solid, mgr);
|
||||||
|
x58c_destroyableRocks.reserve(x57c_.size());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < x57c_.size(); ++i) {
|
||||||
|
TUniqueId uid = mgr.AllocateUniqueId();
|
||||||
|
CModelData mData{x57c_[i]};
|
||||||
|
CHealthInfo hInfo = *GetHealthInfo(mgr);
|
||||||
|
CActorParameters actParms(CLightParameters(false, 0.f, CLightParameters::EShadowTesselation::Invalid, 0.f, 0.f,
|
||||||
|
zeus::skWhite, true,
|
||||||
|
CLightParameters::EWorldLightingOptions::NoShadowCast,
|
||||||
|
CLightParameters::ELightRecalculationOptions::LargeFrameCount,
|
||||||
|
zeus::skZero3f, -1, -1, false, 0),
|
||||||
|
CScannableParameters(), {}, {}, {}, true, true, false, false, 0.f, 0.f, 1.f);
|
||||||
|
auto rock = new CDestroyableRock(uid, true, skRockCollisions[i].name,
|
||||||
|
CEntityInfo(GetAreaIdAlways(), CEntity::NullConnectionList), zeus::CTransform(),
|
||||||
|
std::move(mData), 0.f, hInfo, CDamageVulnerability::NormalVulnerabilty(),
|
||||||
|
GetMaterialList(), x59c_stateMachine, actParms, x57c_[i], 1);
|
||||||
|
rock->Set_x340(false);
|
||||||
|
rock->Set_x32c(x50c_baseDamageMag);
|
||||||
|
mgr.AddObject(rock);
|
||||||
|
x58c_destroyableRocks.push_back(uid);
|
||||||
|
}
|
||||||
|
AddMaterial(EMaterialTypes::ScanPassthrough);
|
||||||
|
InitializeCollisionManager(mgr);
|
||||||
|
x450_bodyController->Activate(mgr);
|
||||||
|
SetActive(false);
|
||||||
|
SetChildrenActive(mgr, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EScriptObjectMessage::Damage: {
|
||||||
|
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(other)) {
|
||||||
|
TUniqueId rockId = kInvalidUniqueId;
|
||||||
|
for (size_t j = 0; j < x578_collisionManager->GetNumCollisionActors(); ++j) {
|
||||||
|
if (other == x578_collisionManager->GetCollisionDescFromIndex(j).GetCollisionActorId()) {
|
||||||
|
rockId = x58c_destroyableRocks[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (auto rock = static_cast<CDestroyableRock*>(mgr.ObjectById(rockId))) {
|
||||||
|
rock->TakeDamage(zeus::skZero3f, 0.f);
|
||||||
|
// NOTE(phil): Accessing Thardus as const here rather than non-const like the vanilla version
|
||||||
|
// since we're not modifying him in any way
|
||||||
|
if (const auto* thardus = static_cast<const CThardus*>(mgr.GetObjectById(x5d0_thardusId))) {
|
||||||
|
if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Thermal ||
|
||||||
|
thardus->Get_x7c4() != 3) {
|
||||||
|
DoExplosion(mgr, x5c4_, GetTranslation(), GetModelData()->GetScale(), 0);
|
||||||
|
}
|
||||||
|
ProcessSoundEvent(x5d4_, 1.f, 0, 0.1f, 1000.f, 0.16f, 1.f, zeus::skZero3f, GetTranslation(),
|
||||||
|
mgr.GetNextAreaId(), mgr, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CThardusRockProjectile::Render(CStateManager& mgr) { CPatterned::Render(mgr); }
|
void CThardusRockProjectile::Render(CStateManager& mgr) { CPatterned::Render(mgr); }
|
||||||
|
@ -93,7 +238,7 @@ void CThardusRockProjectile::GetUp(CStateManager& mgr, EStateMsg msg, float dt)
|
||||||
CThardus* thardus = static_cast<CThardus*>(mgr.ObjectById(x5d0_thardusId));
|
CThardus* thardus = static_cast<CThardus*>(mgr.ObjectById(x5d0_thardusId));
|
||||||
if (thardus != nullptr && !x5dc_) {
|
if (thardus != nullptr && !x5dc_) {
|
||||||
x5dc_ = true;
|
x5dc_ = true;
|
||||||
sub80203824(mgr, x5cc_, result.GetPoint(), GetModelData()->GetScale(), 0);
|
DoExplosion(mgr, x5cc_, result.GetPoint(), GetModelData()->GetScale(), 0);
|
||||||
ProcessSoundEvent(SFXsfx07AE, 1.f, 0, 0.1f, 1.f, 0.16f, 1.f, zeus::skZero3f, GetTranslation(),
|
ProcessSoundEvent(SFXsfx07AE, 1.f, 0, 0.1f, 1.f, 0.16f, 1.f, zeus::skZero3f, GetTranslation(),
|
||||||
mgr.GetNextAreaId(), mgr, false);
|
mgr.GetNextAreaId(), mgr, false);
|
||||||
}
|
}
|
||||||
|
@ -130,15 +275,142 @@ bool CThardusRockProjectile::Delay(CStateManager& mgr, float arg) { return x5a8_
|
||||||
bool CThardusRockProjectile::AnimOver(CStateManager& mgr, float arg) { return x574_ == EAnimState::Over; }
|
bool CThardusRockProjectile::AnimOver(CStateManager& mgr, float arg) { return x574_ == EAnimState::Over; }
|
||||||
|
|
||||||
bool CThardusRockProjectile::ShouldAttack(CStateManager& mgr, float arg) {
|
bool CThardusRockProjectile::ShouldAttack(CStateManager& mgr, float arg) {
|
||||||
if (x5ac_ < x330_stateMachineState.GetTime() && x56c_ != 3) {
|
if (x5ac_ >= x330_stateMachineState.GetTime() || x56c_ == 3) {
|
||||||
x56c_ = 2;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
x56c_ = 2;
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CThardusRockProjectile::HitSomething(CStateManager& mgr, float arg) { return x572_; }
|
bool CThardusRockProjectile::HitSomething(CStateManager& mgr, float arg) { return x572_; }
|
||||||
|
|
||||||
bool CThardusRockProjectile::ShouldMove(CStateManager& mgr, float arg) { return x56c_ != 0; }
|
bool CThardusRockProjectile::ShouldMove(CStateManager& mgr, float arg) { return x56c_ != 0; }
|
||||||
|
|
||||||
|
void CThardusRockProjectile::SetChildrenActive(CStateManager& mgr, bool active) {
|
||||||
|
for (size_t i = 0; i < x58c_destroyableRocks.size(); ++i) {
|
||||||
|
const TUniqueId uid = x58c_destroyableRocks[i];
|
||||||
|
const auto& jInfo = x578_collisionManager->GetCollisionDescFromIndex(i);
|
||||||
|
if (auto rock = static_cast<CDestroyableRock*>(mgr.ObjectById(uid))) {
|
||||||
|
if (auto colAct = static_cast<CCollisionActor*>(mgr.ObjectById(jInfo.GetCollisionActorId()))) {
|
||||||
|
rock->SetActive(active);
|
||||||
|
colAct->SetActive(active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CThardusRockProjectile::InitializeCollisionManager(CStateManager& mgr) {
|
||||||
|
std::vector<CJointCollisionDescription> joints;
|
||||||
|
AddSphereCollisionList(skRockCollisions.data(), 1, joints);
|
||||||
|
x578_collisionManager = std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(), joints, true);
|
||||||
|
SetMaterialProperties(x578_collisionManager, mgr);
|
||||||
|
|
||||||
|
for (size_t j = 0; j < x578_collisionManager->GetNumCollisionActors(); ++j) {
|
||||||
|
const CJointCollisionDescription& colDesc = x578_collisionManager->GetCollisionDescFromIndex(j);
|
||||||
|
auto rock = static_cast<const CDestroyableRock*>(mgr.GetObjectById(x58c_destroyableRocks[j]));
|
||||||
|
if (rock != nullptr) {
|
||||||
|
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(colDesc.GetCollisionActorId())) {
|
||||||
|
colAct->SetDamageVulnerability(*rock->GetDamageVulnerability());
|
||||||
|
*colAct->HealthInfo(mgr) = *rock->GetHealthInfo(mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CThardusRockProjectile::AddSphereCollisionList(const SSphereJointInfo* info, size_t count,
|
||||||
|
std::vector<CJointCollisionDescription>& vecOut) {
|
||||||
|
const auto* animData = GetModelData()->GetAnimationData();
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
CSegId seg = animData->GetLocatorSegId(info[i].name);
|
||||||
|
if (seg.IsInvalid()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
vecOut.push_back(CJointCollisionDescription::SphereCollision(seg, info[i].radius, info[i].name, 0.001f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CThardusRockProjectile::SetMaterialProperties(const std::unique_ptr<CCollisionActorManager>& colMgr,
|
||||||
|
CStateManager& mgr) {
|
||||||
|
for (size_t j = 0; j < colMgr->GetNumCollisionActors(); ++j) {
|
||||||
|
const CJointCollisionDescription& desc = colMgr->GetCollisionDescFromIndex(j);
|
||||||
|
if (auto colAct = static_cast<CCollisionActor*>(mgr.ObjectById(desc.GetCollisionActorId()))) {
|
||||||
|
CMaterialList include = GetMaterialFilter().GetIncludeList();
|
||||||
|
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
|
||||||
|
include.Add(colAct->GetMaterialFilter().GetIncludeList());
|
||||||
|
exclude.Add(colAct->GetMaterialFilter().GetExcludeList());
|
||||||
|
colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CThardusRockProjectile::DoExplosion(CStateManager& mgr, CAssetId particleId, const zeus::CVector3f& pos,
|
||||||
|
const zeus::CVector3f& scale, u32 w2) {
|
||||||
|
TUniqueId uid = mgr.AllocateUniqueId();
|
||||||
|
std::string name = fmt::format(FMT_STRING("ROCK_PROJECTILE_EFFECT-{}-{}"), particleId.Value(), uid.Value());
|
||||||
|
TLockedToken<CGenDescription> descTok = g_SimplePool->GetObj({SBIG('PART'), particleId});
|
||||||
|
mgr.AddObject(new CExplosion(descTok, uid, true, CEntityInfo(mgr.GetNextAreaId(), NullConnectionList), name,
|
||||||
|
zeus::CTransform(zeus::CMatrix3f(), pos), w2, scale, zeus::skWhite));
|
||||||
|
}
|
||||||
|
void CThardusRockProjectile::ExplodeAndShake(CStateManager& mgr, const zeus::CVector3f& pos) {
|
||||||
|
if (x5d0_thardusId == kInvalidUniqueId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto thardus = static_cast<CThardus*>(mgr.ObjectById(x5d0_thardusId))) {
|
||||||
|
DoExplosion(mgr, x5c8_, pos, GetModelData()->GetScale(), 0);
|
||||||
|
thardus->ApplyCameraShake(0.75f, 125.f, 1.f, mgr, pos, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CThardusRockProjectile::ModifyActorMaterial(CStateManager& mgr, bool remove, EMaterialTypes mat) {
|
||||||
|
for (size_t i = 0; i < x58c_destroyableRocks.size(); ++i) {
|
||||||
|
TUniqueId rockId = x58c_destroyableRocks[i];
|
||||||
|
const auto& jInfo = x578_collisionManager->GetCollisionDescFromIndex(i);
|
||||||
|
if (TCastToPtr<CActor> colAct = mgr.ObjectById(jInfo.GetCollisionActorId())) {
|
||||||
|
if (TCastToPtr<CActor> rock = mgr.ObjectById(rockId)) {
|
||||||
|
if (remove) {
|
||||||
|
colAct->RemoveMaterial(mat, mgr);
|
||||||
|
rock->RemoveMaterial(mat, mgr);
|
||||||
|
} else {
|
||||||
|
colAct->AddMaterial(mat, mgr);
|
||||||
|
rock->AddMaterial(mat, mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CThardusRockProjectile::UpdateDestroyableRockPositions(CStateManager& mgr) {
|
||||||
|
const zeus::CVector3f scale = GetModelData()->GetScale();
|
||||||
|
for (size_t i = 0; i < x58c_destroyableRocks.size(); ++i) {
|
||||||
|
zeus::CTransform locatorXf =
|
||||||
|
GetModelData()->GetAnimationData()->GetLocatorTransform(skRockCollisions[i].name, nullptr);
|
||||||
|
if (TCastToPtr<CActor> rock = mgr.ObjectById(x58c_destroyableRocks[i])) {
|
||||||
|
locatorXf = GetTransform() * (zeus::CTransform::Scale(scale) * locatorXf);
|
||||||
|
rock->SetTransform(locatorXf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CThardusRockProjectile::UpdateDestroyableRockCollisionActors(CStateManager& mgr) {
|
||||||
|
for (size_t j = 0; j < x578_collisionManager->GetNumCollisionActors(); ++j) {
|
||||||
|
const auto jInfo = x578_collisionManager->GetCollisionDescFromIndex(j);
|
||||||
|
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(jInfo.GetCollisionActorId())) {
|
||||||
|
if (!colAct->GetActive()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (auto rock = static_cast<CDestroyableRock*>(mgr.ObjectById(x58c_destroyableRocks[j]))) {
|
||||||
|
colAct->SetDamageVulnerability(*rock->GetDamageVulnerability());
|
||||||
|
const CHealthInfo* hInfo = colAct->GetHealthInfo(mgr);
|
||||||
|
*rock->HealthInfo(mgr) = *hInfo;
|
||||||
|
CMaterialFilter filter = (x5bc_ && x56c_ != 3) ? CMaterialFilter::MakeInclude({EMaterialTypes::Wall})
|
||||||
|
: CMaterialFilter::MakeInclude({EMaterialTypes::Solid});
|
||||||
|
bool collided = CGameCollision::DetectStaticCollisionBoolean(mgr, *colAct->GetCollisionPrimitive(),
|
||||||
|
colAct->GetTransform(), filter);
|
||||||
|
if (hInfo->GetHP() <= 0.f || (collided && x5a4_)) {
|
||||||
|
rock->SetActive(false);
|
||||||
|
colAct->SetActive(false);
|
||||||
|
++x5a0_;
|
||||||
|
if (hInfo->GetHP() <= 0.f) {
|
||||||
|
x5dd_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace urde::MP1
|
} // namespace urde::MP1
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Runtime/World/CPatterned.hpp"
|
#include "Runtime/World/CPatterned.hpp"
|
||||||
|
#include "Runtime/Collision/CJointCollisionDescription.hpp"
|
||||||
namespace urde::MP1 {
|
namespace urde {
|
||||||
|
class CCollisionActorManager;
|
||||||
|
struct SSphereJointInfo;
|
||||||
|
namespace MP1 {
|
||||||
class CThardusRockProjectile : public CPatterned {
|
class CThardusRockProjectile : public CPatterned {
|
||||||
float x568_ = 1.f;
|
float x568_ = 1.f;
|
||||||
u32 x56c_ = 0;
|
u32 x56c_ = 0;
|
||||||
TUniqueId x570_ = kInvalidUniqueId;
|
TUniqueId x570_ = kInvalidUniqueId;
|
||||||
bool x572_ = false;
|
bool x572_ = false;
|
||||||
EAnimState x574_ = EAnimState::Invalid;
|
EAnimState x574_ = EAnimState::Invalid;
|
||||||
u32 x578_ = 0;
|
std::unique_ptr<CCollisionActorManager> x578_collisionManager;
|
||||||
std::vector<std::unique_ptr<CModelData>> x57c_;
|
std::vector<CStaticRes> x57c_; // Used to be a pointers to CModelData
|
||||||
std::vector<TUniqueId> x58c_;
|
std::vector<TUniqueId> x58c_destroyableRocks;
|
||||||
CAssetId x59c_stateMachine;
|
CAssetId x59c_stateMachine;
|
||||||
u32 x5a0_ = 0;
|
u32 x5a0_ = 0;
|
||||||
bool x5a4_ = true;
|
bool x5a4_ = true;
|
||||||
|
@ -28,12 +31,21 @@ class CThardusRockProjectile : public CPatterned {
|
||||||
u32 x5d8_ = 0;
|
u32 x5d8_ = 0;
|
||||||
bool x5dc_ = false;
|
bool x5dc_ = false;
|
||||||
bool x5dd_ = false;
|
bool x5dd_ = false;
|
||||||
void sub80203824(CStateManager& mgr, u32 w1, const zeus::CVector3f& pos, const zeus::CVector3f& scale, u32 w2) {}
|
bool x5de_;
|
||||||
|
void DoExplosion(CStateManager& mgr, CAssetId particleId, const zeus::CVector3f& pos, const zeus::CVector3f& scale, u32 w2);
|
||||||
|
void ExplodeAndShake(CStateManager& mgr, const zeus::CVector3f& pos);
|
||||||
|
void ModifyActorMaterial(CStateManager& mgr, bool remove, EMaterialTypes mat);
|
||||||
|
void SetChildrenActive(CStateManager& mgr, bool active);
|
||||||
|
void InitializeCollisionManager(CStateManager& mgr);
|
||||||
|
void AddSphereCollisionList(const SSphereJointInfo* info, size_t count, std::vector<CJointCollisionDescription>& vecOut);
|
||||||
|
void SetMaterialProperties(const std::unique_ptr<CCollisionActorManager>& colMgr, CStateManager& mgr);
|
||||||
|
void UpdateDestroyableRockPositions(CStateManager& mgr);
|
||||||
|
void UpdateDestroyableRockCollisionActors(CStateManager& mgr);
|
||||||
public:
|
public:
|
||||||
DEFINE_PATTERNED(ThardusRockProjectile);
|
DEFINE_PATTERNED(ThardusRockProjectile);
|
||||||
CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||||
CModelData&& modelData, const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
CModelData&& modelData, const CActorParameters& aParms, const CPatternedInfo& patternedInfo,
|
||||||
std::vector<std::unique_ptr<CModelData>>&& mDataVec, CAssetId stateMachine, float);
|
std::vector<CStaticRes>&& mDataVec, CAssetId stateMachine, float);
|
||||||
|
|
||||||
void Think(float dt, CStateManager& mgr) override;
|
void Think(float dt, CStateManager& mgr) override;
|
||||||
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) override;
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) override;
|
||||||
|
@ -41,7 +53,7 @@ public:
|
||||||
void sub80203d58() {
|
void sub80203d58() {
|
||||||
x328_25_verticalMovement = false;
|
x328_25_verticalMovement = false;
|
||||||
x150_momentum = {0.f, 0.f, 2.f * -GetWeight()};
|
x150_momentum = {0.f, 0.f, 2.f * -GetWeight()};
|
||||||
x56c_= 3;
|
x56c_ = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Patrol(CStateManager& mgr, EStateMsg msg, float dt) override;
|
void Patrol(CStateManager& mgr, EStateMsg msg, float dt) override;
|
||||||
|
@ -55,4 +67,5 @@ public:
|
||||||
bool HitSomething(CStateManager& mgr, float arg) override;
|
bool HitSomething(CStateManager& mgr, float arg) override;
|
||||||
bool ShouldMove(CStateManager& mgr, float arg) override;
|
bool ShouldMove(CStateManager& mgr, float arg) override;
|
||||||
};
|
};
|
||||||
} // namespace urde::MP1
|
} // namespace MP1
|
||||||
|
} // namespace urde
|
||||||
|
|
|
@ -17,6 +17,7 @@ class CDestroyableRock : public CAi {
|
||||||
bool x334_isCold = false;
|
bool x334_isCold = false;
|
||||||
bool x335_usePhazonModel = false;
|
bool x335_usePhazonModel = false;
|
||||||
CHealthInfo x338_healthInfo;
|
CHealthInfo x338_healthInfo;
|
||||||
|
bool x340_;
|
||||||
bool x341_;
|
bool x341_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -61,6 +62,8 @@ public:
|
||||||
/* This used to be in the constructor, since we can't store CModelData directly in the class we must set it here */
|
/* This used to be in the constructor, since we can't store CModelData directly in the class we must set it here */
|
||||||
GetModelData()->SetSortThermal(true);
|
GetModelData()->SetSortThermal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Set_x340(bool v) { x340_ = v; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -2878,11 +2878,11 @@ CEntity* ScriptLoader::LoadThardusRockProjectile(CStateManager& mgr, CInputStrea
|
||||||
if (!pInfo.GetAnimationParameters().GetACSFile().IsValid())
|
if (!pInfo.GetAnimationParameters().GetACSFile().IsValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<CModelData>> mDataVec;
|
std::vector<CStaticRes> mDataVec;
|
||||||
CModelData mData(CAnimRes(pInfo.GetAnimationParameters().GetACSFile(), 0, actorHead.x40_scale,
|
CModelData mData(CAnimRes(pInfo.GetAnimationParameters().GetACSFile(), 0, actorHead.x40_scale,
|
||||||
pInfo.GetAnimationParameters().GetInitialAnimation(), true));
|
pInfo.GetAnimationParameters().GetInitialAnimation(), true));
|
||||||
mDataVec.reserve(3);
|
mDataVec.reserve(3);
|
||||||
mDataVec.emplace_back(std::make_unique<CModelData>(CStaticRes(modelId, zeus::skOne3f)));
|
mDataVec.emplace_back(modelId, zeus::skOne3f);
|
||||||
return new MP1::CThardusRockProjectile(mgr.AllocateUniqueId(), actorHead.x0_name, info, actorHead.x10_transform,
|
return new MP1::CThardusRockProjectile(mgr.AllocateUniqueId(), actorHead.x0_name, info, actorHead.x10_transform,
|
||||||
std::move(mData), actParms, pInfo, std::move(mDataVec), stateMachine, f1);
|
std::move(mData), actParms, pInfo, std::move(mDataVec), stateMachine, f1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue