TCastTo implementation

This commit is contained in:
Jack Andersen 2017-01-14 17:07:01 -10:00
parent 3544cbd278
commit e2c671e9b4
111 changed files with 766 additions and 35 deletions

View File

@ -384,7 +384,11 @@ bool FRME::Extract(const SpecBase &dataSpec,
{ {
CAMRInfo::OrthographicProjection* proj = static_cast<CAMRInfo::OrthographicProjection*>(info->projection.get()); CAMRInfo::OrthographicProjection* proj = static_cast<CAMRInfo::OrthographicProjection*>(info->projection.get());
os.format("cam.type = 'ORTHO'\n" os.format("cam.type = 'ORTHO'\n"
"cam.ortho_scale = %f\n", std::fabs(proj->right - proj->left)); "cam.ortho_scale = %f\n"
"cam.clip_start = %f\n"
"cam.clip_end = %f\n",
std::fabs(proj->right - proj->left),
proj->znear, proj->zfar);
} }
else if (info->projectionType == CAMRInfo::ProjectionType::Perspective) else if (info->projectionType == CAMRInfo::ProjectionType::Perspective)
{ {

View File

@ -4,6 +4,62 @@
namespace urde namespace urde
{ {
struct SDSPStreamCacheEntry
{
std::string x0_fileName;
u32 x10_;
u32 x14_;
float x18_;
float x1c_;
u32 x20_;
float x24_;
bool x28_;
};
/* Standard DSPADPCM header */
struct dspadpcm_header
{
uint32_t x0_num_samples;
uint32_t x4_num_nibbles;
uint32_t x8_sample_rate;
uint16_t xc_loop_flag;
uint16_t xe_format; /* 0 for ADPCM */
uint32_t x10_loop_start_nibble;
uint32_t x14_loop_end_nibble;
uint32_t x18_ca;
int16_t x1c_coef[16];
int16_t x3c_gain;
int16_t x3e_ps;
int16_t x40_hist1;
int16_t x42_hist2;
int16_t x44_loop_ps;
int16_t x46_loop_hist1;
int16_t x48_loop_hist2;
uint16_t x4a_pad[11];
};
struct CDSPStreamManager
{
dspadpcm_header x0_header;
std::string x60_fileName; // arg1
union
{
u8 dummy = 0;
struct
{
bool x70_24_claimed : 1;
bool x70_25_ : 1;
u8 x70_26_ : 2;
};
};
u8 x71_ = -1;
u8 x72_ = -1;
u8 x73_arg3;
u8 x74_arg4;
u32 x78_handleId; // arg2
//DVDFileInfo x80_dvdHandle;
};
struct SDSPStreamInfo struct SDSPStreamInfo
{ {
const char* x0_fileName; const char* x0_fileName;
@ -13,6 +69,7 @@ struct SDSPStreamInfo
u32 x10_; u32 x10_;
u32 x14_; u32 x14_;
u32 x18_adpcmOffset; u32 x18_adpcmOffset;
u32 x1c_; u32 x1c_;
u32 x20_; u32 x20_;
u32 x24_adpcmCur; u32 x24_adpcmCur;

View File

@ -1,4 +1,5 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${BOO_INCLUDE_DIR} ${LIBJPEG_INCLUDE_DIR} include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${BOO_INCLUDE_DIR} ${LIBJPEG_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/DataSpec ${JBUS_INCLUDE_DIR}) ${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/DataSpec ${JBUS_INCLUDE_DIR})
macro(runtime_add_list rel_path a_list) macro(runtime_add_list rel_path a_list)
@ -29,6 +30,11 @@ else()
list(APPEND PLAT_SRCS CMemoryCardSysNix.cpp) list(APPEND PLAT_SRCS CMemoryCardSysNix.cpp)
endif() endif()
add_custom_command(OUTPUT TCastTo.hpp TCastTo.cpp DEPENDS MkCastTo.py
COMMAND python ARGS ${CMAKE_CURRENT_SOURCE_DIR}/MkCastTo.py
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating cast functions")
add_subdirectory(MP1) add_subdirectory(MP1)
add_subdirectory(MP2) add_subdirectory(MP2)
add_subdirectory(MP3) add_subdirectory(MP3)
@ -97,5 +103,7 @@ add_library(RuntimeCommon
CGameHintInfo.hpp CGameHintInfo.cpp CGameHintInfo.hpp CGameHintInfo.cpp
rstl.hpp rstl.cpp rstl.hpp rstl.cpp
GameGlobalObjects.hpp GameGlobalObjects.cpp GameGlobalObjects.hpp GameGlobalObjects.cpp
MkCastTo.py
TCastTo.hpp TCastTo.cpp
GCNTypes.hpp GCNTypes.hpp
${PLAT_SRCS}) ${PLAT_SRCS})

View File

@ -23,6 +23,7 @@
#include "AutoMapper/CMapWorldInfo.hpp" #include "AutoMapper/CMapWorldInfo.hpp"
#include "Particle/CGenDescription.hpp" #include "Particle/CGenDescription.hpp"
#include "CMemoryCardSys.hpp" #include "CMemoryCardSys.hpp"
#include "TCastTo.hpp"
#include <cmath> #include <cmath>
@ -143,7 +144,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
x90c_loaderFuncs[int(EScriptObjectType::ColorModulate)] = ScriptLoader::LoadColorModulate; x90c_loaderFuncs[int(EScriptObjectType::ColorModulate)] = ScriptLoader::LoadColorModulate;
x90c_loaderFuncs[int(EScriptObjectType::ThardusRockProjectile)] = ScriptLoader::LoadThardusRockProjectile; x90c_loaderFuncs[int(EScriptObjectType::ThardusRockProjectile)] = ScriptLoader::LoadThardusRockProjectile;
x90c_loaderFuncs[int(EScriptObjectType::Midi)] = ScriptLoader::LoadMidi; x90c_loaderFuncs[int(EScriptObjectType::Midi)] = ScriptLoader::LoadMidi;
x90c_loaderFuncs[int(EScriptObjectType::StreamedAudio)] = ScriptLoader::LoadStreamedAudio; x90c_loaderFuncs[int(EScriptObjectType::StreamedAudio)] = ScriptLoader::LoadStreamedMusic;
x90c_loaderFuncs[int(EScriptObjectType::WorldTeleporterToo)] = ScriptLoader::LoadWorldTeleporter; x90c_loaderFuncs[int(EScriptObjectType::WorldTeleporterToo)] = ScriptLoader::LoadWorldTeleporter;
x90c_loaderFuncs[int(EScriptObjectType::Repulsor)] = ScriptLoader::LoadRepulsor; x90c_loaderFuncs[int(EScriptObjectType::Repulsor)] = ScriptLoader::LoadRepulsor;
x90c_loaderFuncs[int(EScriptObjectType::GunTurret)] = ScriptLoader::LoadGunTurret; x90c_loaderFuncs[int(EScriptObjectType::GunTurret)] = ScriptLoader::LoadGunTurret;
@ -330,7 +331,7 @@ void CStateManager::TouchPlayerActor()
return; return;
#if 0 #if 0
CScriptPlayerActor* spa = dynamic_cast<CScriptPlayerActor*>(GetObjectById(xf6c_playerActor)); CScriptPlayerActor* spa = TCastToPtr<CScriptPlayerActor>(GetObjectById(xf6c_playerActor));
if (spa) if (spa)
spa->TouchModels(); spa->TouchModels();
#endif #endif
@ -528,12 +529,12 @@ bool CStateManager::ApplyLocalDamage(const zeus::CVector3f& vec1, const zeus::CV
float f30 = dt; float f30 = dt;
CPlayer* player = dynamic_cast<CPlayer*>(&actor); CPlayer* player = TCastToPtr<CPlayer>(&actor);
CAi* ai = dynamic_cast<CAi*>(&actor); CAi* ai = TCastToPtr<CAi>(&actor);
#if 0 #if 0
CDestroyableRock* dRock = nullptr; CDestroyableRock* dRock = nullptr;
if (!ai) if (!ai)
dynamic_cast<CDestroyableRock*>(&actor); TCastToPtr<CDestroyableRock>(&actor);
#endif #endif
if (player) if (player)
@ -620,7 +621,7 @@ void CStateManager::InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId)
for (CEntity* ent : *x80c_allObjs) for (CEntity* ent : *x80c_allObjs)
{ {
CScriptSpawnPoint* sp = dynamic_cast<CScriptSpawnPoint*>(ent); CScriptSpawnPoint* sp = TCastToPtr<CScriptSpawnPoint>(ent);
if (sp && sp->x30_24_active && sp->FirstSpawn()) if (sp && sp->x30_24_active && sp->FirstSpawn())
{ {
const zeus::CTransform& xf = sp->GetTransform(); const zeus::CTransform& xf = sp->GetTransform();

View File

@ -22,6 +22,16 @@ public:
{ {
return CompareCaseInsensitive(a.c_str(), b.c_str()); return CompareCaseInsensitive(a.c_str(), b.c_str());
} }
static int IndexOfSubstring(const std::string& haystack, const std::string& needle)
{
std::string str = haystack;
std::transform(str.begin(), str.end(), str.begin(), tolower);
std::string::size_type s = str.find(needle);
if (s == std::string::npos)
return -1;
return s;
}
}; };
} }

View File

@ -12,6 +12,8 @@
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "Graphics/CGraphics.hpp" #include "Graphics/CGraphics.hpp"
#include "CObjectList.hpp" #include "CObjectList.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
float CCameraManager::sAspect = 1.42f; float CCameraManager::sAspect = 1.42f;
@ -115,7 +117,7 @@ void CCameraManager::Update(float dt, CStateManager& stateMgr)
if (x74_fluidCounter) if (x74_fluidCounter)
{ {
const CScriptWater* water = dynamic_cast<const CScriptWater*>(stateMgr.GetObjectById(x78_fluidId)); const CScriptWater* water = TCastToConstPtr<CScriptWater>(stateMgr.GetObjectById(x78_fluidId));
if (water) if (water)
{ {
// TODO: Finish // TODO: Finish
@ -167,7 +169,7 @@ void CCameraManager::ThinkCameras(float dt, CStateManager& mgr)
for (CEntity* ent : gcList) for (CEntity* ent : gcList)
{ {
CGameCamera* gc = dynamic_cast<CGameCamera*>(ent); CGameCamera* gc = TCastToPtr<CGameCamera>(ent);
if (gc) if (gc)
{ {
gc->Think(dt, mgr); gc->Think(dt, mgr);
@ -179,7 +181,7 @@ void CCameraManager::ThinkCameras(float dt, CStateManager& mgr)
return; return;
TUniqueId camId = GetLastCameraId(); TUniqueId camId = GetLastCameraId();
const CGameCamera* cam = dynamic_cast<const CGameCamera*>(mgr.GetObjectById(camId)); const CGameCamera* cam = TCastToConstPtr<CGameCamera>(mgr.GetObjectById(camId));
if (cam) if (cam)
x3bc_curFov = cam->GetFov(); x3bc_curFov = cam->GetFov();

View File

@ -1,4 +1,5 @@
#include "CCinematicCamera.hpp" #include "CCinematicCamera.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -10,6 +11,11 @@ CCinematicCamera::CCinematicCamera(TUniqueId uid, const std::string& name, const
{ {
} }
void CCinematicCamera::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CCinematicCamera::ProcessInput(const CFinalInput&, CStateManager& mgr) {} void CCinematicCamera::ProcessInput(const CFinalInput&, CStateManager& mgr) {}
void CCinematicCamera::Reset(const zeus::CTransform&, CStateManager& mgr) {} void CCinematicCamera::Reset(const zeus::CTransform&, CStateManager& mgr) {}

View File

@ -12,6 +12,7 @@ public:
CCinematicCamera(TUniqueId, const std::string& name, const CEntityInfo& info, CCinematicCamera(TUniqueId, const std::string& name, const CEntityInfo& info,
const zeus::CTransform& xf, bool, float, float, float, float, float, u32); const zeus::CTransform& xf, bool, float, float, float, float, float, u32);
void Accept(IVisitor& visitor);
void ProcessInput(const CFinalInput&, CStateManager& mgr); void ProcessInput(const CFinalInput&, CStateManager& mgr);
void Reset(const zeus::CTransform&, CStateManager& mgr); void Reset(const zeus::CTransform&, CStateManager& mgr);
}; };

View File

@ -5,6 +5,7 @@
#include "World/CPlayer.hpp" #include "World/CPlayer.hpp"
#include "World/CPlayerCameraBob.hpp" #include "World/CPlayerCameraBob.hpp"
#include "World/CScriptGrapplePoint.hpp" #include "World/CScriptGrapplePoint.hpp"
#include "TCastTo.hpp"
#include <math.h> #include <math.h>
namespace urde namespace urde
@ -97,7 +98,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
if (player->x304_ == 4 || player->x304_ == 1) if (player->x304_ == 4 || player->x304_ == 1)
{ {
const CActor* act = dynamic_cast<const CActor*>(mgr.GetObjectById(player->x310_grapplePointId)); const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(player->x310_grapplePointId));
if (act && act->GetMaterialList().Intersection(CMaterialList(EMaterialTypes::Lava)) != 0) if (act && act->GetMaterialList().Intersection(CMaterialList(EMaterialTypes::Lava)) != 0)
{ {
zeus::CVector3f v = player->x318_ - eyePos; zeus::CVector3f v = player->x318_ - eyePos;
@ -162,7 +163,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
qGun = zeus::CQuaternion::lookAt(rVec, gunFrontVec, scaledDt * clampedAngle); qGun = zeus::CQuaternion::lookAt(rVec, gunFrontVec, scaledDt * clampedAngle);
const CScriptGrapplePoint* gPoint = const CScriptGrapplePoint* gPoint =
dynamic_cast<const CScriptGrapplePoint*>(mgr.GetObjectById(player->x310_grapplePointId)); TCastToConstPtr<CScriptGrapplePoint>(mgr.GetObjectById(player->x310_grapplePointId));
if (gPoint && player->x29c_ > 0.f) if (gPoint && player->x29c_ > 0.f)
{ {
gunFrontVec = x190_gunFollowXf.frontVector(); gunFrontVec = x190_gunFollowXf.frontVector();

View File

@ -6,6 +6,7 @@
#include "World/CScriptAiJumpPoint.hpp" #include "World/CScriptAiJumpPoint.hpp"
#include "World/CPatterned.hpp" #include "World/CPatterned.hpp"
#include "Camera/CGameCamera.hpp" #include "Camera/CGameCamera.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -15,7 +16,7 @@ CActorList::CActorList()
bool CActorList::IsQualified(const CEntity& ent) bool CActorList::IsQualified(const CEntity& ent)
{ {
return static_cast<const CActor*>(&ent) != nullptr; return TCastToConstPtr<CActor>(ent);
} }
CPhysicsActorList::CPhysicsActorList() CPhysicsActorList::CPhysicsActorList()
@ -23,7 +24,7 @@ CPhysicsActorList::CPhysicsActorList()
bool CPhysicsActorList::IsQualified(const CEntity& ent) bool CPhysicsActorList::IsQualified(const CEntity& ent)
{ {
return static_cast<const CPhysicsActor*>(&ent) != nullptr; return TCastToConstPtr<CPhysicsActor>(ent);
} }
CGameCameraList::CGameCameraList() CGameCameraList::CGameCameraList()
@ -31,7 +32,7 @@ CGameCameraList::CGameCameraList()
bool CGameCameraList::IsQualified(const CEntity& ent) bool CGameCameraList::IsQualified(const CEntity& ent)
{ {
return static_cast<const CGameCamera*>(&ent) != nullptr; return TCastToConstPtr<CGameCamera>(ent);
} }
CListeningAiList::CListeningAiList() CListeningAiList::CListeningAiList()
@ -39,7 +40,7 @@ CListeningAiList::CListeningAiList()
bool CListeningAiList::IsQualified(const CEntity& ent) bool CListeningAiList::IsQualified(const CEntity& ent)
{ {
return (static_cast<const CPatterned*>(&ent) != nullptr); return TCastToConstPtr<CPatterned>(ent);
} }
CAiWaypointList::CAiWaypointList() CAiWaypointList::CAiWaypointList()
@ -47,8 +48,8 @@ CAiWaypointList::CAiWaypointList()
bool CAiWaypointList::IsQualified(const CEntity& ent) bool CAiWaypointList::IsQualified(const CEntity& ent)
{ {
return static_cast<const CScriptCoverPoint*>(&ent) != nullptr || return TCastToConstPtr<CScriptCoverPoint>(ent) ||
static_cast<const CScriptAiJumpPoint*>(&ent) != nullptr; TCastToConstPtr<CScriptAiJumpPoint>(ent);
} }
CPlatformAndDoorList::CPlatformAndDoorList() CPlatformAndDoorList::CPlatformAndDoorList()
@ -61,12 +62,12 @@ bool CPlatformAndDoorList::IsQualified(const CEntity& ent)
bool CPlatformAndDoorList::IsDoor(const CEntity& ent) bool CPlatformAndDoorList::IsDoor(const CEntity& ent)
{ {
return static_cast<const CScriptDoor*>(&ent) != nullptr; return TCastToConstPtr<CScriptDoor>(ent);
} }
bool CPlatformAndDoorList::IsPlatform(const CEntity& ent) bool CPlatformAndDoorList::IsPlatform(const CEntity& ent)
{ {
return static_cast<const CScriptPlatform*>(&ent) != nullptr; return TCastToConstPtr<CScriptPlatform>(ent);
} }
CGameLightList::CGameLightList() CGameLightList::CGameLightList()
@ -74,7 +75,7 @@ CGameLightList::CGameLightList()
bool CGameLightList::IsQualified(const CEntity& lt) bool CGameLightList::IsQualified(const CEntity& lt)
{ {
return static_cast<const CGameLight*>(&lt) != nullptr; return TCastToConstPtr<CGameLight>(lt);
} }
} }

View File

@ -1,6 +1,7 @@
#include "CBeetle.hpp" #include "CBeetle.hpp"
#include "World/CDamageInfo.hpp" #include "World/CDamageInfo.hpp"
#include "Character/CCharLayoutInfo.hpp" #include "Character/CCharLayoutInfo.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -17,5 +18,10 @@ CBeetle::CBeetle(TUniqueId uid, const std::string& name, const CEntityInfo& info
} }
void CBeetle::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }
} }

View File

@ -23,6 +23,8 @@ public:
const CPatternedInfo&, CPatterned::EFlavorType,EEntranceType, const CDamageInfo &, const CDamageVulnerability&, const CPatternedInfo&, CPatterned::EFlavorType,EEntranceType, const CDamageInfo &, const CDamageVulnerability&,
const zeus::CVector3f&, float, float, float, const CDamageVulnerability&, const CActorParameters&, const zeus::CVector3f&, float, float, float, const CDamageVulnerability&, const CActorParameters&,
const rstl::optional_object<CStaticRes>); const rstl::optional_object<CStaticRes>);
void Accept(IVisitor& visitor);
}; };
} }
} }

View File

@ -1,5 +1,6 @@
#include "CNewIntroBoss.hpp" #include "CNewIntroBoss.hpp"
#include "Character/CCharLayoutInfo.hpp" #include "Character/CCharLayoutInfo.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -15,5 +16,10 @@ CNewIntroBoss::CNewIntroBoss(TUniqueId uid, const std::string& name, const CEnti
{ {
} }
void CNewIntroBoss::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }
} }

