2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 13:47:43 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

View File

@@ -6,86 +6,75 @@
#include "CSimplePool.hpp"
#include "CScriptWater.hpp"
namespace urde
{
namespace urde {
static CMaterialList MakeAiMaterialList(const CMaterialList& in)
{
CMaterialList ret = in;
ret.Add(EMaterialTypes::AIBlock);
ret.Add(EMaterialTypes::CameraPassthrough);
return ret;
static CMaterialList MakeAiMaterialList(const CMaterialList& in) {
CMaterialList ret = in;
ret.Add(EMaterialTypes::AIBlock);
ret.Add(EMaterialTypes::CameraPassthrough);
return ret;
}
CAi::CAi(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const zeus::CAABox& box, float mass, const CHealthInfo& hInfo,
const CDamageVulnerability& dmgVuln, const CMaterialList& list, CAssetId fsm, const CActorParameters& actorParams,
float stepUp, float stepDown)
const CDamageVulnerability& dmgVuln, const CMaterialList& list, CAssetId fsm,
const CActorParameters& actorParams, float stepUp, float stepDown)
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakeAiMaterialList(list), box, SMoverData(mass),
actorParams, stepUp, stepDown)
, x258_healthInfo(hInfo)
, x260_damageVulnerability(dmgVuln)
, x2c8_stateMachine(g_SimplePool->GetObj({FOURCC('AFSM'), fsm}))
{
_CreateShadow();
, x2c8_stateMachine(g_SimplePool->GetObj({FOURCC('AFSM'), fsm})) {
_CreateShadow();
if (x94_simpleShadow)
{
CreateShadow(true);
x94_simpleShadow->SetAlwaysCalculateRadius(false);
}
if (x94_simpleShadow) {
CreateShadow(true);
x94_simpleShadow->SetAlwaysCalculateRadius(false);
}
if (x90_actorLights)
x90_actorLights->SetCastShadows(true);
if (x90_actorLights)
x90_actorLights->SetCastShadows(true);
}
void CAi::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::InitializedInArea)
{
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
CMaterialList include = GetMaterialFilter().GetIncludeList();
include.Add(EMaterialTypes::AIBlock);
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
}
void CAi::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
if (msg == EScriptObjectMessage::InitializedInArea) {
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
CMaterialList include = GetMaterialFilter().GetIncludeList();
include.Add(EMaterialTypes::AIBlock);
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
}
CActor::AcceptScriptMsg(msg, uid, mgr);
CActor::AcceptScriptMsg(msg, uid, mgr);
}
EWeaponCollisionResponseTypes CAi::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
const urde::CWeaponMode&, urde::EProjectileAttrib) const
{
return EWeaponCollisionResponseTypes::EnemyNormal;
const urde::CWeaponMode&, urde::EProjectileAttrib) const {
return EWeaponCollisionResponseTypes::EnemyNormal;
}
void CAi::FluidFXThink(EFluidState state, CScriptWater& water, urde::CStateManager& mgr)
{
if (state == EFluidState::EnteredFluid || state == EFluidState::LeftFluid)
{
float dt = mgr.GetFluidPlaneManager()->GetLastSplashDeltaTime(GetUniqueId());
if (dt >= 0.02f)
{
float vel = (0.5f * GetMass()) * GetVelocity().magSquared();
void CAi::FluidFXThink(EFluidState state, CScriptWater& water, urde::CStateManager& mgr) {
if (state == EFluidState::EnteredFluid || state == EFluidState::LeftFluid) {
float dt = mgr.GetFluidPlaneManager()->GetLastSplashDeltaTime(GetUniqueId());
if (dt >= 0.02f) {
float vel = (0.5f * GetMass()) * GetVelocity().magSquared();
if (vel > 500.f)
{
zeus::CVector3f pos = x34_transform.origin;
pos.z() = float(water.GetTriggerBoundsWR().max.z());
mgr.GetFluidPlaneManager()->CreateSplash(GetUniqueId(), mgr, water, pos,
0.1f + ((0.4f * zeus::min(vel, 30000.f) - 500.f) / 29500.f),
true);
}
}
if (vel > 500.f) {
zeus::CVector3f pos = x34_transform.origin;
pos.z() = float(water.GetTriggerBoundsWR().max.z());
mgr.GetFluidPlaneManager()->CreateSplash(GetUniqueId(), mgr, water, pos,
0.1f + ((0.4f * zeus::min(vel, 30000.f) - 500.f) / 29500.f), true);
}
}
}
if (mgr.GetFluidPlaneManager()->GetLastRippleDeltaTime(GetUniqueId()) < (GetHealthInfo(mgr)->GetHP() > 0.f ? 0.2f : 0.7f))
return;
if (mgr.GetFluidPlaneManager()->GetLastRippleDeltaTime(GetUniqueId()) <
(GetHealthInfo(mgr)->GetHP() > 0.f ? 0.2f : 0.7f))
return;
zeus::CVector3f pos = x34_transform.origin;
zeus::CVector3f center = pos;
center.z() = float(water.GetTriggerBoundsWR().max.z());
pos.normalize();
water.GetFluidPlane().AddRipple(GetMass(), GetUniqueId(), center, GetVelocity(), water, mgr, pos);
zeus::CVector3f pos = x34_transform.origin;
zeus::CVector3f center = pos;
center.z() = float(water.GetTriggerBoundsWR().max.z());
pos.normalize();
water.GetFluidPlane().AddRipple(GetMass(), GetUniqueId(), center, GetVelocity(), water, mgr, pos);
}
CAiStateFunc CAi::GetStateFunc(const char* func) { return m_FuncMap->GetStateFunc(func); }
@@ -95,4 +84,4 @@ CAiTriggerFunc CAi::GetTrigerFunc(const char* func) { return m_FuncMap->GetTrigg
const CStateMachine* CAi::GetStateMachine() const { return x2c8_stateMachine.GetObj(); }
void CAi::CreateFuncLookup(CAiFuncMap* funcMap) { m_FuncMap = funcMap; }
CAiFuncMap* CAi::m_FuncMap = nullptr;
}
} // namespace urde