mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-08 15:04:54 +00:00
Create & link TCastTo.cpp
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#ifndef __CBALLCAMERA_HPP__
|
||||
#define __CBALLCAMERA_HPP__
|
||||
|
||||
class CBallCamera {
|
||||
#include "MetroidPrime/Cameras/CGameCamera.hpp"
|
||||
|
||||
class CBallCamera : public CGameCamera {
|
||||
public:
|
||||
enum EBallCameraState {
|
||||
kBCS_Default,
|
||||
@@ -27,6 +29,10 @@ public:
|
||||
kSS_Nav,
|
||||
kSS_Arc,
|
||||
};
|
||||
|
||||
~CBallCamera() override;
|
||||
void Accept(IVisitor& visitor) override;
|
||||
// TODO
|
||||
};
|
||||
|
||||
#endif // __CBALLCAMERA_HPP__
|
||||
|
||||
@@ -5,10 +5,15 @@
|
||||
|
||||
#include "MetroidPrime/CActor.hpp"
|
||||
|
||||
#include "Kyoto/Math/CTransform4f.hpp"
|
||||
#include "Kyoto/Math/CMatrix4f.hpp"
|
||||
#include "Kyoto/Math/CTransform4f.hpp"
|
||||
|
||||
class CGameCamera : public CActor {
|
||||
public:
|
||||
~CGameCamera() override;
|
||||
void Accept(IVisitor& visitor) override;
|
||||
// TODO
|
||||
|
||||
private:
|
||||
TUniqueId xe8_watchedObject;
|
||||
mutable CMatrix4f xec_perspectiveMatrix;
|
||||
|
||||
@@ -3,8 +3,107 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class IVisitor {
|
||||
class CEntity;
|
||||
|
||||
// clang-format off
|
||||
#define TCASTTO_VISITORS \
|
||||
VISIT(CActor) \
|
||||
VISIT(CBallCamera) \
|
||||
VISIT(CBomb) \
|
||||
VISIT(CCinematicCamera) \
|
||||
VISIT(CCollisionActor) \
|
||||
VISIT(CDestroyableRock) \
|
||||
VISIT(CEnergyProjectile) \
|
||||
VISIT(CEntity) \
|
||||
VISIT(CExplosion) \
|
||||
VISIT(CFirstPersonCamera) \
|
||||
VISIT(CFishCloud) \
|
||||
VISIT(CGameCamera) \
|
||||
VISIT(CGameLight) \
|
||||
VISIT(CGameProjectile) \
|
||||
VISIT(CHUDBillboardEffect) \
|
||||
VISIT(CMetroidPrimeRelay) \
|
||||
VISIT(CPathCamera) \
|
||||
VISIT(CPatterned) \
|
||||
VISIT(CPhysicsActor) \
|
||||
VISIT(CPlayer) \
|
||||
VISIT(CRepulsor) \
|
||||
VISIT(CScriptActor) \
|
||||
VISIT(CScriptActorKeyframe) \
|
||||
VISIT(CScriptAiJumpPoint) \
|
||||
VISIT(CScriptCameraHint) \
|
||||
VISIT(CScriptCameraPitchVolume) \
|
||||
VISIT(CScriptCameraWaypoint) \
|
||||
VISIT(CScriptCoverPoint) \
|
||||
VISIT(CScriptDebugCameraWaypoint) \
|
||||
VISIT(CScriptDistanceFog) \
|
||||
VISIT(CScriptDock) \
|
||||
VISIT(CScriptDoor) \
|
||||
VISIT(CScriptEffect) \
|
||||
VISIT(CScriptGrapplePoint) \
|
||||
VISIT(CScriptGunTurret) \
|
||||
VISIT(CScriptMazeNode) \
|
||||
VISIT(CScriptPickup) \
|
||||
VISIT(CScriptPlatform) \
|
||||
VISIT(CScriptPlayerHint) \
|
||||
VISIT(CScriptPointOfInterest) \
|
||||
VISIT(CScriptRoomAcoustics) \
|
||||
VISIT(CScriptSound) \
|
||||
VISIT(CScriptSpawnPoint) \
|
||||
VISIT(CScriptSpecialFunction) \
|
||||
VISIT(CScriptSpiderBallAttractionSurface) \
|
||||
VISIT(CScriptSpiderBallWaypoint) \
|
||||
VISIT(CScriptTargetingPoint) \
|
||||
VISIT(CTeamAiMgr) \
|
||||
VISIT(CScriptTimer) \
|
||||
VISIT(CScriptTrigger) \
|
||||
VISIT(CScriptVisorFlare) \
|
||||
VISIT(CScriptWater) \
|
||||
VISIT(CScriptWaypoint) \
|
||||
VISIT(CSnakeWeedSwarm) \
|
||||
VISIT(CScriptSpindleCamera) \
|
||||
VISIT(CWallCrawlerSwarm) \
|
||||
VISIT(CWeapon)
|
||||
// clang-format on
|
||||
|
||||
#define VISIT(cls) class cls;
|
||||
TCASTTO_VISITORS
|
||||
#undef VISIT
|
||||
|
||||
class IVisitor {
|
||||
public:
|
||||
#define VISIT(cls) virtual void Visit(cls& p) = 0;
|
||||
TCASTTO_VISITORS
|
||||
#undef VISIT
|
||||
};
|
||||
|
||||
template < class T >
|
||||
class TCastToPtr : public IVisitor {
|
||||
public:
|
||||
TCastToPtr(CEntity* p);
|
||||
TCastToPtr(CEntity& p);
|
||||
operator T*() const { return ptr; }
|
||||
|
||||
#define VISIT(cls) void Visit(cls& p) override;
|
||||
TCASTTO_VISITORS
|
||||
#undef VISIT
|
||||
|
||||
private:
|
||||
// Compiler picks the overload based on whether
|
||||
// the passed pointer is convertible to T*
|
||||
T* GetPtr(void* ptr) const { return nullptr; }
|
||||
T* GetPtr(T* ptr) const { return ptr; }
|
||||
|
||||
T* ptr;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
const T* TCastToConstPtr(const CEntity* p) {
|
||||
return TCastToPtr(const_cast< CEntity* >(p));
|
||||
}
|
||||
template < typename T >
|
||||
const T* TCastToConstPtr(const CEntity& p) {
|
||||
return TCastToPtr(const_cast< CEntity* >(&p));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user