View File

@ -17,6 +17,8 @@ public:
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo, const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo,
u32, u32, u32, u32); u32, u32, u32, u32);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,5 +1,6 @@
#include "CSpacePirate.hpp" #include "CSpacePirate.hpp"
#include "Character/CCharLayoutInfo.hpp" #include "Character/CCharLayoutInfo.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -12,5 +13,11 @@ CSpacePirate::CSpacePirate(TUniqueId uid, const std::string& name, const CEntity
EColliderType::One, EBodyType::One, aParams, true) EColliderType::One, EBodyType::One, aParams, true)
{ {
} }
void CSpacePirate::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }
} }

View File

@ -12,6 +12,8 @@ class CSpacePirate : public CPatterned
public: public:
CSpacePirate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CSpacePirate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, const CPatternedInfo&, CInputStream&, u32); const CActorParameters&, const CPatternedInfo&, CInputStream&, u32);
void Accept(IVisitor& visitor);
}; };
} }
} }

View File

@ -1,5 +1,6 @@
#include "CWarWasp.hpp" #include "CWarWasp.hpp"
#include "Character/CCharLayoutInfo.hpp" #include "Character/CCharLayoutInfo.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -14,6 +15,12 @@ CWarWasp::CWarWasp(TUniqueId uid, const std::string& name, const CEntityInfo& in
{ {
} }
void CWarWasp::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }
} }

