mirror of https://github.com/AxioDL/metaforce.git
Initial CScriptActor imps
This commit is contained in:
parent
def32a1cca
commit
331253cd1f
|
@ -53,6 +53,8 @@ enum class EMaterialTypes
|
|||
AIBlock = 48,
|
||||
Platform = 49,
|
||||
NonSolidDamageable = 50,
|
||||
Unknown54 = 54,
|
||||
Unknwon55 = 55,
|
||||
ExcludeFromLineOfSightTest = 56,
|
||||
SixtyThree = 63
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "Collision/CMaterialList.hpp"
|
||||
#include "Audio/CSfxManager.hpp"
|
||||
#include "TCastTo.hpp"
|
||||
#include "Character/IAnimReader.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
@ -299,4 +300,9 @@ void CActor::SetAddedToken(u32 tok) { xcc_addedToken = tok; }
|
|||
float CActor::GetPitch() const { return zeus::CQuaternion(x34_transform.buildMatrix3f()).pitch(); }
|
||||
|
||||
float CActor::GetYaw() const { return zeus::CQuaternion(x34_transform.buildMatrix3f()).yaw(); }
|
||||
|
||||
SAdvancementDeltas CActor::UpdateAnimation(float, CStateManager&, bool)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ protected:
|
|||
bool xe5_27_useInSortedLists : 1;
|
||||
bool xe5_28_callTouch : 1;
|
||||
bool xe6_26_inFluid : 1;
|
||||
u8 xe6_27_ : 3;
|
||||
bool xe6_30_enablePitchBend : 1;
|
||||
bool xe7_29_ : 1;
|
||||
bool xe7_30_ : 1;
|
||||
|
@ -97,7 +98,7 @@ public:
|
|||
xe7_29_ = true;
|
||||
CEntity::SetActive(active);
|
||||
}
|
||||
virtual void PreRender(const zeus::CFrustum&, const CStateManager&) {}
|
||||
virtual void PreRender(CStateManager&, const zeus::CFrustum&) {}
|
||||
virtual void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {}
|
||||
virtual void Render(const CStateManager&) const {}
|
||||
virtual bool CanRenderUnsorted(const CStateManager&) const { return false; }
|
||||
|
@ -156,6 +157,7 @@ public:
|
|||
CModelData* ModelData() { return x64_modelData.get(); }
|
||||
void EnsureRendered(const CStateManager&);
|
||||
void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CVector3f&);
|
||||
SAdvancementDeltas UpdateAnimation(float, CStateManager&, bool);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@ static inline bool is_not_immune(EVulnerability vuln)
|
|||
|
||||
void CDamageVulnerability::ConstructNew(CInputStream& in, int propCount)
|
||||
{
|
||||
propCount -= 3;
|
||||
EVulnerability* vulns = &x0_power;
|
||||
for (int i = 0; i < std::min(propCount - 3, 15); ++i)
|
||||
for (int i = 0; i < std::min(propCount, 15); ++i)
|
||||
vulns[i] = EVulnerability(in.readUint32Big());
|
||||
|
||||
if (propCount < 15)
|
||||
|
@ -29,19 +30,19 @@ void CDamageVulnerability::ConstructNew(CInputStream& in, int propCount)
|
|||
for (int i = 15; i < propCount; ++i)
|
||||
in.readUint32Big();
|
||||
|
||||
x5c_ = in.readUint32Big();
|
||||
x5c_ = EVulnerability(in.readUint32Big());
|
||||
EVulnerability* vulns2 = &x3c_chargedPower;
|
||||
in.readUint32Big();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
vulns2[i] = EVulnerability(in.readUint32Big());
|
||||
|
||||
x60_ = in.readUint32Big();
|
||||
x60_chargedPhazon = EVulnerability(in.readUint32Big());
|
||||
EVulnerability* vulns3 = &x4c_superMissile;
|
||||
in.readUint32Big();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
vulns3[i] = EVulnerability(in.readUint32Big());
|
||||
|
||||
x64_ = in.readUint32Big();
|
||||
x64_phazonCombo = EVulnerability(in.readUint32Big());
|
||||
}
|
||||
|
||||
CDamageVulnerability::CDamageVulnerability(CInputStream& in)
|
||||
|
@ -54,9 +55,9 @@ CDamageVulnerability::CDamageVulnerability(CInputStream& in)
|
|||
vulns[i] = EVulnerability(in.readUint32Big());
|
||||
|
||||
if (propCount == 15)
|
||||
x5c_ = 0;
|
||||
x5c_ = EVulnerability::DoubleDamage;
|
||||
else
|
||||
x5c_ = in.readUint32Big();
|
||||
x5c_ = EVulnerability(in.readUint32Big());
|
||||
|
||||
x3c_chargedPower = x0_power;
|
||||
x4c_superMissile = x0_power;
|
||||
|
@ -71,12 +72,12 @@ CDamageVulnerability::CDamageVulnerability(CInputStream& in)
|
|||
ConstructNew(in, propCount);
|
||||
}
|
||||
|
||||
u32 CDamageVulnerability::sub80102490(const CWeaponMode& mode) const
|
||||
EVulnerability CDamageVulnerability::GetPhazonVulnerability(const CWeaponMode& mode) const
|
||||
{
|
||||
if (mode.IsCharged())
|
||||
return x60_;
|
||||
return x60_chargedPhazon;
|
||||
if (mode.IsComboed())
|
||||
return x64_;
|
||||
return x64_phazonCombo;
|
||||
return x5c_;
|
||||
}
|
||||
|
||||
|
@ -93,7 +94,7 @@ bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, bool ignoreDirec
|
|||
normalHurts = is_not_immune(normalVuln);
|
||||
else
|
||||
{
|
||||
if (is_not_immune(normalVuln) &&
|
||||
if (!is_not_immune(normalVuln) &&
|
||||
(normalVuln != EVulnerability::DirectDouble && normalVuln != EVulnerability::DirectNormal))
|
||||
normalHurts = false;
|
||||
}
|
||||
|
@ -111,10 +112,10 @@ bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, bool ignoreDirec
|
|||
}
|
||||
else
|
||||
{
|
||||
if (is_not_immune(chargedVuln) &&
|
||||
if (!is_not_immune(chargedVuln) &&
|
||||
(chargedVuln != EVulnerability::DirectDouble && chargedVuln != EVulnerability::DirectNormal))
|
||||
chargedHurts = false;
|
||||
if (is_not_immune(comboedVuln) &&
|
||||
if (!is_not_immune(comboedVuln) &&
|
||||
(comboedVuln != EVulnerability::DirectDouble && comboedVuln != EVulnerability::DirectNormal))
|
||||
comboedHurts = false;
|
||||
}
|
||||
|
|
|
@ -47,16 +47,16 @@ class CDamageVulnerability
|
|||
EVulnerability x54_wavebuster;
|
||||
EVulnerability x58_flamethrower;
|
||||
|
||||
u32 x5c_;
|
||||
u32 x60_;
|
||||
u32 x64_;
|
||||
EVulnerability x5c_;
|
||||
EVulnerability x60_chargedPhazon;
|
||||
EVulnerability x64_phazonCombo;
|
||||
|
||||
void ConstructNew(CInputStream& in, int propCount);
|
||||
|
||||
public:
|
||||
CDamageVulnerability(CInputStream& in);
|
||||
|
||||
u32 sub80102490(const CWeaponMode& mode) const;
|
||||
EVulnerability GetPhazonVulnerability(const CWeaponMode& mode) const;
|
||||
|
||||
bool WeaponHurts(const CWeaponMode&, bool ignoreDirect) const;
|
||||
bool WeaponHits(const CWeaponMode& mode, bool checkDirect) const;
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#include "CStateManager.hpp"
|
||||
#include "CScriptTrigger.hpp"
|
||||
#include "CDamageVulnerability.hpp"
|
||||
#include "CPlayerState.hpp"
|
||||
#include "CScriptColorModulate.hpp"
|
||||
#include "Character/IAnimReader.hpp"
|
||||
#include "TCastTo.hpp"
|
||||
|
||||
namespace urde
|
||||
|
@ -17,7 +20,7 @@ CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntity
|
|||
, x260_currentHealth(hInfo)
|
||||
, x268_damageVulnerability(dVuln)
|
||||
, x2d8_(w1)
|
||||
, x2dc_(f3)
|
||||
, x2dc_xrayAlpha(f3)
|
||||
, x2e2_24_(b2)
|
||||
, x2e2_25_(false)
|
||||
, x2e2_26_(true)
|
||||
|
@ -38,17 +41,68 @@ CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntity
|
|||
|
||||
void CScriptActor::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||
|
||||
void CScriptActor::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) {}
|
||||
void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
||||
{
|
||||
if (msg == EScriptObjectMessage::Reset)
|
||||
{
|
||||
x2e2_25_ = false;
|
||||
x260_currentHealth = x258_initialHealth;
|
||||
}
|
||||
else if (msg == EScriptObjectMessage::Increment && !GetActive())
|
||||
{
|
||||
mgr.SendScriptMsg(this, x8_uid, EScriptObjectMessage::Activate);
|
||||
CScriptColorModulate::FadeInHelper(mgr, x8_uid, x2d0_);
|
||||
}
|
||||
else if (msg == EScriptObjectMessage::Decrement)
|
||||
{
|
||||
CScriptColorModulate::FadeOutHelper(mgr, x8_uid, x2d4_);
|
||||
}
|
||||
else if (msg == EScriptObjectMessage::InternalMessage13)
|
||||
{
|
||||
for (const SConnection& conn : x20_conns)
|
||||
{
|
||||
if (conn.x0_state != EScriptObjectState::InheritBounds || conn.x4_msg != EScriptObjectMessage::Activate)
|
||||
continue;
|
||||
|
||||
void CScriptActor::Think(float, CStateManager&) {}
|
||||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||
for (auto it = search.first; it != search.second; ++it)
|
||||
{
|
||||
if (TCastToConstPtr<CScriptTrigger>(mgr.GetObjectById(it->second)))
|
||||
{
|
||||
x2e0_triggerId = it->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptActor::PreRender(const zeus::CFrustum&, const CStateManager&) {}
|
||||
if (x2e2_31_)
|
||||
CActor::AddMaterial(EMaterialTypes::Unknown54, mgr);
|
||||
}
|
||||
|
||||
CActor::AcceptScriptMsg(msg, uid, mgr);
|
||||
}
|
||||
|
||||
void CScriptActor::Think(float dt, CStateManager& mgr)
|
||||
{
|
||||
if (!GetActive())
|
||||
return;
|
||||
|
||||
if (HasModelData() && x64_modelData->HasAnimData())
|
||||
{
|
||||
bool animTimeRemaining = x64_modelData->GetAnimationData()->IsAnimTimeRemaining(dt - FLT_EPSILON, "Whole Body");
|
||||
bool loop = x64_modelData->GetIsLoop();
|
||||
|
||||
CActor::UpdateAnimation(dt, mgr, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {}
|
||||
|
||||
zeus::CAABox CScriptActor::GetSortingBounds(const CStateManager& mgr) const
|
||||
{
|
||||
if (x2e0_ != kInvalidUniqueId)
|
||||
if (x2e0_triggerId != kInvalidUniqueId)
|
||||
{
|
||||
TCastToConstPtr<CScriptTrigger> trigger(mgr.GetObjectById(x2e0_));
|
||||
TCastToConstPtr<CScriptTrigger> trigger(mgr.GetObjectById(x2e0_triggerId));
|
||||
if (trigger)
|
||||
return trigger->GetTriggerBoundsWR();
|
||||
}
|
||||
|
@ -60,7 +114,12 @@ EWeaponCollisionResponseTypes
|
|||
CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CVector3f& v2, CWeaponMode& wMode, s32 w)
|
||||
{
|
||||
const CDamageVulnerability* dVuln = GetDamageVulnerability();
|
||||
EVulnerability vuln = dVuln->GetVulnerability(wMode, 0);
|
||||
if (dVuln->GetVulnerability(wMode, false) == EVulnerability::Reflect)
|
||||
{
|
||||
EVulnerability phazonVuln = dVuln->GetPhazonVulnerability(wMode);
|
||||
if (phazonVuln < EVulnerability::PassThrough && phazonVuln >= EVulnerability::Normal)
|
||||
return EWeaponCollisionResponseTypes::Unknown15;
|
||||
}
|
||||
return CActor::GetCollisionResponseType(v1, v2, wMode, w);
|
||||
}
|
||||
|
||||
|
@ -71,7 +130,5 @@ rstl::optional_object<zeus::CAABox> CScriptActor::GetTouchBounds() const
|
|||
return {};
|
||||
}
|
||||
|
||||
void CScriptActor::Touch(CActor&, CStateManager&)
|
||||
{
|
||||
}
|
||||
void CScriptActor::Touch(CActor&, CStateManager&) {}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ protected:
|
|||
float x2d0_;
|
||||
float x2d4_;
|
||||
s32 x2d8_;
|
||||
float x2dc_;
|
||||
TUniqueId x2e0_ = kInvalidUniqueId;
|
||||
float x2dc_xrayAlpha;
|
||||
TUniqueId x2e0_triggerId = kInvalidUniqueId;
|
||||
bool x2e2_24_ : 1;
|
||||
bool x2e2_25_ : 1;
|
||||
bool x2e2_26_ : 1;
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
void Accept(IVisitor& visitor);
|
||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
|
||||
void Think(float, CStateManager&);
|
||||
void PreRender(const zeus::CFrustum&, const CStateManager&);
|
||||
void PreRender(CStateManager&, const zeus::CFrustum&);
|
||||
zeus::CAABox GetSortingBounds(const CStateManager&) const;
|
||||
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
|
||||
CWeaponMode&, int);
|
||||
|
|
|
@ -49,8 +49,8 @@ public:
|
|||
void Think(float, CStateManager &);
|
||||
zeus::CColor CalculateFlags(const zeus::CColor&) const;
|
||||
void SetTargetFlags(CStateManager&, const CModelFlags&);
|
||||
void FadeOutHelper(CStateManager&, TUniqueId, float);
|
||||
void FadeInHelper(CStateManager&, TUniqueId, float);
|
||||
static void FadeOutHelper(CStateManager&, TUniqueId, float);
|
||||
static void FadeInHelper(CStateManager&, TUniqueId, float);
|
||||
void End(CStateManager&);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ void CScriptShadowProjector::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
|||
CreateProjectedShadow();
|
||||
}
|
||||
|
||||
void CScriptShadowProjector::PreRender(const zeus::CFrustum &, const CStateManager &)
|
||||
void CScriptShadowProjector::PreRender(CStateManager&, const zeus::CFrustum &)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
void Accept(IVisitor& visitor);
|
||||
void Think(float, CStateManager &);
|
||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
|
||||
void PreRender(const zeus::CFrustum &, const CStateManager &);
|
||||
void PreRender(CStateManager &, const zeus::CFrustum &);
|
||||
void AddToRenderer(const zeus::CFrustum &, const CStateManager &) const {}
|
||||
void CreateProjectedShadow();
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CS
|
|||
|
||||
}
|
||||
|
||||
void CScriptSpecialFunction::PreRender(const zeus::CFrustum &, const CStateManager &)
|
||||
void CScriptSpecialFunction::PreRender(CStateManager &, const zeus::CFrustum &)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ public:
|
|||
void Accept(IVisitor& visitor);
|
||||
void Think(float, CStateManager &);
|
||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
|
||||
void PreRender(const zeus::CFrustum &, const CStateManager &);
|
||||
void PreRender(CStateManager &, const zeus::CFrustum &);
|
||||
void AddToRenderer(const zeus::CFrustum &, const CStateManager &) const;
|
||||
void Render(const CStateManager &) const;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void CScriptWater::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CS
|
|||
CScriptTrigger::AcceptScriptMsg(msg, other, mgr);
|
||||
}
|
||||
|
||||
void CScriptWater::PreRender(const zeus::CFrustum&, const CStateManager&) {}
|
||||
void CScriptWater::PreRender(CStateManager &, const zeus::CFrustum &) {}
|
||||
|
||||
void CScriptWater::AddToRenderer(const zeus::CFrustum& /*frustum*/, const CStateManager& mgr) const
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ const TLockedToken<CParticleGen>& CScriptWater::GetSplashEffect(float dt) const
|
|||
|
||||
float CScriptWater::GetSplashEffectScale(float dt) const
|
||||
{
|
||||
if (std::fabs(dt - 1.f) < 0.0000099999997)
|
||||
if (std::fabs(dt - 1.f) < 0.00001f)
|
||||
return kSplashScales[5];
|
||||
|
||||
u32 idx = GetSplashIndex(dt);
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
void Think(float, CStateManager&);
|
||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
|
||||
void PreRender(const zeus::CFrustum&, const CStateManager&);
|
||||
void PreRender(CStateManager &, const zeus::CFrustum &);
|
||||
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
|
||||
void Render(const CStateManager&) const;
|
||||
void Touch(CActor &, CStateManager &);
|
||||
|
|
Loading…
Reference in New Issue