prime/include/MetroidPrime/CActor.hpp

256 lines
11 KiB
C++
Raw Normal View History

#ifndef _CACTOR
#define _CACTOR
2022-08-13 01:26:00 +00:00
#include "types.h"
#include "Collision/CMaterialFilter.hpp"
#include "Collision/CMaterialList.hpp"
#include "MetroidPrime/CEntity.hpp"
#include "MetroidPrime/CModelData.hpp"
2022-11-11 14:51:34 +00:00
#include "MetroidPrime/ActorCommon.hpp"
2022-08-13 01:26:00 +00:00
2022-08-15 04:51:06 +00:00
#include "Kyoto/Audio/CSfxHandle.hpp"
2022-08-13 01:26:00 +00:00
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Graphics/CModelFlags.hpp"
2022-08-13 01:26:00 +00:00
#include "Kyoto/Math/CAABox.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
#include "Kyoto/TToken.hpp"
#include "rstl/optional_object.hpp"
2022-08-13 01:26:00 +00:00
#include "rstl/pair.hpp"
#include "rstl/reserved_vector.hpp"
#include "rstl/single_ptr.hpp"
class CActorLights;
class CActorParameters;
class CScannableObjectInfo;
class CSimpleShadow;
class CDamageInfo;
class CDamageVulnerability;
2022-08-16 02:14:28 +00:00
class CFrustumPlanes;
class CHealthInfo;
class CScriptWater;
class CWeaponMode;
class CInt32POINode;
2022-08-13 01:26:00 +00:00
class CActor : public CEntity {
public:
enum EThermalFlags {
kTF_None = 0,
kTF_Cold = 1,
kTF_Hot = 2,
};
enum EFluidState {
kFS_EnteredFluid,
kFS_InFluid,
kFS_LeftFluid,
};
enum EScanState {
kSS_Start,
kSS_Processing,
kSS_Done,
};
2022-08-13 01:26:00 +00:00
2022-09-18 06:05:46 +00:00
CActor(TUniqueId uid, bool active, const rstl::string& name, const CEntityInfo& info,
const CTransform4f& xf, const CModelData& mData, const CMaterialList& list,
const CActorParameters& params, TUniqueId nextDrawNode);
2023-02-06 17:01:01 +00:00
~CActor() override;
2022-08-13 01:26:00 +00:00
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr);
void SetActive(const bool active);
2022-08-16 02:14:28 +00:00
virtual void PreRender(CStateManager&, const CFrustumPlanes&);
virtual void AddToRenderer(const CFrustumPlanes&, const CStateManager&) const;
virtual void Render(const CStateManager&) const;
virtual bool CanRenderUnsorted(const CStateManager&) const;
virtual void CalculateRenderBounds();
2022-10-28 21:06:29 +00:00
const CHealthInfo* GetHealthInfo(const CStateManager& mgr) const {
return const_cast< CActor* >(this)->HealthInfo(const_cast< CStateManager& >(mgr));
}
virtual CHealthInfo* HealthInfo(CStateManager&);
virtual const CDamageVulnerability* GetDamageVulnerability() const;
2022-09-18 06:05:46 +00:00
virtual const CDamageVulnerability* GetDamageVulnerability(const CVector3f&, const CVector3f&,
const CDamageInfo&) const;
virtual rstl::optional_object< CAABox > GetTouchBounds() const;
virtual void Touch(CActor&, CStateManager&);
virtual CVector3f GetOrbitPosition(const CStateManager&) const;
virtual CVector3f GetAimPosition(const CStateManager&, float) const;
virtual CVector3f GetHomingPosition(const CStateManager&, float) const;
virtual CVector3f GetScanObjectIndicatorPosition(const CStateManager&) const;
2022-09-18 06:05:46 +00:00
virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const CVector3f&, const CVector3f&,
const CWeaponMode&,
int /*EProjectileAttrib?*/) const;
virtual void FluidFXThink(EFluidState, CScriptWater&, CStateManager&);
virtual void OnScanStateChange(EScanState, CStateManager&);
virtual CAABox GetSortingBounds(const CStateManager&) const;
2022-09-18 06:05:46 +00:00
virtual void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type,
float dt);
2022-10-08 04:53:28 +00:00
CAdvancementDeltas UpdateAnimation(float dt, CStateManager& mgr, bool advTree);
2022-08-13 01:26:00 +00:00
void ProcessSoundEvent(int sfxId, float weight, int flags, float fallOff, float maxDist,
uchar minVol, uchar maxVol, const CVector3f& toListener,
const CVector3f& position, int aid, CStateManager& mgr, bool translateId);
2022-08-13 01:26:00 +00:00
void UpdateSfxEmitters();
void RemoveEmitter();
2022-08-15 04:51:06 +00:00
void SetModelData(const CModelData& modelData);
float GetAverageAnimVelocity(int anim);
2022-08-16 02:14:28 +00:00
void EnsureRendered(const CStateManager& mgr) const;
void EnsureRendered(const CStateManager& mgr, const CVector3f& pos, const CAABox& bounds) const;
void DrawTouchBounds() const;
bool IsModelOpaque(const CStateManager& mgr) const;
void RenderInternal(const CStateManager& mgr) const;
void CreateShadow(bool);
2022-08-13 01:26:00 +00:00
const CTransform4f& GetTransform() const { return x34_transform; }
void SetTransform(const CTransform4f& xf) {
x34_transform = xf;
SetTransformDirty(true);
SetTransformDirtySpare(true);
SetPreRenderHasMoved(true);
}
void SetRotation(const CQuaternion& rot) { SetTransform(rot.BuildTransform4f(GetTranslation())); }
CQuaternion GetRotation() const { return CQuaternion::FromMatrix(GetTransform()); }
CVector3f GetTranslation() const { return x34_transform.GetTranslation(); }
2022-09-15 04:08:47 +00:00
void SetTranslation(const CVector3f& vec);
CTransform4f GetLocatorTransform(const rstl::string& segName) const;
CTransform4f GetScaledLocatorTransform(const rstl::string& segName) const;
float GetYaw() const;
2022-08-16 02:14:28 +00:00
/// ????
bool NullModel() const { return !GetAnimationData() && !GetModelData()->HasNormalModel(); }
2022-09-18 06:05:46 +00:00
bool HasModelData() const {
return GetModelData() && (GetModelData()->HasAnimation() || GetModelData()->HasNormalModel());
}
CModelData* ModelData() { return x64_modelData.get(); }
const CModelData* GetModelData() const { return x64_modelData.get(); }
2022-08-16 02:14:28 +00:00
bool HasAnimation() const { return GetModelData() && GetModelData()->HasAnimation(); }
CAnimData* AnimationData() { return ModelData()->AnimationData(); }
2022-08-15 04:51:06 +00:00
const CAnimData* GetAnimationData() const { return GetModelData()->GetAnimationData(); }
2022-08-16 02:14:28 +00:00
bool HasShadow() const { return GetShadow() != nullptr; }
2022-08-16 02:14:28 +00:00
CSimpleShadow* Shadow() { return x94_simpleShadow.get(); }
const CSimpleShadow* GetShadow() const { return x94_simpleShadow.get(); }
bool HasActorLights() const { return !x90_actorLights.null(); }
CActorLights* ActorLights() { return x90_actorLights.get(); }
const CActorLights* GetActorLights() const { return x90_actorLights.get(); }
const CModelFlags& GetModelFlags() const { return xb4_drawFlags; }
void SetModelFlags(const CModelFlags& flags) { xb4_drawFlags = flags; }
const CMaterialList& GetMaterialList() const { return x68_material; }
CMaterialList& MaterialList() { return x68_material; }
const CMaterialFilter& GetMaterialFilter() const;
void SetMaterialFilter(const CMaterialFilter& filter);
2022-08-16 02:14:28 +00:00
bool GetTransformDirty() const { return xe4_27_notInSortedLists; }
bool GetTransformDirtySpare() const { return xe4_28_transformDirty; }
bool GetPreRenderHasMoved() const { return xe4_29_actorLightsDirty; }
bool GetPreRenderClipped() const { return xe4_30_outOfFrustum; }
bool GetCalculateLighting() const { return xe4_31_calculateLighting && HasActorLights(); }
bool GetDrawShadow() const { return xe5_24_shadowEnabled; }
bool GetShadowDirty() const { return xe5_25_shadowDirty; }
bool GetMuted() const { return xe5_26_muted; }
2022-11-04 05:25:39 +00:00
EThermalFlags GetThermalFlags() const {
return static_cast< EThermalFlags >(xe6_27_thermalVisorFlags);
}
2022-08-16 02:14:28 +00:00
bool GetRenderParticleDatabaseInside() const { return xe6_29_renderParticleDBInside; }
2022-11-04 05:25:39 +00:00
bool GetTargetable() const { return xe7_31_targetable; }
2022-08-16 02:14:28 +00:00
void SetTransformDirty(bool b) { xe4_27_notInSortedLists = b; }
void SetTransformDirtySpare(bool b) { xe4_28_transformDirty = b; }
void SetPreRenderHasMoved(bool b) { xe4_29_actorLightsDirty = b; }
void SetPreRenderClipped(bool b) { xe4_30_outOfFrustum = b; }
void SetCalculateLighting(bool b) { xe4_31_calculateLighting = b; }
void SetDrawShadow(bool b) { xe5_24_shadowEnabled = b; }
void SetShadowDirty(bool b) { xe5_25_shadowDirty = b; }
void SetMuted(bool b) { xe5_26_muted = b; }
2022-11-04 09:24:42 +00:00
void SetThermalFlags(EThermalFlags flags) { xe6_27_thermalVisorFlags = flags; }
2022-08-16 02:14:28 +00:00
void SetRenderParticleDatabaseInside(bool b) { xe6_29_renderParticleDBInside = b; }
2022-11-04 05:25:39 +00:00
void SetTargetable(bool b) { xe7_31_targetable = b; }
2022-08-16 02:14:28 +00:00
2022-10-05 23:06:15 +00:00
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes,
CStateManager&);
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
void RemoveMaterial(EMaterialTypes, EMaterialTypes, CStateManager&);
void RemoveMaterial(EMaterialTypes, CStateManager&);
2022-10-05 23:06:15 +00:00
void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes,
CStateManager&);
void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
void AddMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
void AddMaterial(EMaterialTypes, EMaterialTypes, CStateManager&);
void AddMaterial(EMaterialTypes, CStateManager&);
2022-11-04 05:25:39 +00:00
void AddMaterial(const CMaterialList& l) { x68_material.Add(l); }
2022-08-16 02:14:28 +00:00
const CAABox& GetRenderBoundsCached() const { return x9c_renderBounds; }
void SetRenderBounds(const CAABox& bounds) { x9c_renderBounds = bounds; }
// 000c0ec8 00001c 801711a8 4 GetUseInSortedLists__6CActorCFv CActor.o
2022-11-04 15:17:11 +00:00
void SetUseInSortedLists(bool use);
2022-08-16 02:14:28 +00:00
// 000c0ef8 00001c 801711d8 4 GetCallTouch__6CActorCFv CActor.o
2022-10-20 14:25:08 +00:00
void SetCallTouch(bool);
2022-08-16 02:14:28 +00:00
// GetOrbitDistanceCheck__6CActorCFv
// GetCalculateLighting__6CActorCFv
// GetDrawShadow__6CActorCFv
// GetRenderBoundsCached__6CActorCFv
// GetRenderParticleDatabaseInside__6CActorCFv
// HasModelParticles__6CActorCFv
void SetVolume(uchar volume);
2022-08-13 01:26:00 +00:00
2022-11-04 05:25:39 +00:00
private:
2022-08-13 01:26:00 +00:00
CTransform4f x34_transform;
rstl::single_ptr< CModelData > x64_modelData;
CMaterialList x68_material;
CMaterialFilter x70_materialFilter;
TSfxId x88_sfxId;
CSfxHandle x8c_loopingSfxHandle;
rstl::single_ptr< CActorLights > x90_actorLights;
rstl::single_ptr< CSimpleShadow > x94_simpleShadow;
rstl::single_ptr< TCachedToken< CScannableObjectInfo > > x98_scanObjectInfo;
CAABox x9c_renderBounds;
CModelFlags xb4_drawFlags;
float xbc_time;
uint xc0_pitchBend;
2022-08-13 01:26:00 +00:00
TUniqueId xc4_fluidId;
TUniqueId xc6_nextDrawNode;
int xc8_drawnToken;
int xcc_addedToken;
float xd0_damageMag;
uchar xd4_maxVol;
2022-08-13 01:26:00 +00:00
rstl::reserved_vector< CSfxHandle, 2 > xd8_nonLoopingSfxHandles;
uint xe4_24_nextNonLoopingSfxHandle : 3;
uint xe4_27_notInSortedLists : 1;
uint xe4_28_transformDirty : 1;
uint xe4_29_actorLightsDirty : 1;
uint xe4_30_outOfFrustum : 1;
uint xe4_31_calculateLighting : 1;
uint xe5_24_shadowEnabled : 1;
uint xe5_25_shadowDirty : 1;
uint xe5_26_muted : 1;
uint xe5_27_useInSortedLists : 1;
uint xe5_28_callTouch : 1;
uint xe5_29_globalTimeProvider : 1;
uint xe5_30_renderUnsorted : 1;
uint xe5_31_pointGeneratorParticles : 1;
uint xe6_24_fluidCounter : 3;
2022-11-04 05:25:39 +00:00
uint xe6_27_thermalVisorFlags : 2;
uint xe6_29_renderParticleDBInside : 1;
uint xe6_30_enablePitchBend : 1;
uint xe6_31_targetableVisorFlags : 4;
uint xe7_27_enableRender : 1;
uint xe7_28_worldLightingDirty : 1;
uint xe7_29_drawEnabled : 1;
uint xe7_30_doTargetDistanceTest : 1;
uint xe7_31_targetable : 1;
2022-08-13 01:26:00 +00:00
};
CHECK_SIZEOF(CActor, 0xe8)
#endif // _CACTOR