View File

@ -15,6 +15,8 @@ public:
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
CPatterned::EFlavorType flavor, CPatterned::EColliderType, const CDamageInfo& dInfo1, const CActorParameters&, CPatterned::EFlavorType flavor, CPatterned::EColliderType, const CDamageInfo& dInfo1, const CActorParameters&,
ResId weapon, const CDamageInfo& dInfo2, ResId particle, u32 w3); ResId weapon, const CDamageInfo& dInfo2, ResId particle, u32 w3);
void Accept(IVisitor& visitor);
}; };
} }
} }

180
Runtime/MkCastTo.py Normal file
View File

@ -0,0 +1,180 @@
"Generates TCastTo source files for constexpr-enabled CEntity casts"
class Namespace:
def __init__(self, name):
self.name = name
class EndNamespace:
pass
CENTITY_TYPES = (
('CActor', 'World/CActor.hpp'),
('CPhysicsActor', 'World/CPhysicsActor.hpp'),
('CGameCamera', 'Camera/CGameCamera.hpp'),
('CPatterned', 'World/CPatterned.hpp'),
('CGameLight', 'World/CGameLight.hpp'),
('CAi', 'World/CAi.hpp'),
('CCinematicCamera', 'Camera/CCinematicCamera.hpp'),
('CScriptHUDMemo', 'World/CScriptHUDMemo.hpp'),
('CScriptCameraHint', 'World/CScriptCameraHint.hpp'),
('CScriptPickup', 'World/CScriptPickup.hpp'),
('CScriptRandomRelay', 'World/CScriptRandomRelay.hpp'),
('CScriptMemoryRelay', 'World/CScriptMemoryRelay.hpp'),
('CScriptRelay', 'World/CScriptRelay.hpp'),
('CScriptCameraWaypoint', 'World/CScriptCameraWaypoint.hpp'),
('CScriptCoverPoint', 'World/CScriptCoverPoint.hpp'),
('CScriptSpawnPoint', 'World/CScriptSpawnPoint.hpp'),
('CRepulsor', 'World/CRepulsor.hpp'),
('CScriptCameraHintTrigger', 'World/CScriptCameraHintTrigger.hpp'),
('CScriptSwitch', 'World/CScriptSwitch.hpp'),
('CScriptAiJumpPoint', 'World/CScriptAiJumpPoint.hpp'),
('CScriptColorModulate', 'World/CScriptColorModulate.hpp'),
('CScriptCameraPitchVolume', 'World/CScriptCameraPitchVolume.hpp'),
('CPlayer', 'World/CPlayer.hpp'),
('CScriptActor', 'World/CScriptActor.hpp'),
('CScriptWaypoint', 'World/CScriptWaypoint.hpp'),
('CScriptDoor', 'World/CScriptDoor.hpp'),
('CScriptActorKeyframe', 'World/CScriptActorKeyframe.hpp'),
('CScriptTrigger', 'World/CScriptTrigger.hpp'),
('CScriptSound', 'World/CScriptSound.hpp'),
('CPlasmaProjectile', 'Weapon/CPlasmaProjectile.hpp'),
('CScriptCounter', 'World/CScriptCounter.hpp'),
('CScriptBeam', 'World/CScriptBeam.hpp'),
('CScriptStreamedMusic', 'World/CScriptStreamedMusic.hpp'),
('CScriptTimer', 'World/CScriptTimer.hpp'),
('CScriptEffect', 'World/CScriptEffect.hpp'),
('CScriptPlatform', 'World/CScriptPlatform.hpp'),
('CScriptGrapplePoint', 'World/CScriptGrapplePoint.hpp'),
('CScriptGenerator', 'World/CScriptGenerator.hpp'),
('CScriptShadowProjector', 'World/CScriptShadowProjector.hpp'),
('CScriptDock', 'World/CScriptDock.hpp'),
('CScriptAreaAttributes', 'World/CScriptAreaAttributes.hpp'),
('CScriptPickupGenerator', 'World/CScriptPickupGenerator.hpp'),
('CScriptPointOfInterest', 'World/CScriptPointOfInterest.hpp'),
('CScriptCameraFilterKeyframe', 'World/CScriptCameraFilterKeyframe.hpp'),
('CScriptCameraBlurKeyframe', 'World/CScriptCameraBlurKeyframe.hpp'),
('CScriptActorRotate', 'World/CScriptActorRotate.hpp'),
('CScriptDistanceFog', 'World/CScriptDistanceFog.hpp'),
('CScriptDamageableTrigger', 'World/CScriptDamageableTrigger.hpp'),
('CScriptDockAreaChange', 'World/CScriptDockAreaChange.hpp'),
('CScriptSpecialFunction', 'World/CScriptSpecialFunction.hpp'),
('CScriptDebris', 'World/CScriptDebris.hpp'),
Namespace('MP1'),
('CBeetle', 'MP1/CBeetle.hpp', 'MP1'),
('CWarWasp', 'MP1/CWarWasp.hpp', 'MP1'),
('CSpacePirate', 'MP1/CSpacePirate.hpp', 'MP1'),
('CNewIntroBoss', 'MP1/CNewIntroBoss.hpp', 'MP1'),
EndNamespace(),
)
def getqualified(tp):
if len(tp) >= 3:
return tp[2] + '::' + tp[0]
else:
return tp[0]
headerf = open('TCastTo.hpp', 'w')
sourcef = open('TCastTo.cpp', 'w')
headerf.write('''#ifndef __TCASTTO_HPP__
#define __TCASTTO_HPP__
namespace urde
{
class CEntity;
''')
for tp in CENTITY_TYPES:
if type(tp) == tuple:
headerf.write('class %s;\n' % tp[0])
elif isinstance(tp, Namespace):
headerf.write('namespace %s\n{\n' % tp.name)
elif isinstance(tp, EndNamespace):
headerf.write('}\n')
headerf.write('\nclass IVisitor\n{\npublic:\n')
for tp in CENTITY_TYPES:
if type(tp) == tuple:
headerf.write(' virtual void Visit(%s* p)=0;\n' % getqualified(tp))
headerf.write('''};
template <class T>
class TCastToPtr : public IVisitor
{
protected:
T* ptr = nullptr;
public:
TCastToPtr(CEntity* p);
TCastToPtr(CEntity& p);
''')
for tp in CENTITY_TYPES:
if type(tp) == tuple:
headerf.write(' void Visit(%s* p);\n' % getqualified(tp))
headerf.write('''
T* GetPtr() const { return ptr; }
operator T*() const { return GetPtr(); }
T* operator->() const { return GetPtr(); }
operator bool() const { return ptr != nullptr; }
};
template <class T>
class TCastToConstPtr : TCastToPtr<T>
{
public:
TCastToConstPtr(const CEntity* p) : TCastToPtr<T>(const_cast<CEntity*>(p)) {}
TCastToConstPtr(const CEntity& p) : TCastToPtr<T>(const_cast<CEntity&>(p)) {}
const T* GetPtr() const { return TCastToPtr<T>::ptr; }
operator const T*() const { return GetPtr(); }
const T* operator->() const { return GetPtr(); }
operator bool() const { return TCastToPtr<T>::ptr != nullptr; }
};
}
#endif // __TCASTTO_HPP__
''')
headerf.close()
sourcef.write('#include "TCastTo.hpp"\n\n')
for tp in CENTITY_TYPES:
if type(tp) == tuple:
sourcef.write('#include "%s"\n' % tp[1])
sourcef.write('''
namespace urde
{
template <class T>
TCastToPtr<T>::TCastToPtr(CEntity* p) { p->Accept(*this); }
template <class T>
TCastToPtr<T>::TCastToPtr(CEntity& p) { p.Accept(*this); }
''')
for tp in CENTITY_TYPES:
if type(tp) == tuple:
qual = getqualified(tp)
sourcef.write('''template <class T>
void TCastToPtr<T>::Visit(%s* p)
{
ptr = reinterpret_cast<T*>(std::is_convertible<%s*, T*>::value ? p : nullptr);
}
''' % (qual, qual))
for tp in CENTITY_TYPES:
if type(tp) == tuple:
sourcef.write('template class TCastToPtr<%s>;\n' % getqualified(tp))
sourcef.write('\n}\n')
sourcef.close()

View File

@ -1,4 +1,5 @@
#include "CPlasmaProjectile.hpp" #include "CPlasmaProjectile.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -10,4 +11,10 @@ CPlasmaProjectile::CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, co
: CBeamProjectile(wDesc, name, wType, xf, bInfo.x18_, bInfo.x1c_, bInfo.x38_, matType, dInfo, owner, aid, uid, w2, b1) : CBeamProjectile(wDesc, name, wType, xf, bInfo.x18_, bInfo.x1c_, bInfo.x38_, matType, dInfo, owner, aid, uid, w2, b1)
{ {
} }
void CPlasmaProjectile::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -13,6 +13,8 @@ public:
CPlasmaProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const CBeamInfo&, CPlasmaProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const CBeamInfo&,
const zeus::CTransform&, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, const zeus::CTransform&, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32,
bool, u32); bool, u32);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -3,6 +3,7 @@
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
#include "Audio/CSfxManager.hpp" #include "Audio/CSfxManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -70,7 +71,7 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana
if (conn.x0_state != EScriptObjectState::DFST) if (conn.x0_state != EScriptObjectState::DFST)
continue; continue;
const CActor* act = dynamic_cast<const CActor*>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))); const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
if (act && xc6_ == kInvalidUniqueId) if (act && xc6_ == kInvalidUniqueId)
xc6_ = act->GetUniqueId(); xc6_ = act->GetUniqueId();
} }

View File

@ -7,6 +7,7 @@
namespace urde namespace urde
{ {
class CStateManager; class CStateManager;
class IVisitor;
struct SConnection struct SConnection
{ {
@ -53,8 +54,9 @@ protected:
public: public:
static const std::vector<SConnection> NullConnectionList; static const std::vector<SConnection> NullConnectionList;
virtual ~CEntity() {} virtual ~CEntity() = default;
CEntity(TUniqueId uid, const CEntityInfo& info, bool active, const std::string& name); CEntity(TUniqueId uid, const CEntityInfo& info, bool active, const std::string& name);
virtual void Accept(IVisitor& visitor)=0;
virtual void PreThink(float, CStateManager&) {} virtual void PreThink(float, CStateManager&) {}
virtual void Think(float, CStateManager&) {} virtual void Think(float, CStateManager&) {}
virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);

View File

@ -72,6 +72,7 @@ set(WORLD_SOURCES
CScriptBeam.hpp CScriptBeam.cpp CScriptBeam.hpp CScriptBeam.cpp
CScriptMazeNode.hpp CScriptMazeNode.cpp CScriptMazeNode.hpp CScriptMazeNode.cpp
CScriptShadowProjector.hpp CScriptShadowProjector.cpp CScriptShadowProjector.hpp CScriptShadowProjector.cpp
CScriptStreamedMusic.hpp CScriptStreamedMusic.cpp
CGrappleParameters.hpp CGrappleParameters.hpp
CActorParameters.hpp CActorParameters.hpp
CLightParameters.hpp CLightParameters.hpp

View File

@ -6,6 +6,7 @@
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "Particle/CGenDescription.hpp" #include "Particle/CGenDescription.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -69,7 +70,10 @@ bool CPlayer::WasDamaged() const { return false; }
void CPlayer::TakeDamage(bool, const zeus::CVector3f&, float, EWeaponType, CStateManager& mgr) {} void CPlayer::TakeDamage(bool, const zeus::CVector3f&, float, EWeaponType, CStateManager& mgr) {}
void CPlayer::Accept(IVisitor& visitor) {} void CPlayer::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
CHealthInfo* CPlayer::HealthInfo(CStateManager& mgr) { return nullptr; } CHealthInfo* CPlayer::HealthInfo(CStateManager& mgr) { return nullptr; }

View File

@ -1,5 +1,6 @@
#include "CRepulsor.hpp" #include "CRepulsor.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -11,6 +12,11 @@ CRepulsor::CRepulsor(TUniqueId uid, bool active, const std::string& name, const
{ {
} }
void CRepulsor::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CRepulsor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CRepulsor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
CActor::AcceptScriptMsg(msg, objId, stateMgr); CActor::AcceptScriptMsg(msg, objId, stateMgr);

View File

@ -11,6 +11,7 @@ class CRepulsor : public CActor
public: public:
CRepulsor(TUniqueId, bool, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float); CRepulsor(TUniqueId, bool, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
float GetAffectRadius() const { return xe8_affectRadius; } float GetAffectRadius() const { return xe8_affectRadius; }

View File

@ -1,4 +1,5 @@
#include "CScriptActor.hpp" #include "CScriptActor.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -10,4 +11,10 @@ CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntity
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(a), actParms, 0.3f, 0.1f) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(a), actParms, 0.3f, 0.1f)
{ {
} }
void CScriptActor::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -12,6 +12,7 @@ public:
CScriptActor(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CScriptActor(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const zeus::CAABox& aabb, float, float, const CMaterialList& matList, const CHealthInfo&, const zeus::CAABox& aabb, float, float, const CMaterialList& matList, const CHealthInfo&,
const CDamageVulnerability&, const CActorParameters&, bool, bool, u32, float, bool, bool, bool, bool); const CDamageVulnerability&, const CActorParameters&, bool, bool, u32, float, bool, bool, bool, bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,4 +1,5 @@
#include "CScriptActorKeyframe.hpp" #include "CScriptActorKeyframe.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -15,6 +16,11 @@ CScriptActorKeyframe::CScriptActorKeyframe(TUniqueId uid, const std::string& nam
{ {
} }
void CScriptActorKeyframe::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {} void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {}
void CScriptActorKeyframe::Think(float dt, CStateManager& mgr) void CScriptActorKeyframe::Think(float dt, CStateManager& mgr)

View File

@ -29,6 +29,7 @@ public:
CScriptActorKeyframe(TUniqueId uid, const std::string& name, const CEntityInfo& info, s32 w1, bool b1, float f1, CScriptActorKeyframe(TUniqueId uid, const std::string& name, const CEntityInfo& info, s32 w1, bool b1, float f1,
bool b2, u32 w2, bool active, float f2); bool b2, u32 w2, bool active, float f2);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
void Think(float, CStateManager&); void Think(float, CStateManager&);
void UpdateEntity(TUniqueId, CStateManager&); void UpdateEntity(TUniqueId, CStateManager&);

View File

@ -1,4 +1,5 @@
#include "CScriptActorRotate.hpp" #include "CScriptActorRotate.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -7,4 +8,10 @@ CScriptActorRotate::CScriptActorRotate(TUniqueId uid, const std::string& name, c
: CEntity(uid, info, active, name) : CEntity(uid, info, active, name)
{ {
} }
void CScriptActorRotate::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -27,6 +27,8 @@ class CScriptActorRotate : public CEntity
public: public:
CScriptActorRotate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float, bool, bool, CScriptActorRotate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float, bool, bool,
bool); bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -2,6 +2,7 @@
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CScriptWaypoint.hpp" #include "CScriptWaypoint.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -14,6 +15,11 @@ CScriptAiJumpPoint::CScriptAiJumpPoint(TUniqueId uid, const std::string& name, c
xec_.emplace(xf.origin, xf.origin); xec_.emplace(xf.origin, xf.origin);
} }
void CScriptAiJumpPoint::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptAiJumpPoint::Think(float dt, CStateManager&) void CScriptAiJumpPoint::Think(float dt, CStateManager&)
{ {
if (x110_timeRemaining <= 0) if (x110_timeRemaining <= 0)

View File

@ -25,6 +25,7 @@ private:
public: public:
CScriptAiJumpPoint(TUniqueId, const std::string&, const CEntityInfo&, zeus::CTransform&, bool, float); CScriptAiJumpPoint(TUniqueId, const std::string&, const CEntityInfo&, zeus::CTransform&, bool, float);
void Accept(IVisitor& visitor);
void Think(float, CStateManager&); void Think(float, CStateManager&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {} void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {}

View File

@ -2,6 +2,7 @@
#include "CEnvFxManager.hpp" #include "CEnvFxManager.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CWorld.hpp" #include "CWorld.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -21,6 +22,11 @@ CScriptAreaAttributes::CScriptAreaAttributes(TUniqueId uid, const CEntityInfo& i
{ {
} }
void CScriptAreaAttributes::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptAreaAttributes::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CScriptAreaAttributes::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
AcceptScriptMsg(msg, objId, stateMgr); AcceptScriptMsg(msg, objId, stateMgr);

View File

@ -22,6 +22,7 @@ public:
float envFxDensity, float thermalHeat, float xrayFogDistance, float worldLightingLevel, float envFxDensity, float thermalHeat, float xrayFogDistance, float worldLightingLevel,
ResId skybox, EPhazonType phazonType); ResId skybox, EPhazonType phazonType);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
bool GetNeedsSky() const; bool GetNeedsSky() const;

View File

@ -3,6 +3,7 @@
#include "Particle/CWeaponDescription.hpp" #include "Particle/CWeaponDescription.hpp"
#include "Weapon/CPlasmaProjectile.hpp" #include "Weapon/CPlasmaProjectile.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -18,6 +19,11 @@ CScriptBeam::CScriptBeam(TUniqueId uid, const std::string& name, const CEntityIn
{ {
} }
void CScriptBeam::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptBeam::Think(float dt, CStateManager& mgr) void CScriptBeam::Think(float dt, CStateManager& mgr)
{ {
#if 0 #if 0

View File

@ -18,6 +18,7 @@ public:
CScriptBeam(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, bool, CScriptBeam(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, bool,
const TToken<CWeaponDescription>&, const CBeamInfo&, const CDamageInfo&); const TToken<CWeaponDescription>&, const CBeamInfo&, const CDamageInfo&);
void Accept(IVisitor& visitor);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
}; };

View File

@ -1,4 +1,5 @@
#include "CScriptCameraBlurKeyframe.hpp" #include "CScriptCameraBlurKeyframe.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -7,4 +8,10 @@ CScriptCameraBlurKeyframe::CScriptCameraBlurKeyframe(TUniqueId uid, const std::s
: CEntity(uid, info, active, name) : CEntity(uid, info, active, name)
{ {
} }
void CScriptCameraBlurKeyframe::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -9,6 +9,8 @@ class CScriptCameraBlurKeyframe : public CEntity
{ {
public: public:
CScriptCameraBlurKeyframe(TUniqueId, const std::string&, const CEntityInfo&, u32, float, u32, float, float, bool); CScriptCameraBlurKeyframe(TUniqueId, const std::string&, const CEntityInfo&, u32, float, u32, float, float, bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,4 +1,5 @@
#include "CScriptCameraFilterKeyframe.hpp" #include "CScriptCameraFilterKeyframe.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -8,4 +9,10 @@ CScriptCameraFilterKeyframe::CScriptCameraFilterKeyframe(TUniqueId uid, const st
: CEntity(uid, info, active, name) : CEntity(uid, info, active, name)
{ {
} }
void CScriptCameraFilterKeyframe::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -20,6 +20,8 @@ class CScriptCameraFilterKeyframe : public CEntity
public: public:
CScriptCameraFilterKeyframe(TUniqueId, const std::string&, const CEntityInfo&, u32, u32, u32, u32, CScriptCameraFilterKeyframe(TUniqueId, const std::string&, const CEntityInfo&, u32, u32, u32, u32,
const zeus::CColor&, float, float, u32, bool); const zeus::CColor&, float, float, u32, bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,6 +1,7 @@
#include "CScriptCameraHint.hpp" #include "CScriptCameraHint.hpp"
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -13,4 +14,10 @@ CScriptCameraHint::CScriptCameraHint(TUniqueId uid, const std::string& name, con
CActorParameters::None(), kInvalidUniqueId) CActorParameters::None(), kInvalidUniqueId)
{ {
} }
void CScriptCameraHint::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -12,6 +12,8 @@ public:
CScriptCameraHint(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, bool, CScriptCameraHint(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, bool,
u32, u32, u32, float, float, float, const zeus::CVector3f&, const zeus::CVector3f&, u32, u32, u32, float, float, float, const zeus::CVector3f&, const zeus::CVector3f&,
const zeus::CVector3f&, float, float, float, float, float, float, float, float, float, float); const zeus::CVector3f&, float, float, float, float, float, float, float, float, float, float);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,5 +1,6 @@
#include "CScriptCameraHintTrigger.hpp" #include "CScriptCameraHintTrigger.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -15,4 +16,10 @@ CScriptCameraHintTrigger::CScriptCameraHintTrigger(TUniqueId uid, bool active, c
, x130_25_(b3) , x130_25_(b3)
{ {
} }
void CScriptCameraHintTrigger::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -24,6 +24,8 @@ class CScriptCameraHintTrigger : public CActor
public: public:
CScriptCameraHintTrigger(TUniqueId, bool, const std::string& name, const CEntityInfo&, const zeus::CVector3f&, CScriptCameraHintTrigger(TUniqueId, bool, const std::string& name, const CEntityInfo&, const zeus::CVector3f&,
const zeus::CTransform&, bool, bool); const zeus::CTransform&, bool, bool);
void Accept(IVisitor& visitor);
}; };
} }
#endif // __URDE_CSCRIPTCAMERAHINTTRIGGER_HPP__ #endif // __URDE_CSCRIPTCAMERAHINTTRIGGER_HPP__

View File

@ -4,6 +4,7 @@
#include "CPlayer.hpp" #include "CPlayer.hpp"
#include "Camera/CCameraManager.hpp" #include "Camera/CCameraManager.hpp"
#include "Camera/CFirstPersonCamera.hpp" #include "Camera/CFirstPersonCamera.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -23,6 +24,11 @@ CScriptCameraPitchVolume::CScriptCameraPitchVolume(TUniqueId uid, bool active, c
{ {
} }
void CScriptCameraPitchVolume::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptCameraPitchVolume::Think(float, CStateManager&) void CScriptCameraPitchVolume::Think(float, CStateManager&)
{ {
if (!x30_24_active) if (!x30_24_active)
@ -36,7 +42,7 @@ rstl::optional_object<zeus::CAABox> CScriptCameraPitchVolume::GetTouchBounds() c
void CScriptCameraPitchVolume::Touch(CActor& act, CStateManager& mgr) void CScriptCameraPitchVolume::Touch(CActor& act, CStateManager& mgr)
{ {
CPlayer* pl = dynamic_cast<CPlayer*>(&act); CPlayer* pl = TCastToPtr<CPlayer>(&act);
if (!pl) if (!pl)
return; return;

View File

@ -29,6 +29,7 @@ public:
CScriptCameraPitchVolume(TUniqueId, bool, const std::string&, const CEntityInfo&, const zeus::CVector3f&, CScriptCameraPitchVolume(TUniqueId, bool, const std::string&, const CEntityInfo&, const zeus::CVector3f&,
const zeus::CTransform&, const zeus::CRelAngle&, const zeus::CRelAngle&, float); const zeus::CTransform&, const zeus::CRelAngle&, const zeus::CRelAngle&, float);
void Accept(IVisitor& visitor);
void Think(float, CStateManager&); void Think(float, CStateManager&);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const; rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&); void Touch(CActor&, CStateManager&);

View File

@ -1,5 +1,6 @@
#include "CScriptCameraWaypoint.hpp" #include "CScriptCameraWaypoint.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -12,4 +13,9 @@ CScriptCameraWaypoint::CScriptCameraWaypoint(TUniqueId uid, const std::string& n
} }
void CScriptCameraWaypoint::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -11,6 +11,8 @@ class CScriptCameraWaypoint : public CActor
public: public:
CScriptCameraWaypoint(TUniqueId uid, const std::string& name, const CEntityInfo& info, CScriptCameraWaypoint(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CTransform& xf, bool active, float, u32); const zeus::CTransform& xf, bool active, float, u32);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,6 +1,8 @@
#include "CScriptColorModulate.hpp" #include "CScriptColorModulate.hpp"
#include "Graphics/CModel.hpp" #include "Graphics/CModel.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
CScriptColorModulate::CScriptColorModulate(TUniqueId uid, const std::string& name, const CEntityInfo& info, CScriptColorModulate::CScriptColorModulate(TUniqueId uid, const std::string& name, const CEntityInfo& info,
@ -22,6 +24,11 @@ CScriptColorModulate::CScriptColorModulate(TUniqueId uid, const std::string& nam
} }
void CScriptColorModulate::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptColorModulate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr) void CScriptColorModulate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr)
{ {
CEntity::AcceptScriptMsg(msg, objId, stateMgr); CEntity::AcceptScriptMsg(msg, objId, stateMgr);

View File

@ -44,6 +44,7 @@ public:
CScriptColorModulate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CColor&, const zeus::CColor&, CScriptColorModulate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CColor&, const zeus::CColor&,
EBlendMode, float, float, bool, bool, bool, bool, bool, bool); EBlendMode, float, float, bool, bool, bool, bool, bool, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
void Think(float, CStateManager &); void Think(float, CStateManager &);
zeus::CColor CalculateFlags(const zeus::CColor&) const; zeus::CColor CalculateFlags(const zeus::CColor&) const;

View File

@ -1,4 +1,5 @@
#include "CScriptCounter.hpp" #include "CScriptCounter.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -9,4 +10,9 @@ CScriptCounter::CScriptCounter(TUniqueId uid, const std::string& name, const CEn
{ {
} }
void CScriptCounter::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -11,6 +11,8 @@ class CScriptCounter : public CEntity
public: public:
CScriptCounter(TUniqueId, const std::string& name, const CEntityInfo& info, CScriptCounter(TUniqueId, const std::string& name, const CEntityInfo& info,
u32, u32, bool, bool); u32, u32, bool, bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,6 +1,7 @@
#include "CScriptCoverPoint.hpp" #include "CScriptCoverPoint.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -17,6 +18,11 @@ CScriptCoverPoint::CScriptCoverPoint(TUniqueId uid, const std::string &name, con
x100_touchBounds.emplace(xf.origin, xf.origin); x100_touchBounds.emplace(xf.origin, xf.origin);
} }
void CScriptCoverPoint::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptCoverPoint::Think(float delta, CStateManager&) void CScriptCoverPoint::Think(float delta, CStateManager&)
{ {
if (x11c_timeLeft <= 0.f) if (x11c_timeLeft <= 0.f)

View File

@ -38,6 +38,7 @@ public:
CScriptCoverPoint(TUniqueId uid, const std::string& name, const CEntityInfo& info, CScriptCoverPoint(TUniqueId uid, const std::string& name, const CEntityInfo& info,
zeus::CTransform xf, bool active, u32 flags, bool crouch, float horizontalAngle, float verticalAngle, float coverTime); zeus::CTransform xf, bool active, u32 flags, bool crouch, float horizontalAngle, float verticalAngle, float coverTime);
void Accept(IVisitor& visitor);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void AddToRenderer(const zeus::CFrustum &, CStateManager &) {} void AddToRenderer(const zeus::CFrustum &, CStateManager &) {}
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);

View File

@ -1,5 +1,6 @@
#include "CScriptDamageableTrigger.hpp" #include "CScriptDamageableTrigger.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -31,4 +32,9 @@ CScriptDamageableTrigger::CScriptDamageableTrigger(TUniqueId uid, const std::str
{ {
} }
void CScriptDamageableTrigger::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -20,6 +20,8 @@ public:
CScriptDamageableTrigger(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, const zeus::CVector3f&, CScriptDamageableTrigger(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, const zeus::CVector3f&,
const CHealthInfo&, const CDamageVulnerability&, u32, ResId, ResId, ResId, ECanOrbit, bool, const CHealthInfo&, const CDamageVulnerability&, u32, ResId, ResId, ResId, ECanOrbit, bool,
const CVisorParameters&); const CVisorParameters&);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,4 +1,5 @@
#include "CScriptDebris.hpp" #include "CScriptDebris.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -14,6 +15,11 @@ CScriptDebris::CScriptDebris(TUniqueId uid, const std::string& name, const CEnti
} }
void CScriptDebris::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
#if 0 #if 0
CScriptDebris::CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CScriptDebris::CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, float, float, float, float, float, float, float, float, float, const CActorParameters&, float, float, float, float, float, float, float, float, float,

View File

@ -22,6 +22,8 @@ public:
CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&, const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&,
const zeus::CColor&, float, float, float, EScaleType, bool, bool, bool); const zeus::CColor&, float, float, float, EScaleType, bool, bool, bool);
void Accept(IVisitor& visitor);
#if 0 #if 0
CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, float, float, float, float, float, float, float, float, float, const CActorParameters&, float, float, float, float, float, float, float, float, float,

View File

@ -1,6 +1,7 @@
#include "CScriptDistanceFog.hpp" #include "CScriptDistanceFog.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CWorld.hpp" #include "CWorld.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -28,6 +29,11 @@ CScriptDistanceFog::CScriptDistanceFog(TUniqueId uid, const std::string& name, c
x61_nonZero = true; x61_nonZero = true;
} }
void CScriptDistanceFog::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptDistanceFog::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CScriptDistanceFog::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
CEntity::AcceptScriptMsg(msg, objId, stateMgr); CEntity::AcceptScriptMsg(msg, objId, stateMgr);

View File

@ -24,6 +24,7 @@ public:
const zeus::CColor&, const zeus::CVector2f&, float, const zeus::CVector2f&, const zeus::CColor&, const zeus::CVector2f&, float, const zeus::CVector2f&,
bool, bool, float, float, float, float); bool, bool, float, float, float, float);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
}; };
} }

View File

@ -6,6 +6,7 @@
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CScriptDoor.hpp" #include "CScriptDoor.hpp"
#include "CPlayer.hpp" #include "CPlayer.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -31,6 +32,11 @@ CScriptDock::CScriptDock(TUniqueId uid, const std::string& name, const CEntityIn
{ {
} }
void CScriptDock::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptDock::Think(float dt, CStateManager& mgr) void CScriptDock::Think(float dt, CStateManager& mgr)
{ {
if (!GetActive()) if (!GetActive())

View File

@ -35,6 +35,7 @@ public:
CScriptDock(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f position, CScriptDock(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f position,
const zeus::CVector3f& extent, s32, TAreaId, bool active, s32 w1, bool b1); const zeus::CVector3f& extent, s32, TAreaId, bool active, s32 w1, bool b1);
void Accept(IVisitor& visitor);
void Think(float, CStateManager&); void Think(float, CStateManager&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const; rstl::optional_object<zeus::CAABox> GetTouchBounds() const;

View File

@ -1,6 +1,7 @@
#include "CScriptDockAreaChange.hpp" #include "CScriptDockAreaChange.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "World/CScriptDock.hpp" #include "World/CScriptDock.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -10,6 +11,11 @@ CScriptDockAreaChange::CScriptDockAreaChange(TUniqueId uid, const std::string& n
{ {
} }
void CScriptDockAreaChange::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptDockAreaChange::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CScriptDockAreaChange::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
if (msg == EScriptObjectMessage::Action && GetActive()) if (msg == EScriptObjectMessage::Action && GetActive())
@ -23,7 +29,7 @@ void CScriptDockAreaChange::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
for (auto it = search.first ; it != search.second ; ++it) for (auto it = search.first ; it != search.second ; ++it)
{ {
TUniqueId id = it->second; TUniqueId id = it->second;
CScriptDock* dock = dynamic_cast<CScriptDock*>(stateMgr.ObjectById(id)); CScriptDock* dock = TCastToPtr<CScriptDock>(stateMgr.ObjectById(id));
if (dock) if (dock)
dock->SetDockReference(stateMgr, x34_dockReference); dock->SetDockReference(stateMgr, x34_dockReference);
} }

View File

@ -11,6 +11,7 @@ class CScriptDockAreaChange : public CEntity
public: public:
CScriptDockAreaChange(TUniqueId, const std::string&, const CEntityInfo&, s32, bool); CScriptDockAreaChange(TUniqueId, const std::string&, const CEntityInfo&, s32, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
}; };
} }

View File

@ -8,6 +8,7 @@
#include "CWorld.hpp" #include "CWorld.hpp"
#include "Camera/CCameraManager.hpp" #include "Camera/CCameraManager.hpp"
#include "Camera/CBallCamera.hpp" #include "Camera/CBallCamera.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -45,6 +46,11 @@ CScriptDoor::CScriptDoor(TUniqueId uid, const std::string& name, const CEntityIn
SetMass(0.f); SetMass(0.f);
} }
void CScriptDoor::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
/* ORIGINAL 0-00 OFFSET: 8007F054 */ /* ORIGINAL 0-00 OFFSET: 8007F054 */
zeus::CVector3f CScriptDoor::GetOrbitPosition(const CStateManager& /*mgr*/) const zeus::CVector3f CScriptDoor::GetOrbitPosition(const CStateManager& /*mgr*/) const
{ {
@ -108,7 +114,7 @@ void CScriptDoor::ForceClosed(CStateManager & mgr)
/* ORIGINAL 0-00 OFFSET: 8007E1C4 */ /* ORIGINAL 0-00 OFFSET: 8007E1C4 */
bool CScriptDoor::IsConnectedToArea(const CStateManager& mgr, TAreaId area) bool CScriptDoor::IsConnectedToArea(const CStateManager& mgr, TAreaId area)
{ {
const CScriptDock* dock = dynamic_cast<const CScriptDock*>(mgr.GetObjectById(x282_dockId)); const CScriptDock* dock = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
if (dock) if (dock)
{ {
if (dock->GetDestinationAreaId() == area) if (dock->GetDestinationAreaId() == area)
@ -127,7 +133,7 @@ void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr)
TEditorId eid = mgr.GetEditorIdForUniqueId(uid); TEditorId eid = mgr.GetEditorIdForUniqueId(uid);
mgr.MapWorldInfo()->SetDoorVisited(eid, true); mgr.MapWorldInfo()->SetDoorVisited(eid, true);
const CScriptDoor* door = dynamic_cast<const CScriptDoor*>(mgr.GetObjectById(uid)); const CScriptDoor* door = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid));
if (door) if (door)
x27c_partner = door->GetUniqueId(); x27c_partner = door->GetUniqueId();
@ -146,7 +152,7 @@ void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr)
/* ORIGINAL 0-00 OFFSET: 8007ED4C */ /* ORIGINAL 0-00 OFFSET: 8007ED4C */
u32 CScriptDoor::GetDoorOpenCondition(CStateManager& mgr) u32 CScriptDoor::GetDoorOpenCondition(CStateManager& mgr)
{ {
const CScriptDock* dock = dynamic_cast<const CScriptDock*>(mgr.GetObjectById(x282_dockId)); const CScriptDock* dock = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
if (!dock) if (!dock)
return 2; return 2;

View File

@ -57,6 +57,7 @@ public:
bool active, bool open, bool, float, bool ballDoor); bool active, bool open, bool, float, bool ballDoor);
zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const; zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const;
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr);
void Think(float, CStateManager& mgr); void Think(float, CStateManager& mgr);
void AddToRenderer(const zeus::CFrustum&, CStateManager& mgr); void AddToRenderer(const zeus::CFrustum&, CStateManager& mgr);

View File

@ -2,6 +2,7 @@
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -16,4 +17,9 @@ CScriptEffect::CScriptEffect(TUniqueId uid, const std::string& name, const CEnti
{ {
} }
void CScriptEffect::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -14,6 +14,8 @@ public:
ResId partId, ResId elscId, bool, bool, bool, bool active, ResId partId, ResId elscId, bool, bool, bool, bool active,
bool, float, float, float, float, bool, float, float, float, bool, float, float, float, float, bool, float, float, float,
bool, bool, bool, const CLightParameters& lParms, bool); bool, bool, bool, const CLightParameters& lParms, bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,5 +1,6 @@
#include "CScriptGenerator.hpp" #include "CScriptGenerator.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -16,6 +17,11 @@ CScriptGenerator::CScriptGenerator(TUniqueId uid, const std::string& name, const
{ {
} }
void CScriptGenerator::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptGenerator::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CScriptGenerator::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
if (msg == EScriptObjectMessage::SetToZero && GetActive()) if (msg == EScriptObjectMessage::SetToZero && GetActive())

View File

@ -26,6 +26,7 @@ public:
CScriptGenerator(TUniqueId uid, const std::string& name, const CEntityInfo& info, u32, bool, const zeus::CVector3f&, CScriptGenerator(TUniqueId uid, const std::string& name, const CEntityInfo& info, u32, bool, const zeus::CVector3f&,
bool, bool, float, float); bool, bool, float, float);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
}; };
} }

View File

@ -2,6 +2,7 @@
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -16,4 +17,9 @@ CScriptGrapplePoint::CScriptGrapplePoint(TUniqueId uid, const std::string &name,
{ {
} }
void CScriptGrapplePoint::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -13,6 +13,8 @@ class CScriptGrapplePoint : public CActor
public: public:
CScriptGrapplePoint(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& transform, CScriptGrapplePoint(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& transform,
bool active, const CGrappleParameters& params); bool active, const CGrappleParameters& params);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,4 +1,5 @@
#include "CScriptHUDMemo.hpp" #include "CScriptHUDMemo.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -9,4 +10,9 @@ CScriptHUDMemo::CScriptHUDMemo(TUniqueId uid, const std::string& name, const CEn
{ {
} }
void CScriptHUDMemo::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -19,6 +19,8 @@ private:
public: public:
CScriptHUDMemo(TUniqueId, const std::string&, const CEntityInfo&, const CHUDMemoParms&, CScriptHUDMemo(TUniqueId, const std::string&, const CEntityInfo&, const CHUDMemoParms&,
CScriptHUDMemo::EDisplayType, ResId, bool); CScriptHUDMemo::EDisplayType, ResId, bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,6 +1,7 @@
#include "CScriptMemoryRelay.hpp" #include "CScriptMemoryRelay.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CRelayTracker.hpp" #include "CRelayTracker.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -13,6 +14,11 @@ CScriptMemoryRelay::CScriptMemoryRelay(TUniqueId uid, const std::string& name, c
{ {
} }
void CScriptMemoryRelay::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptMemoryRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr) void CScriptMemoryRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr)
{ {
if (x34_26_ignoreMessages) if (x34_26_ignoreMessages)

View File

@ -19,6 +19,7 @@ class CScriptMemoryRelay : public CEntity
}; };
public: public:
CScriptMemoryRelay(TUniqueId, const std::string& name, const CEntityInfo&, bool, bool, bool); CScriptMemoryRelay(TUniqueId, const std::string& name, const CEntityInfo&, bool, bool, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
}; };
} }

View File

@ -1,4 +1,5 @@
#include "CScriptPickup.hpp" #include "CScriptPickup.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -9,4 +10,10 @@ CScriptPickup::CScriptPickup(TUniqueId uid, const std::string& name, const CEnti
0.3f, 0.1f) 0.3f, 0.1f)
{ {
} }
void CScriptPickup::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -10,6 +10,8 @@ class CScriptPickup : public CPhysicsActor
public: public:
CScriptPickup(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CScriptPickup(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, const zeus::CAABox&, s32, s32, s32, s32, float, float, float, float, bool); const CActorParameters&, const zeus::CAABox&, s32, s32, s32, s32, float, float, float, float, bool);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -1,4 +1,5 @@
#include "CScriptPickupGenerator.hpp" #include "CScriptPickupGenerator.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -8,6 +9,11 @@ CScriptPickupGenerator::CScriptPickupGenerator(TUniqueId uid, const std::string&
{ {
} }
void CScriptPickupGenerator::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptPickupGenerator::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CScriptPickupGenerator::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
if (msg == EScriptObjectMessage::SetToZero && x30_24_active && x44_ != 100.f) if (msg == EScriptObjectMessage::SetToZero && x30_24_active && x44_ != 100.f)

View File

@ -15,6 +15,7 @@ class CScriptPickupGenerator : public CEntity
public: public:
CScriptPickupGenerator(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float, bool); CScriptPickupGenerator(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, float, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
}; };
} }

View File

@ -1,5 +1,6 @@
#include "CScriptPlatform.hpp" #include "CScriptPlatform.hpp"
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -24,4 +25,10 @@ CScriptPlatform::CScriptPlatform(TUniqueId uid, const std::string& name, const C
actParms, 0.3f, 0.1f) actParms, 0.3f, 0.1f)
{ {
} }
void CScriptPlatform::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -16,6 +16,8 @@ public:
CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float, bool, float, CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float, bool, float,
bool, const CHealthInfo& hInfo, const CDamageVulnerability& dInfo, bool, const CHealthInfo& hInfo, const CDamageVulnerability& dInfo,
const rstl::optional_object<TLockedToken<CCollidableOBBTreeGroup>>& dcln, bool, u32, u32); const rstl::optional_object<TLockedToken<CCollidableOBBTreeGroup>>& dcln, bool, u32, u32);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -2,6 +2,7 @@
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CPlayerState.hpp" #include "CPlayerState.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -15,6 +16,11 @@ CScriptPointOfInterest::CScriptPointOfInterest(TUniqueId uid, const std::string&
{ {
} }
void CScriptPointOfInterest::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptPointOfInterest::Think(float dt, CStateManager& mgr) void CScriptPointOfInterest::Think(float dt, CStateManager& mgr)
{ {
xe7_31_ = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan; xe7_31_ = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan;

View File

@ -14,6 +14,7 @@ public:
CScriptPointOfInterest(TUniqueId, const std::string&, const CEntityInfo, const zeus::CTransform&, bool, CScriptPointOfInterest(TUniqueId, const std::string&, const CEntityInfo, const zeus::CTransform&, bool,
const CScannableParameters&, float); const CScannableParameters&, float);
void Accept(IVisitor& visitor);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
void AddToRenderer(const zeus::CFrustum &, const CStateManager &) const; void AddToRenderer(const zeus::CFrustum &, const CStateManager &) const;

View File

@ -1,5 +1,6 @@
#include "CScriptRandomRelay.hpp" #include "CScriptRandomRelay.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -12,6 +13,11 @@ CScriptRandomRelay::CScriptRandomRelay(TUniqueId uid, const std::string& name, c
{ {
} }
void CScriptRandomRelay::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptRandomRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CScriptRandomRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
CEntity::AcceptScriptMsg(msg, objId, stateMgr); CEntity::AcceptScriptMsg(msg, objId, stateMgr);

View File

@ -13,6 +13,7 @@ class CScriptRandomRelay : public CEntity
public: public:
CScriptRandomRelay(TUniqueId, const std::string&, const CEntityInfo&, s32, s32, bool, bool); CScriptRandomRelay(TUniqueId, const std::string&, const CEntityInfo&, s32, s32, bool, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
void SendLocalScriptMsgs(EScriptObjectState state, CStateManager& stateMgr); void SendLocalScriptMsgs(EScriptObjectState state, CStateManager& stateMgr);
}; };

View File

@ -1,5 +1,6 @@
#include "CScriptRelay.hpp" #include "CScriptRelay.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -9,6 +10,11 @@ CScriptRelay::CScriptRelay(TUniqueId uid, const std::string& name, const CEntity
{ {
} }
void CScriptRelay::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr) void CScriptRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr)
{ {
CEntity::AcceptScriptMsg(msg, objId, stateMgr); CEntity::AcceptScriptMsg(msg, objId, stateMgr);
@ -66,7 +72,7 @@ void CScriptRelay::UpdateObjectRef(CStateManager& stateMgr)
*tmp = x34_; *tmp = x34_;
return; return;
} }
const CScriptRelay* obj = dynamic_cast<const CScriptRelay*>(stateMgr.GetObjectById(*tmp)); const CScriptRelay* obj = TCastToConstPtr<CScriptRelay>(stateMgr.GetObjectById(*tmp));
if (obj) if (obj)
tmp = (TUniqueId*)&obj->x34_; tmp = (TUniqueId*)&obj->x34_;
} }

View File

@ -12,6 +12,7 @@ class CScriptRelay : public CEntity
public: public:
CScriptRelay(TUniqueId, const std::string&, const CEntityInfo&, bool); CScriptRelay(TUniqueId, const std::string&, const CEntityInfo&, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
void Think(float, CStateManager& stateMgr); void Think(float, CStateManager& stateMgr);
void UpdateObjectRef(CStateManager& stateMgr); void UpdateObjectRef(CStateManager& stateMgr);

View File

@ -2,6 +2,7 @@
#include "World/CActorParameters.hpp" #include "World/CActorParameters.hpp"
#include "World/CProjectedShadow.hpp" #include "World/CProjectedShadow.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -22,6 +23,11 @@ CScriptShadowProjector::CScriptShadowProjector(TUniqueId uid, const std::string&
{ {
} }
void CScriptShadowProjector::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptShadowProjector::Think(float dt, CStateManager& mgr) void CScriptShadowProjector::Think(float dt, CStateManager& mgr)
{ {
if (GetActive() && x110_25_shadowInvalidated) if (GetActive() && x110_25_shadowInvalidated)
@ -65,7 +71,7 @@ void CScriptShadowProjector::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
if (conn.x0_state != EScriptObjectState::Play) if (conn.x0_state != EScriptObjectState::Play)
continue; continue;
const CActor* act = dynamic_cast<const CActor*>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))); const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)));
if (!act) if (!act)
continue; continue;
const CModelData* mData = act->GetModelData(); const CModelData* mData = act->GetModelData();

View File

@ -30,6 +30,7 @@ public:
CScriptShadowProjector(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, bool, CScriptShadowProjector(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, bool,
const zeus::CVector3f&, bool, float, float, float, float, s32); const zeus::CVector3f&, bool, float, float, float, float, s32);
void Accept(IVisitor& visitor);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
void PreRender(const zeus::CFrustum &, const CStateManager &); void PreRender(const zeus::CFrustum &, const CStateManager &);

View File

@ -2,6 +2,7 @@
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -14,4 +15,9 @@ CScriptSound::CScriptSound(TUniqueId uid, const std::string& name, const CEntity
{ {
} }
void CScriptSound::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -12,6 +12,8 @@ public:
CScriptSound(TUniqueId, const std::string& name, const CEntityInfo& info, CScriptSound(TUniqueId, const std::string& name, const CEntityInfo& info,
const zeus::CTransform& xf, s16 soundId, bool, float, float, float, const zeus::CTransform& xf, s16 soundId, bool, float, float, float,
u32, u32, u32, u32, u32, bool, bool, bool, bool, bool, bool, bool, bool, u32); u32, u32, u32, u32, u32, bool, bool, bool, bool, bool, bool, bool, bool, u32);
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -2,6 +2,7 @@
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CWorld.hpp" #include "CWorld.hpp"
#include "CPlayer.hpp" #include "CPlayer.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -15,6 +16,11 @@ CScriptSpawnPoint::CScriptSpawnPoint(TUniqueId uid, const std::string& name, con
x10c_25_morphed = morphed; x10c_25_morphed = morphed;
} }
void CScriptSpawnPoint::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptSpawnPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) void CScriptSpawnPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{ {
CEntity::AcceptScriptMsg(msg, objId, stateMgr); CEntity::AcceptScriptMsg(msg, objId, stateMgr);

View File

@ -26,6 +26,7 @@ public:
const zeus::CTransform& xf, const std::vector<u32>& itemCounts, const zeus::CTransform& xf, const std::vector<u32>& itemCounts,
bool, bool, bool); bool, bool, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
bool FirstSpawn() const { return x10c_24_firstSpawn; } bool FirstSpawn() const { return x10c_24_firstSpawn; }
const zeus::CTransform& GetTransform() const { return x34_xf; } const zeus::CTransform& GetTransform() const { return x34_xf; }

View File

@ -2,6 +2,7 @@
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "Audio/CSfxManager.hpp" #include "Audio/CSfxManager.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -35,6 +36,11 @@ CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, const std::string&
x1c8_ = {{zeus::CVector3f(-1.f), zeus::CVector3f(1.f)}}; x1c8_ = {{zeus::CVector3f(-1.f), zeus::CVector3f(1.f)}};
} }
void CScriptSpecialFunction::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptSpecialFunction::Think(float, CStateManager &) void CScriptSpecialFunction::Think(float, CStateManager &)
{ {

View File

@ -113,6 +113,7 @@ public:
const std::string&, float, float, float, float, const zeus::CVector3f&, const zeus::CColor&, const std::string&, float, float, float, float, const zeus::CVector3f&, const zeus::CColor&,
bool, const CDamageInfo&, ResId, ResId, ResId, s16, s16, s16); bool, const CDamageInfo&, ResId, ResId, ResId, s16, s16, s16);
void Accept(IVisitor& visitor);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
void PreRender(const zeus::CFrustum &, const CStateManager &); void PreRender(const zeus::CFrustum &, const CStateManager &);

View File

@ -0,0 +1,45 @@
#include "CScriptStreamedMusic.hpp"
#include "CStringExtras.hpp"
#include "TCastTo.hpp"
namespace urde
{
bool CScriptStreamedMusic::ValidateFileName(const std::string& fileName)
{
if (!CStringExtras::CompareCaseInsensitive(fileName, "sw"))
return true;
if (CStringExtras::IndexOfSubstring(fileName, ".dsp") != -1)
return true;
return false;
}
CScriptStreamedMusic::CScriptStreamedMusic(TUniqueId id, const CEntityInfo& info, const std::string& name,
bool active, const std::string& fileName, bool b1, float f1, float f2,
u32 w1, bool b2, bool b3)
: CEntity(id, info, active, name), x34_fileName(fileName), x44_b1(b1),
x45_fileNameValid(ValidateFileName(fileName)), x46_b2(b2), x47_b3(b3),
x48_f1(f1), x4c_f2(f2), x50_w1(w1) {}
void CScriptStreamedMusic::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CScriptStreamedMusic::PreThink(float, CStateManager&)
{
}
void CScriptStreamedMusic::Think(float, CStateManager&)
{
}
void CScriptStreamedMusic::AcceptScriptMsg(EScriptObjectMessage msg,
TUniqueId objId, CStateManager& stateMgr)
{
}
}

Some files were not shown because too many files have changed in this diff Show More