This commit is contained in:
Jack Andersen 2017-01-15 07:51:01 -10:00
commit 7db63f3663
39 changed files with 707 additions and 448 deletions

View File

@ -4,54 +4,54 @@ namespace urde
{ {
CObjectList::CObjectList(EGameObjectList listEnum) CObjectList::CObjectList(EGameObjectList listEnum)
: m_listEnum(listEnum) : x2004_listEnum(listEnum)
{} {}
void CObjectList::AddObject(CEntity& entity) void CObjectList::AddObject(CEntity& entity)
{ {
if (IsQualified(entity)) if (IsQualified(entity))
{ {
if (m_firstId != -1) if (x2008_firstId != -1)
m_list[m_firstId].prev = entity.GetUniqueId() & 0x3ff; x0_list[x2008_firstId].prev = entity.GetUniqueId() & 0x3ff;
TUniqueId prevFirst = m_firstId; TUniqueId prevFirst = x2008_firstId;
m_firstId = entity.GetUniqueId() & 0x3ff; x2008_firstId = entity.GetUniqueId() & 0x3ff;
SObjectListEntry& newEnt = m_list[m_firstId]; SObjectListEntry& newEnt = x0_list[x2008_firstId];
newEnt.entity = &entity; newEnt.entity = &entity;
newEnt.next = prevFirst; newEnt.next = prevFirst;
newEnt.prev = -1; newEnt.prev = -1;
++m_count; ++x200a_count;
} }
} }
void CObjectList::RemoveObject(TUniqueId uid) void CObjectList::RemoveObject(TUniqueId uid)
{ {
uid = uid & 0x3ff; uid = uid & 0x3ff;
SObjectListEntry& ent = m_list[uid]; SObjectListEntry& ent = x0_list[uid];
if (!ent.entity || ent.entity->GetUniqueId() != uid) if (!ent.entity || ent.entity->GetUniqueId() != uid)
return; return;
if (uid == m_firstId) if (uid == x2008_firstId)
{ {
m_firstId = ent.next; x2008_firstId = ent.next;
if (ent.next != -1) if (ent.next != -1)
m_list[ent.next].prev = -1; x0_list[ent.next].prev = -1;
} }
else else
{ {
if (ent.next != -1) if (ent.next != -1)
m_list[ent.next].prev = -1; x0_list[ent.next].prev = -1;
m_list[ent.prev].next = -1; x0_list[ent.prev].next = -1;
} }
ent.entity = nullptr; ent.entity = nullptr;
ent.next = -1; ent.next = -1;
ent.prev = -1; ent.prev = -1;
--m_count; --x200a_count;
} }
const CEntity* CObjectList::GetObjectById(TUniqueId uid) const const CEntity* CObjectList::GetObjectById(TUniqueId uid) const
{ {
if (!uid) if (!uid)
return nullptr; return nullptr;
const SObjectListEntry& ent = m_list[uid & 0x3ff]; const SObjectListEntry& ent = x0_list[uid & 0x3ff];
if (ent.entity->x30_26_scriptingBlocked) if (ent.entity->x30_26_scriptingBlocked)
return nullptr; return nullptr;
return ent.entity; return ent.entity;
@ -61,7 +61,7 @@ CEntity* CObjectList::GetObjectById(TUniqueId uid)
{ {
if (!uid) if (!uid)
return nullptr; return nullptr;
SObjectListEntry& ent = m_list[uid & 0x3ff]; SObjectListEntry& ent = x0_list[uid & 0x3ff];
if (ent.entity->x30_26_scriptingBlocked) if (ent.entity->x30_26_scriptingBlocked)
return nullptr; return nullptr;
return ent.entity; return ent.entity;

View File

@ -27,14 +27,13 @@ class CObjectList
struct SObjectListEntry struct SObjectListEntry
{ {
CEntity* entity = nullptr; CEntity* entity = nullptr;
TUniqueId next = -1; TUniqueId next = kInvalidUniqueId;
TUniqueId prev = -1; TUniqueId prev = kInvalidUniqueId;
}; };
SObjectListEntry m_list[1024]; SObjectListEntry x0_list[1024];
EGameObjectList m_listEnum; EGameObjectList x2004_listEnum;
TUniqueId m_firstId = kInvalidUniqueId; TUniqueId x2008_firstId = kInvalidUniqueId;
u16 m_count = 0; u16 x200a_count = 0;
int m_areaIdx = 0;
public: public:
class iterator class iterator
{ {
@ -47,7 +46,7 @@ public:
bool operator!=(const iterator& other) const { return m_id != other.m_id; } bool operator!=(const iterator& other) const { return m_id != other.m_id; }
CEntity* operator*() const { return m_list.GetObjectById(m_id); } CEntity* operator*() const { return m_list.GetObjectById(m_id); }
}; };
iterator begin() { return iterator(*this, m_firstId); } iterator begin() { return iterator(*this, x2008_firstId); }
iterator end() { return iterator(*this, kInvalidUniqueId); } iterator end() { return iterator(*this, kInvalidUniqueId); }
CObjectList(EGameObjectList listEnum); CObjectList(EGameObjectList listEnum);
@ -55,9 +54,10 @@ public:
void AddObject(CEntity& entity); void AddObject(CEntity& entity);
void RemoveObject(TUniqueId uid); void RemoveObject(TUniqueId uid);
const CEntity* GetObjectById(TUniqueId uid) const; const CEntity* GetObjectById(TUniqueId uid) const;
const CEntity* GetObjectByIndex(s32 index) const { return x0_list[index].entity; }
CEntity* GetObjectById(TUniqueId uid); CEntity* GetObjectById(TUniqueId uid);
TUniqueId GetFirstObjectIndex() const { return m_firstId; } TUniqueId GetFirstObjectIndex() const { return x2008_firstId; }
TUniqueId GetNextObjectIndex(TUniqueId prev) const { return m_list[prev].next; } TUniqueId GetNextObjectIndex(TUniqueId prev) const { return x0_list[prev & 0x3ff].next; }
virtual bool IsQualified(const CEntity&); virtual bool IsQualified(const CEntity&);
}; };

View File

@ -181,7 +181,7 @@ CHealthInfo& CPlayerState::HealthInfo()
return xc_health; return xc_health;
} }
CHealthInfo CPlayerState::GetHealthInfo() const const CHealthInfo& CPlayerState::GetHealthInfo() const
{ {
return xc_health; return xc_health;
} }

View File

@ -134,7 +134,7 @@ public:
u32 CalculateItemCollectionRate() const; u32 CalculateItemCollectionRate() const;
CHealthInfo& HealthInfo(); CHealthInfo& HealthInfo();
CHealthInfo GetHealthInfo() const; const CHealthInfo &GetHealthInfo() const;
u32 GetPickupTotal() { return 99; } u32 GetPickupTotal() { return 99; }
void SetIsFusionEnabled(bool val) { x0_26_fusion = val; } void SetIsFusionEnabled(bool val) { x0_26_fusion = val; }
bool IsFusionEnabled() const { return x0_26_fusion; } bool IsFusionEnabled() const { return x0_26_fusion; }

View File

@ -1,4 +1,5 @@
#include "CSortedLists.hpp" #include "CSortedLists.hpp"
#include "World/CActor.hpp"
namespace urde namespace urde
{ {
@ -20,9 +21,19 @@ void CSortedListManager::RemoveFromList(ESortedList list, s16 id)
SSortedList& sl = xb000_sortedLists[u32(list)]; SSortedList& sl = xb000_sortedLists[u32(list)];
} }
void CSortedListManager::Remove(const CActor *) void CSortedListManager::Remove(const CActor* act)
{ {
SNode& node = x0_nodes[act->GetUniqueId() & 0x3ff];
if (node.x2a_full == false)
return;
RemoveFromList(ESortedList::Zero, node.x1c_);
RemoveFromList(ESortedList::Three, node.x22_);
RemoveFromList(ESortedList::One, node.x1e_);
RemoveFromList(ESortedList::Four, node.x24_);
RemoveFromList(ESortedList::Two, node.x20_);
RemoveFromList(ESortedList::Five, node.x26_);
node.x2a_full = false;
} }
} }

View File

@ -20,7 +20,7 @@ struct SSortedList
{ {
TUniqueId x0_ids[1024]; TUniqueId x0_ids[1024];
u32 x800_; u32 x800_;
void Reset() {std::fill(std::begin(x0_ids), std::end(x0_ids), -1);} void Reset() {std::fill(std::begin(x0_ids), std::end(x0_ids), kInvalidUniqueId);}
SSortedList() {Reset();} SSortedList() {Reset();}
}; };
@ -31,11 +31,14 @@ class CSortedListManager
{ {
u32 x0_ = 0; u32 x0_ = 0;
zeus::CAABox x4_box = zeus::CAABox::skNullBox; zeus::CAABox x4_box = zeus::CAABox::skNullBox;
u32 x1c_; u16 x1c_;
u32 x20_; u16 x1e_;
u32 x24_; u16 x20_;
u32 x28_ = -1; u16 x22_;
bool x2a_ = false; u16 x24_;
u16 x26_;
u16 x28_ = -1;
bool x2a_full = false;
}; };
SNode x0_nodes[1024]; SNode x0_nodes[1024];
SSortedList xb000_sortedLists[6]; SSortedList xb000_sortedLists[6];

View File

@ -29,25 +29,24 @@
namespace urde namespace urde
{ {
logvisor::Module LogModule("urde::CStateManager");
CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker, CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
const std::weak_ptr<CMapWorldInfo>& mwInfo, const std::weak_ptr<CMapWorldInfo>& mwInfo, const std::weak_ptr<CPlayerState>& playerState,
const std::weak_ptr<CPlayerState>& playerState,
const std::weak_ptr<CWorldTransManager>& wtMgr, const std::weak_ptr<CWorldTransManager>& wtMgr,
const std::weak_ptr<CWorldLayerState>& layerState) const std::weak_ptr<CWorldLayerState>& layerState)
: x80c_allObjs(new CObjectList(EGameObjectList::All)), : x80c_allObjs(new CObjectList(EGameObjectList::All))
x814_actorObjs(new CActorList()), , x814_actorObjs(new CActorList())
x81c_physActorObjs(new CPhysicsActorList()), , x81c_physActorObjs(new CPhysicsActorList())
x824_cameraObjs(new CGameCameraList()), , x824_cameraObjs(new CGameCameraList())
x82c_lightObjs(new CGameLightList()), , x82c_lightObjs(new CGameLightList())
x834_listenAiObjs(new CListeningAiList()), , x834_listenAiObjs(new CListeningAiList())
x83c_aiWaypointObjs(new CAiWaypointList()), , x83c_aiWaypointObjs(new CAiWaypointList())
x844_platformAndDoorObjs(new CPlatformAndDoorList()), , x844_platformAndDoorObjs(new CPlatformAndDoorList())
x8b8_playerState(playerState), , x8b8_playerState(playerState)
x8bc_relayTracker(relayTracker), , x8bc_relayTracker(relayTracker)
x8c0_mapWorldInfo(mwInfo), , x8c0_mapWorldInfo(mwInfo)
x8c4_worldTransManager(wtMgr), , x8c4_worldTransManager(wtMgr)
x8c8_worldLayerState(layerState) , x8c8_worldLayerState(layerState)
{ {
x86c_stateManagerContainer.reset(new CStateManagerContainer); x86c_stateManagerContainer.reset(new CStateManagerContainer);
x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager; x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager;
@ -100,7 +99,8 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
x90c_loaderFuncs[int(EScriptObjectType::GrapplePoint)] = ScriptLoader::LoadGrapplePoint; x90c_loaderFuncs[int(EScriptObjectType::GrapplePoint)] = ScriptLoader::LoadGrapplePoint;
x90c_loaderFuncs[int(EScriptObjectType::PuddleSpore)] = ScriptLoader::LoadPuddleSpore; x90c_loaderFuncs[int(EScriptObjectType::PuddleSpore)] = ScriptLoader::LoadPuddleSpore;
x90c_loaderFuncs[int(EScriptObjectType::DebugCameraWaypoint)] = ScriptLoader::LoadDebugCameraWaypoint; x90c_loaderFuncs[int(EScriptObjectType::DebugCameraWaypoint)] = ScriptLoader::LoadDebugCameraWaypoint;
x90c_loaderFuncs[int(EScriptObjectType::SpiderBallAttractionSurface)] = ScriptLoader::LoadSpiderBallAttractionSurface; x90c_loaderFuncs[int(EScriptObjectType::SpiderBallAttractionSurface)] =
ScriptLoader::LoadSpiderBallAttractionSurface;
x90c_loaderFuncs[int(EScriptObjectType::PuddleToadGamma)] = ScriptLoader::LoadPuddleToadGamma; x90c_loaderFuncs[int(EScriptObjectType::PuddleToadGamma)] = ScriptLoader::LoadPuddleToadGamma;
x90c_loaderFuncs[int(EScriptObjectType::DistanceFog)] = ScriptLoader::LoadDistanceFog; x90c_loaderFuncs[int(EScriptObjectType::DistanceFog)] = ScriptLoader::LoadDistanceFog;
x90c_loaderFuncs[int(EScriptObjectType::FireFlea)] = ScriptLoader::LoadFireFlea; x90c_loaderFuncs[int(EScriptObjectType::FireFlea)] = ScriptLoader::LoadFireFlea;
@ -144,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::LoadStreamedMusic; x90c_loaderFuncs[int(EScriptObjectType::StreamedAudio)] = ScriptLoader::LoadStreamedAudio;
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;
@ -203,7 +203,8 @@ void CStateManager::UpdateThermalVisor()
for (const CGameArea::Dock& dock : area->GetDocks()) for (const CGameArea::Dock& dock : area->GetDocks())
{ {
zeus::CVector3f dockCenter = (dock.GetPlaneVertices()[0] + dock.GetPlaneVertices()[1] + zeus::CVector3f dockCenter = (dock.GetPlaneVertices()[0] + dock.GetPlaneVertices()[1] +
dock.GetPlaneVertices()[2] + dock.GetPlaneVertices()[3]) * 0.25f; dock.GetPlaneVertices()[2] + dock.GetPlaneVertices()[3]) *
0.25f;
dockCenter.z = 0.f; dockCenter.z = 0.f;
float dist = (playerXYPos - dockCenter).magSquared(); float dist = (playerXYPos - dockCenter).magSquared();
if (dist < closestDist) if (dist < closestDist)
@ -237,8 +238,7 @@ void CStateManager::UpdateThermalVisor()
else else
closestDist = 0.5f; closestDist = 0.5f;
xf24_thermColdScale1 = xf24_thermColdScale1 = (1.f - closestDist) * lastArea->GetPostConstructed()->x111c_thermalCurrent +
(1.f - closestDist) * lastArea->GetPostConstructed()->x111c_thermalCurrent +
closestDist * area->GetPostConstructed()->x111c_thermalCurrent; closestDist * area->GetPostConstructed()->x111c_thermalCurrent;
return; return;
} }
@ -248,12 +248,10 @@ void CStateManager::UpdateThermalVisor()
} }
} }
bool CStateManager::RenderLast(TUniqueId) bool CStateManager::RenderLast(TUniqueId) { return false; }
{
return false;
}
void CStateManager::AddDrawableActorPlane(const CActor& actor, const zeus::CPlane& plane, const zeus::CAABox& aabb) const void CStateManager::AddDrawableActorPlane(const CActor& actor, const zeus::CPlane& plane,
const zeus::CAABox& aabb) const
{ {
#if 0 #if 0
actor.SetAddedToken(x8dc_ + 1); actor.SetAddedToken(x8dc_ + 1);
@ -261,8 +259,7 @@ void CStateManager::AddDrawableActorPlane(const CActor& actor, const zeus::CPlan
g_Renderer->AddPlaneObject(static_cast<const void*>(&actor), aabb, plane, 0); g_Renderer->AddPlaneObject(static_cast<const void*>(&actor), aabb, plane, 0);
} }
void CStateManager::AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, void CStateManager::AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const
const zeus::CAABox& aabb) const
{ {
#if 0 #if 0
actor.SetAddedToken(x8dc_ + 1); actor.SetAddedToken(x8dc_ + 1);
@ -271,59 +268,40 @@ void CStateManager::AddDrawableActor(const CActor& actor, const zeus::CVector3f&
IRenderer::EDrawableSorting::SortedCallback); IRenderer::EDrawableSorting::SortedCallback);
} }
void CStateManager::SpecialSkipCinematic() void CStateManager::SpecialSkipCinematic() {}
void CStateManager::GetVisAreaId() const {}
void CStateManager::GetWeaponIdCount(TUniqueId, EWeaponType) {}
void CStateManager::RemoveWeaponId(TUniqueId, EWeaponType) {}
void CStateManager::AddWeaponId(TUniqueId, EWeaponType) {}
void CStateManager::UpdateEscapeSequenceTimer(float) {}
float CStateManager::GetEscapeSequenceTimer() const { return 0.f; }
void CStateManager::ResetEscapeSequenceTimer(float) {}
void CStateManager::SetupParticleHook(const CActor& actor) const {}
void CStateManager::MurderScriptInstanceNames() {}
std::string CStateManager::HashInstanceName(CInputStream& in)
{ {
#ifdef NDEBUG
static std::string name;
while (in.readByte() != 0) {};
return name;
#else
return in.readString();
#endif
} }
void CStateManager::GetVisAreaId() const void CStateManager::SetActorAreaId(CActor& actor, TAreaId) {}
{
}
void CStateManager::GetWeaponIdCount(TUniqueId, EWeaponType) void CStateManager::TouchSky() const {}
{
}
void CStateManager::RemoveWeaponId(TUniqueId, EWeaponType)
{
}
void CStateManager::AddWeaponId(TUniqueId, EWeaponType)
{
}
void CStateManager::UpdateEscapeSequenceTimer(float)
{
}
float CStateManager::GetEscapeSequenceTimer() const
{
return 0.f;
}
void CStateManager::ResetEscapeSequenceTimer(float)
{
}
void CStateManager::SetupParticleHook(const CActor& actor) const
{
}
void CStateManager::MurderScriptInstanceNames()
{
}
const std::string* CStateManager::HashInstanceName(CInputStream& in)
{
return nullptr;
}
void CStateManager::SetActorAreaId(CActor& actor, TAreaId)
{
}
void CStateManager::TouchSky() const
{
}
void CStateManager::TouchPlayerActor() void CStateManager::TouchPlayerActor()
{ {
@ -347,63 +325,33 @@ void CStateManager::DrawSpaceWarp(const zeus::CVector3f& v, float strength) cons
} }
} }
void CStateManager::DrawReflection(const zeus::CVector3f&) void CStateManager::DrawReflection(const zeus::CVector3f&) {}
{
}
void CStateManager::CacheReflection() void CStateManager::CacheReflection() {}
{
}
bool CStateManager::CanCreateProjectile(TUniqueId, EWeaponType, int) const bool CStateManager::CanCreateProjectile(TUniqueId, EWeaponType, int) const { return false; }
{
return false;
}
const CGameLightList* CStateManager::GetDynamicLightList() const const CGameLightList* CStateManager::GetDynamicLightList() const { return nullptr; }
{
return nullptr;
}
void CStateManager::BuildDynamicLightListForWorld(std::vector<CLight>& listOut) const void CStateManager::BuildDynamicLightListForWorld(std::vector<CLight>& listOut) const {}
{
}
void CStateManager::DrawDebugStuff() const void CStateManager::DrawDebugStuff() const {}
{
}
void CStateManager::RenderCamerasAndAreaLights() const void CStateManager::RenderCamerasAndAreaLights() const {}
{
}
void CStateManager::DrawE3DeathEffect() const void CStateManager::DrawE3DeathEffect() const {}
{
}
void CStateManager::DrawAdditionalFilters() const void CStateManager::DrawAdditionalFilters() const {}
{
}
void CStateManager::DrawWorld() const void CStateManager::DrawWorld() const {}
{
}
void CStateManager::SetupFogForArea(const CGameArea& area) const void CStateManager::SetupFogForArea(const CGameArea& area) const {}
{
}
void CStateManager::PreRender() void CStateManager::PreRender() {}
{
}
void CStateManager::GetVisSetForArea(TAreaId, TAreaId) const void CStateManager::GetVisSetForArea(TAreaId, TAreaId) const {}
{
}
void CStateManager::RecursiveDrawTree(TUniqueId) const void CStateManager::RecursiveDrawTree(TUniqueId) const {}
{
}
void CStateManager::SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMessage msg) void CStateManager::SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMessage msg)
{ {
@ -426,14 +374,11 @@ void CStateManager::SendScriptMsgAlways(TUniqueId dest, TUniqueId src, EScriptOb
dst->AcceptScriptMsg(msg, src, *this); dst->AcceptScriptMsg(msg, src, *this);
} }
void CStateManager::SendScriptMsg(TUniqueId src, TEditorId dest, void CStateManager::SendScriptMsg(TUniqueId src, TEditorId dest, EScriptObjectMessage msg, EScriptObjectState state)
EScriptObjectMessage msg, EScriptObjectState state)
{ {
CEntity* ent = ObjectById(src); CEntity* ent = ObjectById(src);
auto search = GetIdListForScript(dest); auto search = GetIdListForScript(dest);
if (ent && if (ent && search.first != x890_scriptIdMap.cend() && search.second != x890_scriptIdMap.cend())
search.first != x890_scriptIdMap.cend() &&
search.second != x890_scriptIdMap.cend())
{ {
for (auto it = search.first; it != search.second; ++it) for (auto it = search.first; it != search.second; ++it)
{ {
@ -444,39 +389,23 @@ void CStateManager::SendScriptMsg(TUniqueId src, TEditorId dest,
} }
} }
void CStateManager::FreeScriptObjects(TAreaId) void CStateManager::FreeScriptObjects(TAreaId) {}
{
}
void CStateManager::GetBuildForScript(TEditorId) const void CStateManager::GetBuildForScript(TEditorId) const {}
{
}
TEditorId CStateManager::GetEditorIdForUniqueId(TUniqueId) const TEditorId CStateManager::GetEditorIdForUniqueId(TUniqueId) const { return 0; }
{
return 0;
}
TUniqueId CStateManager::GetIdForScript(TEditorId) const TUniqueId CStateManager::GetIdForScript(TEditorId) const { return kInvalidUniqueId; }
{
return 0;
}
std::pair<std::multimap<TEditorId, TUniqueId>::const_iterator, std::pair<std::multimap<TEditorId, TUniqueId>::const_iterator, std::multimap<TEditorId, TUniqueId>::const_iterator>
std::multimap<TEditorId, TUniqueId>::const_iterator>
CStateManager::GetIdListForScript(TEditorId id) const CStateManager::GetIdListForScript(TEditorId id) const
{ {
return x890_scriptIdMap.equal_range(id); return x890_scriptIdMap.equal_range(id);
} }
void CStateManager::LoadScriptObjects(TAreaId aid, CInputStream& in, std::vector<TEditorId>& idsOut) void CStateManager::LoadScriptObjects(TAreaId aid, CInputStream& in, std::vector<TEditorId>& idsOut) {}
{
}
void CStateManager::LoadScriptObject(TAreaId, EScriptObjectType, u32, void CStateManager::LoadScriptObject(TAreaId, EScriptObjectType, u32, CInputStream& in) {}
CInputStream& in)
{
}
void CStateManager::InitScriptObjects(std::vector<TEditorId>& ids) void CStateManager::InitScriptObjects(std::vector<TEditorId>& ids)
{ {
@ -490,29 +419,26 @@ void CStateManager::InitScriptObjects(std::vector<TEditorId>& ids)
MurderScriptInstanceNames(); MurderScriptInstanceNames();
} }
void CStateManager::InformListeners(const zeus::CVector3f&, EListenNoiseType) void CStateManager::InformListeners(const zeus::CVector3f&, EListenNoiseType) {}
{
}
bool CStateManager::ApplyKnockBack(CActor& actor, const CDamageInfo& info, bool CStateManager::ApplyKnockBack(CActor& actor, const CDamageInfo& info, const CDamageVulnerability&,
const CDamageVulnerability&, const zeus::CVector3f&, float) const zeus::CVector3f&, float)
{ {
return false; return false;
} }
bool CStateManager::ApplyDamageToWorld(TUniqueId, const CActor&, const zeus::CVector3f&, bool CStateManager::ApplyDamageToWorld(TUniqueId, const CActor&, const zeus::CVector3f&, const CDamageInfo& info,
const CDamageInfo& info, const CMaterialFilter&) const CMaterialFilter&)
{ {
return false; return false;
} }
void CStateManager::ProcessRadiusDamage(const CActor&, CActor&, const zeus::CVector3f&, void CStateManager::ProcessRadiusDamage(const CActor&, CActor&, const zeus::CVector3f&, const CDamageInfo& info,
const CDamageInfo& info, const CMaterialFilter&) const CMaterialFilter&)
{ {
} }
bool CStateManager::ApplyRadiusDamage(const CActor&, const zeus::CVector3f&, CActor&, bool CStateManager::ApplyRadiusDamage(const CActor&, const zeus::CVector3f&, CActor&, const CDamageInfo& info)
const CDamageInfo& info)
{ {
return false; return false;
} }
@ -541,45 +467,29 @@ bool CStateManager::ApplyLocalDamage(const zeus::CVector3f& vec1, const zeus::CV
{ {
if (x870_cameraManager->IsInCinematicCamera()) if (x870_cameraManager->IsInCinematicCamera())
{ {
} }
} }
return false; return false;
} }
bool CStateManager::ApplyDamage(TUniqueId, TUniqueId, TUniqueId, const CDamageInfo& info, bool CStateManager::ApplyDamage(TUniqueId, TUniqueId, TUniqueId, const CDamageInfo& info, const CMaterialFilter&)
const CMaterialFilter&)
{ {
return false; return false;
} }
void CStateManager::UpdateAreaSounds() void CStateManager::UpdateAreaSounds() {}
{
}
void CStateManager::FrameEnd() void CStateManager::FrameEnd() {}
{
}
void CStateManager::ProcessPlayerInput() void CStateManager::ProcessPlayerInput() {}
{
}
void CStateManager::ProcessInput(const CFinalInput& input) void CStateManager::ProcessInput(const CFinalInput& input) {}
{
}
void CStateManager::Update(float dt) void CStateManager::Update(float dt) {}
{
}
void CStateManager::UpdateGameState() void CStateManager::UpdateGameState() {}
{
}
void CStateManager::FrameBegin() void CStateManager::FrameBegin() {}
{
}
void CStateManager::InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId) void CStateManager::InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId)
{ {
@ -673,10 +583,9 @@ void CStateManager::CreateStandardGameObjects()
float unk3 = g_tweakPlayer->GetX27C(); float unk3 = g_tweakPlayer->GetX27C();
zeus::CAABox pBounds = {{-xyHe, -xyHe, 0.f}, {xyHe, xyHe, height}}; zeus::CAABox pBounds = {{-xyHe, -xyHe, 0.f}, {xyHe, xyHe, height}};
auto q = zeus::CQuaternion::fromAxisAngle(zeus::CVector3f{0.f, 0.f, 1.f}, zeus::degToRad(129.6f)); auto q = zeus::CQuaternion::fromAxisAngle(zeus::CVector3f{0.f, 0.f, 1.f}, zeus::degToRad(129.6f));
x84c_player.reset(new CPlayer(AllocateUniqueId(), zeus::CTransform(q), pBounds, 0, x84c_player.reset(new CPlayer(
zeus::CVector3f{1.65f, 1.65f, 1.65f}, AllocateUniqueId(), zeus::CTransform(q), pBounds, 0, zeus::CVector3f{1.65f, 1.65f, 1.65f}, 200.f, unk1, unk2,
200.f, unk1, unk2, unk3, CMaterialList(EMaterialTypes::Player, unk3, CMaterialList(EMaterialTypes::Player, EMaterialTypes::Solid, EMaterialTypes::GroundCollider)));
EMaterialTypes::Solid, EMaterialTypes::GroundCollider)));
AddObject(*x84c_player); AddObject(*x84c_player);
} }
@ -692,18 +601,11 @@ const CObjectList* CStateManager::GetObjectListById(EGameObjectList type) const
return lists[int(type)].get(); return lists[int(type)].get();
} }
void CStateManager::RemoveObject(TUniqueId) void CStateManager::RemoveObject(TUniqueId) {}
{
}
void CStateManager::RemoveActor(TUniqueId) void CStateManager::RemoveActor(TUniqueId) {}
{
} void CStateManager::UpdateRoomAcoustics(TAreaId) {}
void CStateManager::UpdateRoomAcoustics(TAreaId)
{
}
void CStateManager::SetCurrentAreaId(TAreaId aid) void CStateManager::SetCurrentAreaId(TAreaId aid)
{ {
@ -722,9 +624,7 @@ void CStateManager::SetCurrentAreaId(TAreaId aid)
x850_world->GetMapWorld()->RecalculateWorldSphere(*x8c0_mapWorldInfo, *x850_world); x850_world->GetMapWorld()->RecalculateWorldSphere(*x8c0_mapWorldInfo, *x850_world);
} }
void CStateManager::ClearGraveyard() void CStateManager::ClearGraveyard() {}
{
}
void CStateManager::DeleteObjectRequest(TUniqueId id) void CStateManager::DeleteObjectRequest(TUniqueId id)
{ {
@ -749,63 +649,39 @@ void CStateManager::DeleteObjectRequest(TUniqueId id)
} }
} }
CEntity* CStateManager::ObjectById(TUniqueId uid) CEntity* CStateManager::ObjectById(TUniqueId uid) { return x80c_allObjs->GetObjectById(uid); }
{ const CEntity* CStateManager::GetObjectById(TUniqueId uid) const { return x80c_allObjs->GetObjectById(uid); }
return x80c_allObjs->GetObjectById(uid);
}
const CEntity* CStateManager::GetObjectById(TUniqueId uid) const
{
return x80c_allObjs->GetObjectById(uid);
}
void CStateManager::AreaUnloaded(TAreaId) void CStateManager::AreaUnloaded(TAreaId) {}
void CStateManager::PrepareAreaUnload(TAreaId) {}
void CStateManager::AreaLoaded(TAreaId) {}
void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const zeus::CVector3f&,
const zeus::CVector3f&, float, const CMaterialFilter&, const CActor*) const
{ {
} }
void CStateManager::PrepareAreaUnload(TAreaId) void CStateManager::BuildColliderList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const CActor&,
const zeus::CAABox&) const
{ {
} }
void CStateManager::AreaLoaded(TAreaId) void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const zeus::CAABox&,
{
}
void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut,
const zeus::CVector3f&, const zeus::CVector3f&, float,
const CMaterialFilter&, const CActor*) const const CMaterialFilter&, const CActor*) const
{ {
} }
void CStateManager::BuildColliderList(rstl::reserved_vector<TUniqueId, 1024>& listOut, void CStateManager::UpdateActorInSortedLists(CActor&) {}
const CActor&, const zeus::CAABox&) const
{
}
void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut, void CStateManager::UpdateSortedLists() {}
const zeus::CAABox&, const CMaterialFilter&, const CActor*) const
{
}
void CStateManager::UpdateActorInSortedLists(CActor&) zeus::CAABox CStateManager::CalculateObjectBounds(const CActor&) { return {}; }
{
}
void CStateManager::UpdateSortedLists() void CStateManager::AddObject(CEntity&) {}
{
}
zeus::CAABox CStateManager::CalculateObjectBounds(const CActor&) void CStateManager::AddObject(CEntity*) {}
{
return {};
}
void CStateManager::AddObject(CEntity&)
{
}
void CStateManager::AddObject(CEntity*)
{
}
bool CStateManager::RayStaticIntersection(const zeus::CVector3f&, const zeus::CVector3f&, float, bool CStateManager::RayStaticIntersection(const zeus::CVector3f&, const zeus::CVector3f&, float,
const CMaterialFilter&) const const CMaterialFilter&) const
@ -813,20 +689,33 @@ bool CStateManager::RayStaticIntersection(const zeus::CVector3f&, const zeus::CV
return false; return false;
} }
bool CStateManager::RayWorldIntersection(TUniqueId, const zeus::CVector3f&, const zeus::CVector3f&, bool CStateManager::RayWorldIntersection(TUniqueId, const zeus::CVector3f&, const zeus::CVector3f&, float,
float, const CMaterialFilter&, const CMaterialFilter&,
const rstl::reserved_vector<TUniqueId, 1024>& list) const const rstl::reserved_vector<TUniqueId, 1024>& list) const
{ {
return false; return false;
} }
void CStateManager::UpdateObjectInLists(CEntity&) void CStateManager::UpdateObjectInLists(CEntity&) {}
{
}
TUniqueId CStateManager::AllocateUniqueId() TUniqueId CStateManager::AllocateUniqueId()
{ {
return 0; const s16 lastIndex = x0_nextFreeIndex;
s16 ourIndex = 0;
do
{
ourIndex = x0_nextFreeIndex;
x0_nextFreeIndex = (x0_nextFreeIndex + 1) & 0x3ff;
if (ourIndex == lastIndex)
LogModule.report(logvisor::Fatal, "Object List Full!");
}
while (x80c_allObjs->GetObjectByIndex(ourIndex) != nullptr);
x8_idArr[ourIndex]++;
if (((ourIndex | ((x8_idArr[ourIndex]) << 10)) & 0xFFFF) == kInvalidUniqueId)
x8_idArr[0] = 0;
return ((ourIndex | ((x8_idArr[ourIndex]) << 10)) & 0xFFFF);
} }
std::pair<u32, u32> CStateManager::CalculateScanCompletionRate() const std::pair<u32, u32> CStateManager::CalculateScanCompletionRate() const
@ -837,8 +726,7 @@ std::pair<u32, u32> CStateManager::CalculateScanCompletionRate() const
for (const std::pair<u32, float>& scan : x8b8_playerState->GetScanTimes()) for (const std::pair<u32, float>& scan : x8b8_playerState->GetScanTimes())
{ {
CSaveWorld::EScanCategory category = g_MemoryCardSys->GetScanStates()[idx++].second; CSaveWorld::EScanCategory category = g_MemoryCardSys->GetScanStates()[idx++].second;
if (category != CSaveWorld::EScanCategory::None && if (category != CSaveWorld::EScanCategory::None && category != CSaveWorld::EScanCategory::Research)
category != CSaveWorld::EScanCategory::Research)
{ {
++denom; ++denom;
if (scan.second == 1.f) if (scan.second == 1.f)
@ -848,4 +736,9 @@ std::pair<u32, u32> CStateManager::CalculateScanCompletionRate() const
return {num, denom}; return {num, denom};
} }
bool CStateManager::ApplyDamage(TUniqueId, TUniqueId, TUniqueId, const CDamageInfo& info, const CMaterialFilter&,
const zeus::CVector3f&)
{
return false;
}
} }

View File

@ -54,6 +54,7 @@ struct SScriptObjectStream
class CStateManager class CStateManager
{ {
s16 x0_nextFreeIndex = 0;
TUniqueId x8_idArr[1024] = {}; TUniqueId x8_idArr[1024] = {};
std::unique_ptr<CObjectList> x80c_allObjs; std::unique_ptr<CObjectList> x80c_allObjs;
@ -162,6 +163,7 @@ class CStateManager
TUniqueId xf6c_playerActor; TUniqueId xf6c_playerActor;
void UpdateThermalVisor(); void UpdateThermalVisor();
TUniqueId xf74_lastTrigger = kInvalidUniqueId;
public: public:
/* TODO: Figure out what these are /* TODO: Figure out what these are
* Public for CScriptRelay * Public for CScriptRelay
@ -189,7 +191,7 @@ public:
void ResetEscapeSequenceTimer(float); void ResetEscapeSequenceTimer(float);
void SetupParticleHook(const CActor& actor) const; void SetupParticleHook(const CActor& actor) const;
void MurderScriptInstanceNames(); void MurderScriptInstanceNames();
const std::string* HashInstanceName(CInputStream& in); std::string HashInstanceName(CInputStream& in);
void SetActorAreaId(CActor& actor, TAreaId); void SetActorAreaId(CActor& actor, TAreaId);
void TouchSky() const; void TouchSky() const;
void TouchPlayerActor(); void TouchPlayerActor();
@ -236,6 +238,8 @@ public:
const CWeaponMode&); const CWeaponMode&);
bool ApplyDamage(TUniqueId, TUniqueId, TUniqueId, const CDamageInfo& info, bool ApplyDamage(TUniqueId, TUniqueId, TUniqueId, const CDamageInfo& info,
const CMaterialFilter&); const CMaterialFilter&);
bool ApplyDamage(TUniqueId, TUniqueId, TUniqueId, const CDamageInfo& info,
const CMaterialFilter&, const zeus::CVector3f&);
void UpdateAreaSounds(); void UpdateAreaSounds();
void FrameEnd(); void FrameEnd();
void ProcessPlayerInput(); void ProcessPlayerInput();
@ -306,6 +310,8 @@ public:
CAiWaypointList& GetAiWaypointObjectList() const { return *x83c_aiWaypointObjs; } CAiWaypointList& GetAiWaypointObjectList() const { return *x83c_aiWaypointObjs; }
CPlatformAndDoorList& GetPlatformAndDoorObjectList() const { return *x844_platformAndDoorObjs; } CPlatformAndDoorList& GetPlatformAndDoorObjectList() const { return *x844_platformAndDoorObjs; }
std::pair<u32, u32> CalculateScanCompletionRate() const; std::pair<u32, u32> CalculateScanCompletionRate() const;
void SetLastTrigger(TUniqueId uid) { xf74_lastTrigger = uid; }
TUniqueId GetLastTrigger() const { return xf74_lastTrigger; }
}; };
} }

View File

@ -143,7 +143,7 @@ void CCameraManager::Update(float dt, CStateManager& stateMgr)
CGameCamera* CCameraManager::GetCurrentCamera(CStateManager& stateMgr) const CGameCamera* CCameraManager::GetCurrentCamera(CStateManager& stateMgr) const
{ {
CObjectList* camList = stateMgr.ObjectListById(EGameObjectList::GameCamera); CObjectList* camList = stateMgr.ObjectListById(EGameObjectList::GameCamera);
return static_cast<CGameCamera*>(camList->GetObjectById(GetCurrentCameraId())); return TCastToPtr<CGameCamera>(camList->GetObjectById(GetCurrentCameraId())).GetPtr();
} }
const CGameCamera* CCameraManager::GetCurrentCamera(const CStateManager& stateMgr) const const CGameCamera* CCameraManager::GetCurrentCamera(const CStateManager& stateMgr) const
@ -169,7 +169,7 @@ void CCameraManager::ThinkCameras(float dt, CStateManager& mgr)
for (CEntity* ent : gcList) for (CEntity* ent : gcList)
{ {
CGameCamera* gc = TCastToPtr<CGameCamera>(ent); TCastToPtr<CGameCamera> gc(ent);
if (gc) if (gc)
{ {
gc->Think(dt, mgr); gc->Think(dt, mgr);
@ -221,7 +221,7 @@ void CCameraManager::ResetCameras(CStateManager& mgr)
for (CEntity* ent : mgr.GetCameraObjectList()) for (CEntity* ent : mgr.GetCameraObjectList())
{ {
CGameCamera* camObj = static_cast<CGameCamera*>(ent); TCastToPtr<CGameCamera> camObj(ent);
camObj->Reset(xf, mgr); camObj->Reset(xf, mgr);
} }
} }

View File

@ -60,7 +60,7 @@ void CFirstPersonCamera::CalculateGunFollowOrientationAndTransform(zeus::CTransf
void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt) void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
{ {
CPlayer* player = static_cast<CPlayer*>(mgr.ObjectById(GetWatchedObject())); TCastToPtr<CPlayer> player(mgr.ObjectById(GetWatchedObject()));
if (!player) if (!player)
{ {
x34_transform = zeus::CTransform::Identity(); x34_transform = zeus::CTransform::Identity();
@ -108,13 +108,12 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
rVec = v; rVec = v;
} }
} }
else if (player->x304_ == 0 && player->x2f8_morphTransState == 0 && player->x3dc_ && x1c4_pitchId == kInvalidUniqueId) else if (player->x304_ == 0 && player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed &&
player->x3dc_ && x1c4_pitchId == kInvalidUniqueId)
{ {
if (player->x294_ > 0.f) if (player->x294_ > 0.f)
{ {
float angle = zeus::clamp(0.f, (player->x294_ - g_tweakPlayer->GetX288()) / float angle = zeus::clamp(0.f, (player->x294_ - g_tweakPlayer->GetX288()) / g_tweakPlayer->GetX28c(), 1.f) *
g_tweakPlayer->GetX28c(),
1.f) *
g_tweakPlayer->GetX290(); g_tweakPlayer->GetX290();
angle += x1c0_; angle += x1c0_;
rVec.x = 0.f; rVec.x = 0.f;
@ -125,9 +124,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
} }
else if (player->x29c_ > 0.f) else if (player->x29c_ > 0.f)
{ {
float angle = zeus::clamp(0.f, (player->x29c_ - g_tweakPlayer->GetX294()) / float angle = zeus::clamp(0.f, (player->x29c_ - g_tweakPlayer->GetX294()) / g_tweakPlayer->GetX298(), 1.f) *
g_tweakPlayer->GetX298(),
1.f) *
g_tweakPlayer->GetX29C(); g_tweakPlayer->GetX29C();
rVec.x = 0.f; rVec.x = 0.f;
rVec.y = std::cos(angle); rVec.y = std::cos(angle);
@ -174,7 +171,8 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
if (rVecCpy.canBeNormalized()) if (rVecCpy.canBeNormalized())
rVecCpy.normalize(); rVecCpy.normalize();
gunXf = zeus::CQuaternion::lookAt(rVecCpy, gunFrontVec, zeus::CRelAngle::FromDegrees(360.f)).toTransform() * gunXf =
zeus::CQuaternion::lookAt(rVecCpy, gunFrontVec, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
x190_gunFollowXf.getRotation(); x190_gunFollowXf.getRotation();
gunFrontVec = gunXf.frontVector(); gunFrontVec = gunXf.frontVector();
@ -233,14 +231,13 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
} }
zeus::CTransform bobXf = player->GetCameraBob()->GetCameraBobTransformation(); zeus::CTransform bobXf = player->GetCameraBob()->GetCameraBobTransformation();
if (player->x2f8_morphTransState == 1 || player->x304_ == 5 || player->x3b8_ == 0 || mgr.x904_ == 1 || if (player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed || player->x304_ == 5 ||
mgr.GetCameraManager()->IsInCinematicCamera()) player->x3b8_ == 0 || mgr.x904_ == 1 || mgr.GetCameraManager()->IsInCinematicCamera())
{ {
bobXf = zeus::CTransform::Identity(); bobXf = zeus::CTransform::Identity();
player->GetCameraBob()->SetCameraBobTransform(bobXf); player->GetCameraBob()->SetCameraBobTransform(bobXf);
} }
x190_gunFollowXf = qGun.toTransform() * gunXf; x190_gunFollowXf = qGun.toTransform() * gunXf;
x34_transform = x190_gunFollowXf * bobXf.getRotation(); x34_transform = x190_gunFollowXf * bobXf.getRotation();

View File

@ -35,7 +35,7 @@ class CIkChain
public: public:
CIkChain() = default; CIkChain() = default;
bool GetActive() const; bool GetActive() const { return x44_24_activated; }
void Update(float); void Update(float);
void Deactivate(); void Deactivate();
void Activate(const CAnimData&, const CSegId&, const zeus::CTransform&); void Activate(const CAnimData&, const CSegId&, const zeus::CTransform&);

View File

@ -98,7 +98,7 @@ bool CParticleGenInfoGeneric::HasLight() const
TUniqueId CParticleGenInfoGeneric::GetLightId() const TUniqueId CParticleGenInfoGeneric::GetLightId() const
{ {
return 0; return kInvalidUniqueId;
} }
void CParticleGenInfoGeneric::SetModulationColor(const zeus::CColor& color) void CParticleGenInfoGeneric::SetModulationColor(const zeus::CColor& color)

View File

@ -37,6 +37,9 @@ CENTITY_TYPES = (
('CScriptActorKeyframe', 'World/CScriptActorKeyframe.hpp'), ('CScriptActorKeyframe', 'World/CScriptActorKeyframe.hpp'),
('CScriptTrigger', 'World/CScriptTrigger.hpp'), ('CScriptTrigger', 'World/CScriptTrigger.hpp'),
('CScriptSound', 'World/CScriptSound.hpp'), ('CScriptSound', 'World/CScriptSound.hpp'),
('CWeapon', 'Weapon/CWeapon.hpp'),
('CGameProjectile', 'Weapon/CGameProjectile.hpp'),
('CBeamProjectile', 'Weapon/CBeamProjectile.hpp'),
('CPlasmaProjectile', 'Weapon/CPlasmaProjectile.hpp'), ('CPlasmaProjectile', 'Weapon/CPlasmaProjectile.hpp'),
('CScriptCounter', 'World/CScriptCounter.hpp'), ('CScriptCounter', 'World/CScriptCounter.hpp'),
('CScriptBeam', 'World/CScriptBeam.hpp'), ('CScriptBeam', 'World/CScriptBeam.hpp'),

View File

@ -36,9 +36,6 @@ struct SObjectTag
} }
}; };
using TUniqueId = s16;
using TAreaId = s32;
struct TEditorId struct TEditorId
{ {
TEditorId() = default; TEditorId() = default;
@ -46,13 +43,16 @@ struct TEditorId
u32 id = -1; u32 id = -1;
u8 LayerNum() const { return (id >> 26) & 0x3f; } u8 LayerNum() const { return (id >> 26) & 0x3f; }
u16 AreaNum() const { return (id >> 16) & 0x3ff; } u16 AreaNum() const { return (id >> 16) & 0x3ff; }
TUniqueId Id() const { return id & 0xffff; } u16 Id() const { return id & 0xffff; }
bool operator<(const TEditorId& other) const { return (id & 0x3ffffff) < (other.id & 0x3ffffff); } bool operator<(const TEditorId& other) const { return (id & 0x3ffffff) < (other.id & 0x3ffffff); }
bool operator!=(const TEditorId& other) const { return (id & 0x3ffffff) != (other.id & 0x3ffffff); } bool operator!=(const TEditorId& other) const { return (id & 0x3ffffff) != (other.id & 0x3ffffff); }
bool operator==(const TEditorId& other) const { return (id & 0x3ffffff) == (other.id & 0x3ffffff); } bool operator==(const TEditorId& other) const { return (id & 0x3ffffff) == (other.id & 0x3ffffff); }
}; };
using TUniqueId = s16;
using TAreaId = s32;
#define kInvalidEditorId TEditorId() #define kInvalidEditorId TEditorId()
#define kInvalidUniqueId TUniqueId(-1) #define kInvalidUniqueId TUniqueId(-1)
#define kInvalidAreaId TAreaId(-1) #define kInvalidAreaId TAreaId(-1)

View File

@ -1,4 +1,5 @@
#include "Weapon/CBeamProjectile.hpp" #include "Weapon/CBeamProjectile.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -35,4 +36,10 @@ void CBeamProjectile::UpdateFX(const zeus::CTransform &, float, CStateManager &)
{ {
} }
void CBeamProjectile::Accept(urde::IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -10,6 +10,7 @@ public:
CBeamProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&, int, CBeamProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&, int,
float, float, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, bool); float, float, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, bool);
virtual void Accept(IVisitor &visitor);
float GetMaxRadius() const; float GetMaxRadius() const;
zeus::CVector3f GetSurfaceNormal() const; zeus::CVector3f GetSurfaceNormal() const;
void GetDamageType() const; void GetDamageType() const;

View File

@ -1,4 +1,5 @@
#include "Weapon/CGameProjectile.hpp" #include "Weapon/CGameProjectile.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -7,7 +8,7 @@ CGameProjectile::CGameProjectile(bool active, const TToken<CWeaponDescription>&,
const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid, TUniqueId uid, TUniqueId, const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid, TUniqueId uid, TUniqueId,
u32 w1, bool b2, const zeus::CVector3f&, u32 w1, bool b2, const zeus::CVector3f&,
const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool b3) const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool b3)
: CWeapon(owner, aid, uid, active, wType, name, xf, : CWeapon(owner, aid, active, uid, wType, name, xf,
CMaterialFilter::MakeIncludeExclude( CMaterialFilter::MakeIncludeExclude(
{EMaterialTypes::NonSolidDamageable, matType}, {EMaterialTypes::NonSolidDamageable, matType},
{EMaterialTypes::Projectile, EMaterialTypes::ProjectilePassthrough, matType, EMaterialTypes::Solid}), {EMaterialTypes::Projectile, EMaterialTypes::ProjectilePassthrough, matType, EMaterialTypes::Solid}),
@ -28,4 +29,10 @@ CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType)
return EProjectileAttrib::None; return EProjectileAttrib::None;
} }
void CGameProjectile::Accept(urde::IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -19,6 +19,7 @@ public:
EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, TUniqueId, u32, bool, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, TUniqueId, u32, bool,
const zeus::CVector3f&, const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool); const zeus::CVector3f&, const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool);
virtual void Accept(IVisitor &visitor);
static EProjectileAttrib GetBeamAttribType(EWeaponType wType); static EProjectileAttrib GetBeamAttribType(EWeaponType wType);
}; };
} }

View File

@ -1,5 +1,6 @@
#include "CWeapon.hpp" #include "CWeapon.hpp"
#include "World/CActorParameters.hpp" #include "World/CActorParameters.hpp"
#include "TCastTo.hpp"
namespace urde namespace urde
{ {
@ -11,4 +12,10 @@ CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId, EWeaponType
CActorParameters::None(), kInvalidUniqueId) CActorParameters::None(), kInvalidUniqueId)
{ {
} }
void CWeapon::Accept(urde::IVisitor& visitor)
{
visitor.Visit(this);
}
} }

View File

@ -16,16 +16,21 @@ public:
Ice = (1 << 3), Ice = (1 << 3),
Wave = (1 << 4), Wave = (1 << 4),
Plasma = (1 << 5), Plasma = (1 << 5),
Phazon = (1 << 6) Phazon = (1 << 6),
Unknown1 = (1 << 7),
Bombs = (1 << 8),
PowerBombs = (1 << 9),
}; };
private: private:
EProjectileAttrib xe8_projectileAttribs;
public: public:
CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&, CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&,
const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&); const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&);
virtual void Accept(IVisitor &visitor);
bool HasAttrib(EProjectileAttrib) const; bool HasAttrib(EProjectileAttrib) const;
EProjectileAttrib GetAttribField() const; EProjectileAttrib GetAttribField() const { return xe8_projectileAttribs; }
const CMaterialFilter& GetFilter() const; const CMaterialFilter& GetFilter() const;
void SetFilter(const CMaterialFilter&); void SetFilter(const CMaterialFilter&);
TUniqueId GetOwnerId() const; TUniqueId GetOwnerId() const;

View File

@ -2,8 +2,11 @@
namespace urde namespace urde
{ {
CWeaponMode::CWeaponMode(EWeaponType type, bool, bool) CWeaponMode::CWeaponMode(EWeaponType type, bool b1, bool b2, bool b3)
: x0_weaponType(type) : x0_weaponType(type)
, x4_24_(b1)
, x4_25_(b2)
, x4_26_instantKill(b3)
{ {
} }
@ -14,42 +17,42 @@ EWeaponType CWeaponMode::GetType() const
CWeaponMode CWeaponMode::Invalid() CWeaponMode CWeaponMode::Invalid()
{ {
return CWeaponMode(EWeaponType::None, false, false); return CWeaponMode(EWeaponType::None);
} }
CWeaponMode CWeaponMode::Phazon() CWeaponMode CWeaponMode::Phazon()
{ {
return CWeaponMode(EWeaponType::Phazon, false, false); return CWeaponMode(EWeaponType::Phazon);
} }
CWeaponMode CWeaponMode::Plasma() CWeaponMode CWeaponMode::Plasma()
{ {
return CWeaponMode(EWeaponType::Plasma, false, false); return CWeaponMode(EWeaponType::Plasma);
} }
CWeaponMode CWeaponMode::Wave() CWeaponMode CWeaponMode::Wave()
{ {
return CWeaponMode(EWeaponType::Wave, false, false); return CWeaponMode(EWeaponType::Wave);
} }
CWeaponMode CWeaponMode::BoostBall() CWeaponMode CWeaponMode::BoostBall()
{ {
return CWeaponMode(EWeaponType::BoostBall, false, false); return CWeaponMode(EWeaponType::BoostBall);
} }
CWeaponMode CWeaponMode::Ice() CWeaponMode CWeaponMode::Ice()
{ {
return CWeaponMode(EWeaponType::Ice, false, false); return CWeaponMode(EWeaponType::Ice);
} }
CWeaponMode CWeaponMode::Power() CWeaponMode CWeaponMode::Power()
{ {
return CWeaponMode(EWeaponType::Power, false, false); return CWeaponMode(EWeaponType::Power);
} }
CWeaponMode CWeaponMode::Bomb() CWeaponMode CWeaponMode::Bomb()
{ {
return CWeaponMode(EWeaponType::Bomb, false, false); return CWeaponMode(EWeaponType::Bomb);
} }
} }

View File

@ -20,7 +20,7 @@ class CWeaponMode
}; };
public: public:
CWeaponMode() = default; CWeaponMode() = default;
CWeaponMode(EWeaponType, bool = false, bool = false); CWeaponMode(EWeaponType, bool = false, bool = false, bool instaKill = false);
EWeaponType GetType() const; EWeaponType GetType() const;

View File

@ -28,7 +28,14 @@ public:
x10_radius = in.readFloatBig(); x10_radius = in.readFloatBig();
x14_knockback = in.readFloatBig(); x14_knockback = in.readFloatBig();
} }
CDamageInfo(const CWeaponMode&, float damage, float radius, float knockback); CDamageInfo(const CWeaponMode& mode, float damage, float radius, float knockback)
: x0_weaponMode(mode)
, x8_damage(damage)
, xc_radiusDamage(damage)
, x10_radius(radius)
, x14_knockback(knockback)
{}
CDamageInfo(const CDamageInfo& other) = default; CDamageInfo(const CDamageInfo& other) = default;
const CWeaponMode& GetWeaponMode() const { return x0_weaponMode; } const CWeaponMode& GetWeaponMode() const { return x0_weaponMode; }

View File

@ -2,6 +2,7 @@
#define __URDE_CDAMAGEVULNERABILITY_HPP__ #define __URDE_CDAMAGEVULNERABILITY_HPP__
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "Weapon/CWeaponMode.hpp"
namespace urde namespace urde
{ {
@ -106,6 +107,8 @@ public:
else else
ConstructNew(in, propCount); ConstructNew(in, propCount);
} }
bool WeaponHurts(const CWeaponMode&, u32) const { return false; }
}; };
} }

View File

@ -799,9 +799,7 @@ void CGameArea::PostConstructArea()
++secIt; ++secIt;
} }
x12c_postConstructed->x10c0_areaObjs.reset(new CObjectList(EGameObjectList::Invalid)); x12c_postConstructed->x10c0_areaObjs.reset(new CAreaObjectList(x4_selfIdx));
x12c_postConstructed->x10c0_areaObjs->m_areaIdx = x4_selfIdx;
x12c_postConstructed->x10c4_areaFog.reset(new CAreaFog()); x12c_postConstructed->x10c4_areaFog.reset(new CAreaFog());
xf0_24_postConstructed = true; xf0_24_postConstructed = true;
@ -920,4 +918,9 @@ void CGameArea::SetAreaAttributes(const CScriptAreaAttributes* areaAttributes)
x12c_postConstructed->x1128_worldLightingLevel = areaAttributes->GetWorldLightingLevel(); x12c_postConstructed->x1128_worldLightingLevel = areaAttributes->GetWorldLightingLevel();
} }
bool CGameArea::CAreaObjectList::IsQualified(const CEntity& ent)
{
return (ent.GetAreaId() == x200c_areaIdx);
}
} }

View File

@ -122,6 +122,21 @@ class CGameArea : public IGameArea
std::list<std::shared_ptr<ProjectResourceFactoryBase::AsyncTask>> xf8_loadTransactions; std::list<std::shared_ptr<ProjectResourceFactoryBase::AsyncTask>> xf8_loadTransactions;
public: public:
class CAreaObjectList : public CObjectList
{
private:
TAreaId x200c_areaIdx = 0;
public:
CAreaObjectList(TAreaId areaIdx)
: CObjectList(EGameObjectList::Invalid)
, x200c_areaIdx(areaIdx)
{
}
bool IsQualified(const CEntity& ent);
};
enum class EOcclusionState enum class EOcclusionState
{ {
NotOccluded, NotOccluded,
@ -170,7 +185,7 @@ public:
TLockedToken<CPFArea> x10ac_path; TLockedToken<CPFArea> x10ac_path;
// bool x10b8_ = 0; optional flag for CToken // bool x10b8_ = 0; optional flag for CToken
u32 x10bc_ = 0; u32 x10bc_ = 0;
std::unique_ptr<CObjectList> x10c0_areaObjs; std::unique_ptr<CAreaObjectList> x10c0_areaObjs;
std::unique_ptr<CAreaFog> x10c4_areaFog; std::unique_ptr<CAreaFog> x10c4_areaFog;
std::unique_ptr<u8[]> x10c8_sclyBuf; std::unique_ptr<u8[]> x10c8_sclyBuf;
u32 x10d0_sclySize = 0; u32 x10d0_sclySize = 0;
@ -242,12 +257,6 @@ private:
public: public:
struct CAreaObjectList : public IAreaObjectList
{
bool IsQualified(const CEntity& ent);
};
CGameArea(CInputStream& in, int idx, int mlvlVersion); CGameArea(CInputStream& in, int idx, int mlvlVersion);
bool IsFinishedOccluding() const; bool IsFinishedOccluding() const;

View File

@ -66,6 +66,7 @@ set(WORLD_SOURCES
CScriptSwitch.hpp CScriptSwitch.cpp CScriptSwitch.hpp CScriptSwitch.cpp
CScriptAiJumpPoint.hpp CScriptAiJumpPoint.cpp CScriptAiJumpPoint.hpp CScriptAiJumpPoint.cpp
CScriptColorModulate.hpp CScriptColorModulate.cpp CScriptColorModulate.hpp CScriptColorModulate.cpp
CScriptStreamedMusic.hpp CScriptStreamedMusic.cpp
CRepulsor.hpp CRepulsor.cpp CRepulsor.hpp CRepulsor.cpp
CScriptCameraPitchVolume.hpp CScriptCameraPitchVolume.cpp CScriptCameraPitchVolume.hpp CScriptCameraPitchVolume.cpp
CScriptCameraHintTrigger.hpp CScriptCameraHintTrigger.cpp CScriptCameraHintTrigger.hpp CScriptCameraHintTrigger.cpp

View File

@ -32,9 +32,9 @@ void CPlayer::Update(float, CStateManager& mgr) {}
bool CPlayer::IsPlayerDeadEnough() const bool CPlayer::IsPlayerDeadEnough() const
{ {
if (x2f8_morphTransState == 0) if (x2f8_morphTransState == CPlayer::EPlayerMorphBallState::Unmorphed)
return x9f4_ < 2.5f; return x9f4_ < 2.5f;
else if (x2f8_morphTransState == 1) else if (x2f8_morphTransState == CPlayer::EPlayerMorphBallState::Morphed)
return x9f4_ < 6.f; return x9f4_ < 6.f;
return false; return false;
@ -75,7 +75,7 @@ void CPlayer::Accept(IVisitor& visitor)
visitor.Visit(this); visitor.Visit(this);
} }
CHealthInfo* CPlayer::HealthInfo(CStateManager& mgr) { return nullptr; } CHealthInfo* CPlayer::HealthInfo(CStateManager& mgr) { return &mgr.GetPlayerState()->HealthInfo(); }
bool CPlayer::IsUnderBetaMetroidAttack(CStateManager& mgr) const { return false; } bool CPlayer::IsUnderBetaMetroidAttack(CStateManager& mgr) const { return false; }
@ -166,7 +166,7 @@ void CPlayer::DrawGun(CStateManager& mgr) {}
void CPlayer::HolsterGun(CStateManager& mgr) {} void CPlayer::HolsterGun(CStateManager& mgr) {}
bool CPlayer::GetMorphballTransitionState() const { return false; } CPlayer::EPlayerMorphBallState CPlayer::GetMorphballTransitionState() const { return x2f8_morphTransState; }
void CPlayer::UpdateGrappleArmTransform(const zeus::CVector3f&, CStateManager& mgr, float) {} void CPlayer::UpdateGrappleArmTransform(const zeus::CVector3f&, CStateManager& mgr, float) {}
@ -365,4 +365,21 @@ void CPlayer::CVisorSteam::Update(float dt)
} }
void CPlayer::SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState, CStateManager&) {} void CPlayer::SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState, CStateManager&) {}
void CPlayer::DecrementPhazon()
{
if (xa10_ == 0)
return;
xa10_--;
}
void CPlayer::IncrementPhazon()
{
if (xa10_ != 0)
xa10_++;
else
xa14_ = 0.f;
}
} }

View File

@ -50,7 +50,7 @@ public:
Unmorphed, Unmorphed,
Morphed, Morphed,
Morphing, Morphing,
UnMorphing Unmorphing
}; };
private: private:
@ -98,7 +98,7 @@ private:
zeus::CAABox x2d8_; zeus::CAABox x2d8_;
float x2f0_ = 0.f; float x2f0_ = 0.f;
u32 x2f4_cameraState = 0; u32 x2f4_cameraState = 0;
u32 x2f8_morphTransState = 0; EPlayerMorphBallState x2f8_morphTransState = EPlayerMorphBallState::Unmorphed;
u32 x2fc_ = 0; u32 x2fc_ = 0;
float x300_ = 0.f; float x300_ = 0.f;
u32 x304_ = 0; u32 x304_ = 0;
@ -185,9 +185,12 @@ private:
float x79c_; float x79c_;
CVisorSteam x7a0_ = CVisorSteam(0.f, 0.f, 0.f, -1); CVisorSteam x7a0_ = CVisorSteam(0.f, 0.f, 0.f, -1);
float x9f4_; float x9f4_;
TUniqueId xa00_;
float xa04_; float xa04_;
ResId xa08_steamTextureId; ResId xa08_steamTextureId;
ResId xa0c_; ResId xa0c_;
u32 xa10_;
float xa14_;
public: public:
CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, unsigned int, const zeus::CVector3f&, float, float, CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, unsigned int, const zeus::CVector3f&, float, float,
@ -248,7 +251,7 @@ public:
void UpdateGunTransform(const zeus::CVector3f&, float, CStateManager& mgr, bool); void UpdateGunTransform(const zeus::CVector3f&, float, CStateManager& mgr, bool);
void DrawGun(CStateManager& mgr); void DrawGun(CStateManager& mgr);
void HolsterGun(CStateManager& mgr); void HolsterGun(CStateManager& mgr);
bool GetMorphballTransitionState() const; CPlayer::EPlayerMorphBallState GetMorphballTransitionState() const;
void UpdateGrappleArmTransform(const zeus::CVector3f&, CStateManager& mgr, float); void UpdateGrappleArmTransform(const zeus::CVector3f&, CStateManager& mgr, float);
void ApplyGrappleForces(const CFinalInput& input, CStateManager& mgr, float); void ApplyGrappleForces(const CFinalInput& input, CStateManager& mgr, float);
bool ValidateFPPosition(const zeus::CVector3f& pos, CStateManager& mgr); bool ValidateFPPosition(const zeus::CVector3f& pos, CStateManager& mgr);
@ -318,6 +321,9 @@ public:
void Touch(); void Touch();
const std::unique_ptr<CPlayerCameraBob>& GetCameraBob() const { return x76c_cameraBob; } const std::unique_ptr<CPlayerCameraBob>& GetCameraBob() const { return x76c_cameraBob; }
void DecrementPhazon();
void IncrementPhazon();
}; };
} }

View File

@ -50,7 +50,18 @@ void CPlayerCameraBob::SetPlayerVelocity(const zeus::CVector3f& velocity)
x68_ = zeus::min(x68_, velocity.z); x68_ = zeus::min(x68_, velocity.z);
} }
void CPlayerCameraBob::SetBobMagnitude(float magnitude) { x10_bobMagnitude = zeus::clamp(0.f, magnitude, 1.f); } void CPlayerCameraBob::SetBobMagnitude(float magnitude)
{
#if 0
/* Retro Original (This is why underpaid (re: unpaid) interns make crappy programmers) */
x10_bobMagnitude = magnitude;
x10_bobMagnitude = std::max(0.f, x10_bobMagnitude);
x10_bobMagnitude = std::max(1.f, x10_bobMagnitude);
#else
/* Should fix lightshow */
x10_bobMagnitude = zeus::clamp(0.f, magnitude, 1.f);
#endif
}
void CPlayerCameraBob::SetBobTimeScale(float ts) { x18_bobTimeScale = zeus::clamp(0.f, ts, 1.f); } void CPlayerCameraBob::SetBobTimeScale(float ts) { x18_bobTimeScale = zeus::clamp(0.f, ts, 1.f); }

View File

@ -27,7 +27,7 @@ void CScriptBeam::Accept(IVisitor& visitor)
void CScriptBeam::Think(float dt, CStateManager& mgr) void CScriptBeam::Think(float dt, CStateManager& mgr)
{ {
#if 0 #if 0
CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.GetObjectById(x154_projectileId)); TCastToPtr<CGameProjectile> proj{mgr.GetObjectById(x154_projectileId)};
if (proj) if (proj)
{ {
if (proj->GetActive()) if (proj->GetActive())

View File

@ -42,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 = TCastToPtr<CPlayer>(act); TCastToPtr<CPlayer> pl(act);
if (!pl) if (!pl)
return; return;

View File

@ -74,7 +74,7 @@ void CScriptDock::Think(float dt, CStateManager& mgr)
CObjectList& objs = mgr.WorldNC()->GetArea(aid)->GetAreaObjects(); CObjectList& objs = mgr.WorldNC()->GetArea(aid)->GetAreaObjects();
for (CEntity* ent : objs) for (CEntity* ent : objs)
{ {
CScriptDock* dock = static_cast<CScriptDock*>(ent); TCastToPtr<CScriptDock> dock(ent);
if (dock && dock->GetDockId() == otherDock) if (dock && dock->GetDockId() == otherDock)
dock->SetLoadConnected(mgr, true); dock->SetLoadConnected(mgr, true);
} }
@ -129,7 +129,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
CPlatformAndDoorList& lst = mgr.GetPlatformAndDoorObjectList(); CPlatformAndDoorList& lst = mgr.GetPlatformAndDoorObjectList();
for (CEntity* ent : lst) for (CEntity* ent : lst)
{ {
CScriptDoor* door = static_cast<CScriptDoor*>(ent); TCastToPtr<CScriptDoor> door(ent);
if (door && !door->IsConnectedToArea(mgr, aid)) if (door && !door->IsConnectedToArea(mgr, aid))
door->ForceClosed(mgr); door->ForceClosed(mgr);
} }
@ -176,7 +176,7 @@ void CScriptDock::Touch(CActor& act, CStateManager&)
if (x264_dockState == EDockState::Three) if (x264_dockState == EDockState::Three)
return; return;
if (static_cast<CPlayer*>(&act) != nullptr) if (TCastToPtr<CPlayer>(act))
x264_dockState = EDockState::PlayerTouched; x264_dockState = EDockState::PlayerTouched;
} }

View File

@ -29,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 = TCastToPtr<CScriptDock>(stateMgr.ObjectById(id)); TCastToPtr<CScriptDock> dock(stateMgr.ObjectById(id));
if (dock) if (dock)
dock->SetDockReference(stateMgr, x34_dockReference); dock->SetDockReference(stateMgr, x34_dockReference);
} }

View File

@ -4,23 +4,27 @@
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "TCastTo.hpp" #include "TCastTo.hpp"
#include "World/CPlayer.hpp"
#include "Weapon/CGameProjectile.hpp"
#include "Weapon/CWeapon.hpp"
#include "CPlayerState.hpp"
namespace urde namespace urde
{ {
CScriptTrigger::CScriptTrigger(TUniqueId uid, const std::string& name, const CEntityInfo& info, CScriptTrigger::CScriptTrigger(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CVector3f& pos, const zeus::CAABox& bounds, const zeus::CVector3f& pos, const zeus::CAABox& bounds, const CDamageInfo& dInfo,
const CDamageInfo& dInfo, const zeus::CVector3f& forceField, const zeus::CVector3f& forceField, ETriggerFlags triggerFlags, bool active, bool b2,
ETriggerFlags triggerFlags, bool active, bool b2, bool b3) bool b3)
: CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(), : CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(),
CMaterialList(EMaterialTypes::Trigger), CActorParameters::None(), kInvalidUniqueId), CMaterialList(EMaterialTypes::Trigger), CActorParameters::None(), kInvalidUniqueId)
x100_damageInfo(dInfo), , x100_damageInfo(dInfo)
x11c_forceField(forceField), , x11c_forceField(forceField)
x128_forceMagnitude(forceField.magnitude()), , x128_forceMagnitude(forceField.magnitude())
x12c_flags(triggerFlags), , x12c_flags(triggerFlags)
x130_bounds(bounds), , x130_bounds(bounds)
x148_26_(b2), , x148_26_deactivateOnEntered(b2)
x148_27_(b3) , x148_27_deactivateOnExited(b3)
{ {
} }
@ -29,34 +33,289 @@ void CScriptTrigger::Accept(IVisitor& visitor)
visitor.Visit(this); visitor.Visit(this);
} }
CScriptTrigger::CObjectTracker* CScriptTrigger::FindInhabitant(TUniqueId id) void CScriptTrigger::Think(float dt, CStateManager& mgr)
{ {
const auto& iter = std::find(xe8_inhabitants.begin(), xe8_inhabitants.end(), id); if (GetActive())
UpdateInhabitants(dt, mgr);
}
if (iter != xe8_inhabitants.end()) void CScriptTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
if (GetActive() && (msg == EScriptObjectMessage::Deactivate || msg == EScriptObjectMessage::InternalMessage12))
{
if (msg == EScriptObjectMessage::Deactivate)
{
xe8_inhabitants.clear();
x148_25_ = false;
}
if (x148_28_)
{
x148_28_ = false;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
x148_29_didPhazonDamage = false;
}
if (x8_uid == mgr.GetLastTrigger())
mgr.SetLastTrigger(kInvalidUniqueId);
}
}
CEntity::AcceptScriptMsg(msg, uid, mgr);
;
}
CScriptTrigger::CObjectTracker* CScriptTrigger::FindObject(TUniqueId id)
{
auto& inhabitants = GetInhabitants();
const auto& iter = std::find(inhabitants.begin(), inhabitants.end(), id);
if (iter != inhabitants.end())
return &(*iter); return &(*iter);
return nullptr; return nullptr;
} }
void CScriptTrigger::UpdateInhabitants(CStateManager& mgr) void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr)
{ {
#if 0
for (auto it = xe8_inhabitants.begin(); it != xe8_inhabitants.end();)
{
TCastToPtr<CActor> act(mgr.ObjectById((*it).GetObjectId()));
if (act->GetUniqueId() == mgr.Player()->GetUniqueId())
{
TCastToPtr<CPlayer> pl(act);
if (bool(x12c_flags & ETriggerFlags::DetectPlayer))
{
using EPlayerMorphBallState = CPlayer::EPlayerMorphBallState;
EPlayerMorphBallState mState = pl->GetMorphballTransitionState();
if ((mState == EPlayerMorphBallState::Morphed &&
bool(x12c_flags & ETriggerFlags::DetectMorphedPlayer)) ||
(mState == EPlayerMorphBallState::Unmorphed &&
bool(x12c_flags & ETriggerFlags::DetectUnmorphedPlayer)))
{
it = xe8_inhabitants.erase(it);
if (x148_28_)
{
x148_28_ = false;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
x148_29_didPhazonDamage = false;
} }
const std::list<CScriptTrigger::CObjectTracker>&CScriptTrigger::GetInhabitants() const if (mgr.GetLastTrigger() == GetUniqueId())
{ mgr.SetLastTrigger(kInvalidUniqueId);
return xe8_inhabitants;
} }
InhabitantExited(*act, mgr);
continue;
}
}
const auto& touchBounds = GetTouchBounds();
const auto& actTouchBounds = act->GetTouchBounds();
if (touchBounds && actTouchBounds)
{
if (actTouchBounds->intersects(*touchBounds))
{
inhabitantExited = true;
InhabitantIdle(*act, mgr);
if (act->HealthInfo() && x100_damageInfo.GetDamage() > 0.f)
mgr.ApplyDamage(GetUniqueId(), act->GetUniqueId(), GetUniqueId(), x100_damageInfo, CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull}));
TCastToPtr<CPhysicsActor> physAct{act};
if (physAct)
{
float forceMult = 1.f;
if (bool(x12c_flags & ETriggerFlags::UseBooleanIntersection))
forceMult = touchBounds->booleanIntersection(*actTouchBounds).volume() / actTouchBounds->volume();
zeus::CVector3f force = forceMult * x11c_forceField;
if (bool(x12c_flags & ETriggerFlags::UseCollisionImpulses))
{
physAct->ApplyImpulseWR(force, zeus::CAxisAngle::sIdentity);
physAct->UseCollisionImpulses();
}
else
physAct->ApplyForceWR(force, zeus::CAxisAngle::sIdentity);
}
}
}
else
{
it = xe8_inhabitants.erase(it);
if (mgr.Player()->GetUniqueId() == (*it).GetObjectId())
{
if (x148_28_)
{
x148_28_ = false;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
x148_29_didPhazonDamage = false;
}
}
}
if (mgr.GetLastTrigger() == GetUniqueId())
mgr.SetLastTrigger(kInvalidUniqueId);
InhabitantExited(*act, mgr);
continue;
}
}
else
{
it = xe8_inhabitants.erase(it);
if (mgr.Player()->GetUniqueId() == (*it).GetObjectId())
{
if (x148_28_)
{
x148_28_ = false;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
x148_29_didPhazonDamage = false;
}
}
}
if (mgr.GetLastTrigger() == GetUniqueId())
mgr.SetLastTrigger(kInvalidUniqueId);
}
}
if (bool(x12c_flags & ETriggerFlags::DetectPlayerIfInside) && x148_24_playerInside && !inhabitantExited)
{
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
return;
}
if (!player)
{
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
if (x148_27_deactivateOnExited)
{
mgr.SendScriptMsg(GetUniqueId(), mgr.GetEditorIdForUniqueId(GetUniqueId()), EScriptObjectMessage::Deactivate,
EScriptObjectState::Exited);
}
}
#endif
}
std::list<CScriptTrigger::CObjectTracker>& CScriptTrigger::GetInhabitants() { return xe8_inhabitants; }
rstl::optional_object<zeus::CAABox> CScriptTrigger::GetTouchBounds() const rstl::optional_object<zeus::CAABox> CScriptTrigger::GetTouchBounds() const
{ {
if (x30_24_active) if (x30_24_active)
return {GetTriggerBoundsWR()}; return {GetTriggerBoundsWR()};
return {}; return {};
} }
static const CWeaponMode sktonOHurtWeaponMode = CWeaponMode(EWeaponType::Power, false, false, true);
void CScriptTrigger::Touch(CActor& act, CStateManager& mgr)
{
if (!act.GetActive() || act.GetMaterialList().HasMaterial(EMaterialTypes::Trigger))
return;
if (FindObject(act.GetUniqueId()) == nullptr)
{
ETriggerFlags testFlags = ETriggerFlags::None;
TCastToPtr<CPlayer> pl(act);
if (pl)
{
if (x128_forceMagnitude > 0.f && (x12c_flags & ETriggerFlags::DetectPlayer) != ETriggerFlags::None &&
mgr.GetLastTrigger() == kInvalidUniqueId)
mgr.SetLastTrigger(x8_uid);
testFlags |= ETriggerFlags::DetectPlayer;
if (pl->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed)
testFlags |= ETriggerFlags::DetectUnmorphedPlayer;
else if (pl->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed)
testFlags |= ETriggerFlags::DetectMorphedPlayer;
}
else if (TCastToPtr<CAi>(act))
{
testFlags |= ETriggerFlags::DetectAI;
}
else if (TCastToPtr<CGameProjectile>(act))
{
testFlags |= ETriggerFlags::DetectProjectiles1 | ETriggerFlags::DetectProjectiles2 |
ETriggerFlags::DetectProjectiles3 | ETriggerFlags::DetectProjectiles4 |
ETriggerFlags::DetectProjectiles5 | ETriggerFlags::DetectProjectiles6 |
ETriggerFlags::DetectProjectiles7;
}
else if (CWeapon* weap = TCastToPtr<CWeapon>(act))
{
if ((weap->GetAttribField() & CWeapon::EProjectileAttrib::Bombs) != CWeapon::EProjectileAttrib::None)
testFlags |= ETriggerFlags::DetectBombs;
else if ((weap->GetAttribField() & CWeapon::EProjectileAttrib::PowerBombs) !=
CWeapon::EProjectileAttrib::None)
testFlags |= ETriggerFlags::DetectPowerBombs;
}
if ((testFlags & x12c_flags) != ETriggerFlags::None)
{
xe8_inhabitants.push_back(act.GetUniqueId());
InhabitantAdded(act, mgr);
if (pl)
{
if (x148_28_ == false)
{
x148_28_ = true;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
x148_29_didPhazonDamage = false;
}
else if (x100_damageInfo.GetDamage() > 0.f)
{
const CDamageVulnerability* dVuln = mgr.Player()->GetDamageVulnerability();
if (dVuln->WeaponHurts(x100_damageInfo.GetWeaponMode(), 0) &&
x100_damageInfo.GetWeaponMode().GetType() == EWeaponType::Phazon &&
!mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::PhazonSuit))
{
pl->IncrementPhazon();
x148_29_didPhazonDamage = true;
}
}
}
}
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
if (x148_26_deactivateOnEntered)
{
mgr.SendScriptMsg(x8_uid, mgr.GetEditorIdForUniqueId(x8_uid), EScriptObjectMessage::Deactivate,
EScriptObjectState::Entered);
if (act.HealthInfo() && x100_damageInfo.GetDamage() > 0.f)
{
mgr.ApplyDamage(x8_uid, act.GetUniqueId(), x8_uid, x100_damageInfo,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull}),
zeus::CVector3f::skZero);
}
}
if ((x12c_flags & ETriggerFlags::KillOnEnter) != ETriggerFlags::None && act.HealthInfo())
{
CHealthInfo* hInfo = act.HealthInfo();
mgr.ApplyDamage(
x8_uid, act.GetUniqueId(), x8_uid, {sktonOHurtWeaponMode, 10.f * hInfo->GetHP(), 0.f, 0.f},
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull}), zeus::CVector3f::skZero);
}
}
else
InhabitantRejected(act, mgr);
}
}
zeus::CAABox CScriptTrigger::GetTriggerBoundsWR() const zeus::CAABox CScriptTrigger::GetTriggerBoundsWR() const
{ {
return {x130_bounds.min + x34_transform.origin, x130_bounds.max + x34_transform.origin}; return {x130_bounds.min + x34_transform.origin, x130_bounds.max + x34_transform.origin};
} }
} }

View File

@ -10,6 +10,7 @@ namespace urde
// TODO - Phil: Figure out what each of the DetectProjectiles actually mean // TODO - Phil: Figure out what each of the DetectProjectiles actually mean
enum class ETriggerFlags : u32 enum class ETriggerFlags : u32
{ {
None = 0,
DetectPlayer = (1 << 0), DetectPlayer = (1 << 0),
DetectAI = (1 << 1), DetectAI = (1 << 1),
DetectProjectiles1 = (1 << 2), DetectProjectiles1 = (1 << 2),
@ -17,19 +18,19 @@ enum class ETriggerFlags : u32
DetectProjectiles3 = (1 << 4), DetectProjectiles3 = (1 << 4),
DetectProjectiles4 = (1 << 5), DetectProjectiles4 = (1 << 5),
DetectBombs = (1 << 6), DetectBombs = (1 << 6),
Unknown1 = (1 << 7), DetectPowerBombs = (1 << 7),
DetectProjectiles5 = (1 << 8), DetectProjectiles5 = (1 << 8),
DetectProjectiles6 = (1 << 9), DetectProjectiles6 = (1 << 9),
DetectProjectiles7 = (1 << 10), DetectProjectiles7 = (1 << 10),
KillOnEnter = (1 << 11), KillOnEnter = (1 << 11),
DetectMorphedPlayer = (1 << 12), DetectMorphedPlayer = (1 << 12),
ApplyForce = (1 << 13), UseCollisionImpulses = (1 << 13),
DetectPlayerIfInside = (1 << 14), DetectPlayerIfInside = (1 << 14),
Unknown2 = (1 << 15), UseBooleanIntersection = (1 << 15),
DetectUnmorphedPlayer = (1 << 16), DetectUnmorphedPlayer = (1 << 16),
BlockEnvironmentalEffects = (1 << 17) BlockEnvironmentalEffects = (1 << 17)
}; };
ENABLE_BITWISE_ENUM(ETriggerFlags) ENABLE_BITWISE_ENUM(ETriggerFlags);
class CScriptTrigger : public CActor class CScriptTrigger : public CActor
{ {
@ -42,7 +43,7 @@ public:
CObjectTracker(TUniqueId id) : x0_id(id) {} CObjectTracker(TUniqueId id) : x0_id(id) {}
TUniqueId GetObjectId() const { return x0_id; } TUniqueId GetObjectId() const { return x0_id; }
bool operator==(const CObjectTracker& other) { return x0_id == other.x0_id; } bool operator==(const CObjectTracker& other) const { return x0_id == other.x0_id; }
}; };
protected: protected:
@ -56,12 +57,12 @@ protected:
union { union {
struct struct
{ {
bool x148_24_ : 1; bool x148_24_playerInside : 1;
bool x148_25_ : 1; bool x148_25_ : 1;
bool x148_26_ : 1; bool x148_26_deactivateOnEntered : 1;
bool x148_27_ : 1; bool x148_27_deactivateOnExited : 1;
bool x148_28_ : 1; bool x148_28_ : 1;
bool x148_29_ : 1; bool x148_29_didPhazonDamage : 1;
}; };
u8 dummy = 0; u8 dummy = 0;
}; };
@ -72,14 +73,17 @@ public:
ETriggerFlags triggerFlags, bool, bool, bool); ETriggerFlags triggerFlags, bool, bool, bool);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void Think(float, CStateManager &);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
virtual void InhabitantRejected(CActor&, CStateManager&) {} virtual void InhabitantRejected(CActor&, CStateManager&) {}
virtual void InhabitantExited(CActor&, CStateManager&) {} virtual void InhabitantExited(CActor&, CStateManager&) {}
virtual void InhabitantIdle(CActor&, CStateManager&) {} virtual void InhabitantIdle(CActor&, CStateManager&) {}
virtual void InhabitantAdded(CActor&, CStateManager&) {} virtual void InhabitantAdded(CActor&, CStateManager&) {}
CObjectTracker* FindInhabitant(TUniqueId); CObjectTracker* FindObject(TUniqueId);
void UpdateInhabitants(CStateManager&); void UpdateInhabitants(float, CStateManager&);
const std::list<CObjectTracker>& GetInhabitants() const; std::list<CObjectTracker>& GetInhabitants();
rstl::optional_object<zeus::CAABox> GetTouchBounds() const; rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor &, CStateManager &);
zeus::CAABox GetTriggerBoundsWR() const; zeus::CAABox GetTriggerBoundsWR() const;
}; };
} }

View File

@ -42,11 +42,6 @@ public:
void SetReferenceCount(s32 v) { x0_referenceCount = v; x48_isReferenced = true; } void SetReferenceCount(s32 v) { x0_referenceCount = v; x48_isReferenced = true; }
}; };
struct IAreaObjectList
{
virtual bool IsQualified(const CEntity& ent)=0;
};
virtual bool IGetScriptingMemoryAlways() const=0; virtual bool IGetScriptingMemoryAlways() const=0;
virtual TAreaId IGetAreaId() const=0; virtual TAreaId IGetAreaId() const=0;
virtual ResId IGetAreaAssetId() const=0; virtual ResId IGetAreaAssetId() const=0;

View File

@ -126,7 +126,7 @@ static zeus::CTransform LoadEditorTransformPivotOnly(CInputStream& in)
static SActorHead LoadActorHead(CInputStream& in, CStateManager& stateMgr) static SActorHead LoadActorHead(CInputStream& in, CStateManager& stateMgr)
{ {
SActorHead ret; SActorHead ret;
ret.x0_name = *stateMgr.HashInstanceName(in); ret.x0_name = stateMgr.HashInstanceName(in);
ret.x10_transform = LoadEditorTransform(in); ret.x10_transform = LoadEditorTransform(in);
return ret; return ret;
} }
@ -502,7 +502,7 @@ CEntity* ScriptLoader::LoadTrigger(CStateManager& mgr, CInputStream& in, int pro
if (!EnsurePropertyCount(propCount, 9, "Trigger")) if (!EnsurePropertyCount(propCount, 9, "Trigger"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f position; zeus::CVector3f position;
position.readBig(in); position.readBig(in);
@ -525,7 +525,7 @@ CEntity* ScriptLoader::LoadTrigger(CStateManager& mgr, CInputStream& in, int pro
const zeus::CTransform& areaXf = mgr.WorldNC()->GetGameAreas()[info.GetAreaId()]->GetTransform(); const zeus::CTransform& areaXf = mgr.WorldNC()->GetGameAreas()[info.GetAreaId()]->GetTransform();
zeus::CVector3f orientedForce = areaXf.basis * forceVec; zeus::CVector3f orientedForce = areaXf.basis * forceVec;
return new CScriptTrigger(mgr.AllocateUniqueId(), *name, info, position, box, dInfo, orientedForce, flags, active, return new CScriptTrigger(mgr.AllocateUniqueId(), name, info, position, box, dInfo, orientedForce, flags, active,
b2, b3); b2, b3);
} }
@ -534,7 +534,7 @@ CEntity* ScriptLoader::LoadTimer(CStateManager& mgr, CInputStream& in, int propC
if (!EnsurePropertyCount(propCount, 6, "Timer")) if (!EnsurePropertyCount(propCount, 6, "Timer"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
float f1 = in.readFloatBig(); float f1 = in.readFloatBig();
float f2 = in.readFloatBig(); float f2 = in.readFloatBig();
@ -542,7 +542,7 @@ CEntity* ScriptLoader::LoadTimer(CStateManager& mgr, CInputStream& in, int propC
bool b2 = in.readBool(); bool b2 = in.readBool();
bool b3 = in.readBool(); bool b3 = in.readBool();
return new CScriptTimer(mgr.AllocateUniqueId(), *name, info, f1, f2, b1, b2, b3); return new CScriptTimer(mgr.AllocateUniqueId(), name, info, f1, f2, b1, b2, b3);
} }
CEntity* ScriptLoader::LoadCounter(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadCounter(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -550,14 +550,14 @@ CEntity* ScriptLoader::LoadCounter(CStateManager& mgr, CInputStream& in, int pro
if (!EnsurePropertyCount(propCount, 5, "Counter")) if (!EnsurePropertyCount(propCount, 5, "Counter"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
u32 w1 = in.readUint32Big(); u32 w1 = in.readUint32Big();
u32 w2 = in.readUint32Big(); u32 w2 = in.readUint32Big();
bool b1 = in.readBool(); bool b1 = in.readBool();
bool b2 = in.readBool(); bool b2 = in.readBool();
return new CScriptCounter(mgr.AllocateUniqueId(), *name, info, w1, w2, b1, b2); return new CScriptCounter(mgr.AllocateUniqueId(), name, info, w1, w2, b1, b2);
} }
CEntity* ScriptLoader::LoadEffect(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadEffect(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -696,7 +696,7 @@ CEntity* ScriptLoader::LoadGenerator(CStateManager& mgr, CInputStream& in, int p
if (!EnsurePropertyCount(propCount, 8, "Generator")) if (!EnsurePropertyCount(propCount, 8, "Generator"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
u32 w1 = in.readUint32Big(); u32 w1 = in.readUint32Big();
bool b1 = in.readBool(); bool b1 = in.readBool();
@ -709,7 +709,7 @@ CEntity* ScriptLoader::LoadGenerator(CStateManager& mgr, CInputStream& in, int p
float f1 = in.readFloatBig(); float f1 = in.readFloatBig();
float f2 = in.readFloatBig(); float f2 = in.readFloatBig();
return new CScriptGenerator(mgr.AllocateUniqueId(), *name, info, w1, b1, v1, b2, b3, f1, f2); return new CScriptGenerator(mgr.AllocateUniqueId(), name, info, w1, b1, v1, b2, b3, f1, f2);
} }
CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -717,7 +717,7 @@ CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in, int propCo
if (!EnsurePropertyCount(propCount, 7, "Dock")) if (!EnsurePropertyCount(propCount, 7, "Dock"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
bool active = in.readBool(); bool active = in.readBool();
zeus::CVector3f position; zeus::CVector3f position;
position.readBig(in); position.readBig(in);
@ -726,7 +726,7 @@ CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in, int propCo
u32 dock = in.readUint32Big(); u32 dock = in.readUint32Big();
TAreaId area = in.readUint32Big(); TAreaId area = in.readUint32Big();
bool b1 = in.readBool(); bool b1 = in.readBool();
return new CScriptDock(mgr.AllocateUniqueId(), *name, info, position, scale, dock, area, active, 0, b1); return new CScriptDock(mgr.AllocateUniqueId(), name, info, position, scale, dock, area, active, 0, b1);
} }
CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -815,7 +815,7 @@ CEntity* ScriptLoader::LoadSpawnPoint(CStateManager& mgr, CInputStream& in, int
if (!EnsurePropertyCount(propCount, 35, "SpawnPoint")) if (!EnsurePropertyCount(propCount, 35, "SpawnPoint"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f position; zeus::CVector3f position;
position.readBig(in); position.readBig(in);
@ -834,7 +834,7 @@ CEntity* ScriptLoader::LoadSpawnPoint(CStateManager& mgr, CInputStream& in, int
if (propCount > 34) if (propCount > 34)
morphed = in.readBool(); morphed = in.readBool();
return new CScriptSpawnPoint(mgr.AllocateUniqueId(), *name, info, return new CScriptSpawnPoint(mgr.AllocateUniqueId(), name, info,
ConvertEditorEulerToTransform4f(rotation, position), itemCounts, defaultSpawn, active, morphed); ConvertEditorEulerToTransform4f(rotation, position), itemCounts, defaultSpawn, active, morphed);
} }
@ -929,27 +929,27 @@ CEntity* ScriptLoader::LoadMemoryRelay(CStateManager& mgr, CInputStream& in, int
if (!EnsurePropertyCount(propCount, 3, "MemoryRelay") || propCount > 4) if (!EnsurePropertyCount(propCount, 3, "MemoryRelay") || propCount > 4)
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
bool b1 = in.readBool(); bool b1 = in.readBool();
bool b2 = in.readBool(); bool b2 = in.readBool();
bool b3 = false; bool b3 = false;
if (propCount > 3) if (propCount > 3)
b3 = in.readBool(); b3 = in.readBool();
return new CScriptMemoryRelay(mgr.AllocateUniqueId(), *name, info, b1, b2, b3); return new CScriptMemoryRelay(mgr.AllocateUniqueId(), name, info, b1, b2, b3);
} }
CEntity* ScriptLoader::LoadRandomRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadRandomRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
{ {
if (!EnsurePropertyCount(propCount, 5, "RandomRelay")) if (!EnsurePropertyCount(propCount, 5, "RandomRelay"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
u32 w1 = in.readUint32Big(); u32 w1 = in.readUint32Big();
u32 w2 = in.readUint32Big(); u32 w2 = in.readUint32Big();
bool b1 = in.readBool(); bool b1 = in.readBool();
bool b2 = in.readBool(); bool b2 = in.readBool();
return new CScriptRandomRelay(mgr.AllocateUniqueId(), *name, info, w1, w2, b1, b2); return new CScriptRandomRelay(mgr.AllocateUniqueId(), name, info, w1, w2, b1, b2);
} }
CEntity* ScriptLoader::LoadRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -957,19 +957,19 @@ CEntity* ScriptLoader::LoadRelay(CStateManager& mgr, CInputStream& in, int propC
if (!EnsurePropertyCount(propCount, 2, "Relay") || propCount > 3) if (!EnsurePropertyCount(propCount, 2, "Relay") || propCount > 3)
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
if (propCount >= 3) if (propCount >= 3)
in.readUint32Big(); in.readUint32Big();
bool b1 = in.readBool(); bool b1 = in.readBool();
return new CScriptRelay(mgr.AllocateUniqueId(), *name, info, b1); return new CScriptRelay(mgr.AllocateUniqueId(), name, info, b1);
} }
CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
{ {
if (!EnsurePropertyCount(propCount, 16, "Beetle")) if (!EnsurePropertyCount(propCount, 16, "Beetle"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big()); CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big());
zeus::CTransform xfrm = LoadEditorTransform(in); zeus::CTransform xfrm = LoadEditorTransform(in);
zeus::CVector3f scale = zeus::CVector3f::ReadBig(in); zeus::CVector3f scale = zeus::CVector3f::ReadBig(in);
@ -1000,7 +1000,7 @@ CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int prop
const CAnimationParameters& animParams = pInfo.GetAnimationParameters(); const CAnimationParameters& animParams = pInfo.GetAnimationParameters();
CAnimRes animRes(animParams.GetACSFile(), animParams.GetCharacter(), scale, animParams.GetInitialAnimation(), true); CAnimRes animRes(animParams.GetACSFile(), animParams.GetCharacter(), scale, animParams.GetInitialAnimation(), true);
return new MP1::CBeetle(mgr.AllocateUniqueId(), *name, info, xfrm, animRes, pInfo, flavor, entrance, dInfo, dVuln2, return new MP1::CBeetle(mgr.AllocateUniqueId(), name, info, xfrm, animRes, pInfo, flavor, entrance, dInfo, dVuln2,
v1, f2, f3, f1, dVuln1, aParams, abdomenRes); v1, f2, f3, f1, dVuln1, aParams, abdomenRes);
} }
@ -1008,7 +1008,7 @@ CEntity* ScriptLoader::LoadHUDMemo(CStateManager& mgr, CInputStream& in, int pro
{ {
if (propCount != 5 && !EnsurePropertyCount(propCount, 6, "HUDMemo")) if (propCount != 5 && !EnsurePropertyCount(propCount, 6, "HUDMemo"))
return 0; return 0;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
CHUDMemoParms hParms(in); CHUDMemoParms hParms(in);
CScriptHUDMemo::EDisplayType displayType = CScriptHUDMemo::EDisplayType::MessageBox; CScriptHUDMemo::EDisplayType displayType = CScriptHUDMemo::EDisplayType::MessageBox;
if (propCount == 6) if (propCount == 6)
@ -1016,7 +1016,7 @@ CEntity* ScriptLoader::LoadHUDMemo(CStateManager& mgr, CInputStream& in, int pro
ResId message = in.readUint32Big(); ResId message = in.readUint32Big();
bool active = in.readBool(); bool active = in.readBool();
return new CScriptHUDMemo(mgr.AllocateUniqueId(), *name, info, hParms, displayType, message, active); return new CScriptHUDMemo(mgr.AllocateUniqueId(), name, info, hParms, displayType, message, active);
} }
CEntity* ScriptLoader::LoadCameraFilterKeyframe(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadCameraFilterKeyframe(CStateManager& mgr, CInputStream& in, int propCount,
@ -1024,7 +1024,7 @@ CEntity* ScriptLoader::LoadCameraFilterKeyframe(CStateManager& mgr, CInputStream
{ {
if (!EnsurePropertyCount(propCount, 10, "CameraFilterKeyframe")) if (!EnsurePropertyCount(propCount, 10, "CameraFilterKeyframe"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
bool active = in.readBool(); bool active = in.readBool();
u32 w1 = in.readUint32Big(); u32 w1 = in.readUint32Big();
u32 w2 = in.readUint32Big(); u32 w2 = in.readUint32Big();
@ -1036,7 +1036,7 @@ CEntity* ScriptLoader::LoadCameraFilterKeyframe(CStateManager& mgr, CInputStream
float f2 = in.readFloatBig(); float f2 = in.readFloatBig();
u32 w5 = in.readUint32Big(); u32 w5 = in.readUint32Big();
return new CScriptCameraFilterKeyframe(mgr.AllocateUniqueId(), *name, info, w1, w2, w3, w4, color, f1, f2, w5, return new CScriptCameraFilterKeyframe(mgr.AllocateUniqueId(), name, info, w1, w2, w3, w4, color, f1, f2, w5,
active); active);
} }
@ -1046,7 +1046,7 @@ CEntity* ScriptLoader::LoadCameraBlurKeyframe(CStateManager& mgr, CInputStream&
if (!EnsurePropertyCount(propCount, 7, "CameraBlurKeyframe")) if (!EnsurePropertyCount(propCount, 7, "CameraBlurKeyframe"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
bool active = in.readBool(); bool active = in.readBool();
u32 w1 = in.readUint32Big(); u32 w1 = in.readUint32Big();
float f1 = in.readFloatBig(); float f1 = in.readFloatBig();
@ -1054,7 +1054,7 @@ CEntity* ScriptLoader::LoadCameraBlurKeyframe(CStateManager& mgr, CInputStream&
float f2 = in.readFloatBig(); float f2 = in.readFloatBig();
float f3 = in.readFloatBig(); float f3 = in.readFloatBig();
return new CScriptCameraBlurKeyframe(mgr.AllocateUniqueId(), *name, info, w1, f1, w2, f2, f3, active); return new CScriptCameraBlurKeyframe(mgr.AllocateUniqueId(), name, info, w1, f1, w2, f2, f3, active);
} }
u32 ClassifyVector(const zeus::CVector3f& dir) u32 ClassifyVector(const zeus::CVector3f& dir)
@ -1101,7 +1101,7 @@ CEntity* ScriptLoader::LoadDamageableTrigger(CStateManager& mgr, CInputStream& i
if (!EnsurePropertyCount(propCount, 12, "DamageableTrigger")) if (!EnsurePropertyCount(propCount, 12, "DamageableTrigger"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f position(zeus::CVector3f::ReadBig(in)); zeus::CVector3f position(zeus::CVector3f::ReadBig(in));
zeus::CVector3f volume(zeus::CVector3f::ReadBig(in)); zeus::CVector3f volume(zeus::CVector3f::ReadBig(in));
@ -1115,7 +1115,7 @@ CEntity* ScriptLoader::LoadDamageableTrigger(CStateManager& mgr, CInputStream& i
CScriptDamageableTrigger::ECanOrbit canOrbit = CScriptDamageableTrigger::ECanOrbit(in.readBool()); CScriptDamageableTrigger::ECanOrbit canOrbit = CScriptDamageableTrigger::ECanOrbit(in.readBool());
bool active = in.readBool(); bool active = in.readBool();
CVisorParameters vParms = LoadVisorParameters(in); CVisorParameters vParms = LoadVisorParameters(in);
return new CScriptDamageableTrigger(mgr.AllocateUniqueId(), *name, info, position, volume, hInfo, dVuln, return new CScriptDamageableTrigger(mgr.AllocateUniqueId(), name, info, position, volume, hInfo, dVuln,
triggerFlags, w1, w2, w3, canOrbit, active, vParms); triggerFlags, w1, w2, w3, canOrbit, active, vParms);
} }
@ -1158,7 +1158,7 @@ CEntity* ScriptLoader::LoadActorKeyframe(CStateManager& mgr, CInputStream& in, i
if (!EnsurePropertyCount(propCount, 7, "ActorKeyframe")) if (!EnsurePropertyCount(propCount, 7, "ActorKeyframe"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
s32 w1 = in.readInt32Big(); s32 w1 = in.readInt32Big();
bool b1 = in.readBool(); bool b1 = in.readBool();
float f1 = in.readFloatBig(); float f1 = in.readFloatBig();
@ -1169,7 +1169,7 @@ CEntity* ScriptLoader::LoadActorKeyframe(CStateManager& mgr, CInputStream& in, i
if (w1 == -1) if (w1 == -1)
return nullptr; return nullptr;
return new CScriptActorKeyframe(mgr.AllocateUniqueId(), *name, info, w1, b1, f1, false, w2, active, f2); return new CScriptActorKeyframe(mgr.AllocateUniqueId(), name, info, w1, b1, f1, false, w2, active, f2);
} }
CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -1177,7 +1177,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propC
if (!EnsurePropertyCount(propCount, 63, "Water")) if (!EnsurePropertyCount(propCount, 63, "Water"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f position; zeus::CVector3f position;
position.readBig(in); position.readBig(in);
zeus::CVector3f extent; zeus::CVector3f extent;
@ -1188,7 +1188,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propC
ETriggerFlags triggerFlags = ETriggerFlags(in.readUint32Big()) | ETriggerFlags::DetectProjectiles1 | ETriggerFlags triggerFlags = ETriggerFlags(in.readUint32Big()) | ETriggerFlags::DetectProjectiles1 |
ETriggerFlags::DetectProjectiles2 | ETriggerFlags::DetectProjectiles3 | ETriggerFlags::DetectProjectiles2 | ETriggerFlags::DetectProjectiles3 |
ETriggerFlags::DetectProjectiles4 | ETriggerFlags::DetectBombs | ETriggerFlags::DetectProjectiles4 | ETriggerFlags::DetectBombs |
ETriggerFlags::Unknown1 | ETriggerFlags::DetectProjectiles5 | ETriggerFlags::DetectPowerBombs | ETriggerFlags::DetectProjectiles5 |
ETriggerFlags::DetectProjectiles6 | ETriggerFlags::DetectProjectiles7; ETriggerFlags::DetectProjectiles6 | ETriggerFlags::DetectProjectiles7;
bool b1 = in.readBool(); bool b1 = in.readBool();
bool displaySurface = in.readBool(); bool displaySurface = in.readBool();
@ -1280,7 +1280,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propC
realTextureId5 = textureId5; realTextureId5 = textureId5;
return new CScriptWater( return new CScriptWater(
mgr, mgr.AllocateUniqueId(), *name, info, position, box, dInfo, orientedForce, triggerFlags, b1, displaySurface, mgr, mgr.AllocateUniqueId(), name, info, position, box, dInfo, orientedForce, triggerFlags, b1, displaySurface,
textureId1, textureId2, textureId3, textureId4, realTextureId5, realTextureId6, -1, otherV2, f1, f2, f3, active, textureId1, textureId2, textureId3, textureId4, realTextureId5, realTextureId6, -1, otherV2, f1, f2, f3, active,
fluidType, b4, f4, fluidMotion, f5, f6, f7, f8, f9, f10, f11, f12, c1, c2, enterParticle, partId2, partId3, fluidType, b4, f4, fluidMotion, f5, f6, f7, f8, f9, f10, f11, f12, c1, c2, enterParticle, partId2, partId3,
partId4, partId5, soundId1, soundId2, soundId3, soundId4, soundId5, f13, w19, f14, f15, f16, f17, f18, f19, partId4, partId5, soundId1, soundId2, soundId3, soundId4, soundId5, f13, w19, f14, f15, f16, f17, f18, f19,
@ -1292,7 +1292,7 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in, int pro
if (!EnsurePropertyCount(propCount, 13, "WarWasp")) if (!EnsurePropertyCount(propCount, 13, "WarWasp"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big()); CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big());
zeus::CTransform xf = LoadEditorTransformPivotOnly(in); zeus::CTransform xf = LoadEditorTransformPivotOnly(in);
zeus::CVector3f scale; zeus::CVector3f scale;
@ -1318,7 +1318,7 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in, int pro
CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), scale, true, aParms.GetInitialAnimation()); CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), scale, true, aParms.GetInitialAnimation());
CModelData mData(res); CModelData mData(res);
return new MP1::CWarWasp(mgr.AllocateUniqueId(), *name, info, xf, std::move(mData), pInfo, flavor, collider, return new MP1::CWarWasp(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, flavor, collider,
damageInfo1, actorParms, weaponDesc, damageInfo2, particle, w1); damageInfo1, actorParms, weaponDesc, damageInfo2, particle, w1);
} }
@ -1416,11 +1416,11 @@ CEntity* ScriptLoader::LoadGrapplePoint(CStateManager& mgr, CInputStream& in, in
if (!EnsurePropertyCount(propCount, 5, "GrapplePoint")) if (!EnsurePropertyCount(propCount, 5, "GrapplePoint"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CTransform grappleXf = LoadEditorTransform(in); zeus::CTransform grappleXf = LoadEditorTransform(in);
bool active = in.readBool(); bool active = in.readBool();
CGrappleParameters parameters = LoadGrappleParameters(in); CGrappleParameters parameters = LoadGrappleParameters(in);
return new CScriptGrapplePoint(mgr.AllocateUniqueId(), *name, info, grappleXf, active, parameters); return new CScriptGrapplePoint(mgr.AllocateUniqueId(), name, info, grappleXf, active, parameters);
} }
CEntity* ScriptLoader::LoadPuddleSpore(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadPuddleSpore(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -1450,7 +1450,7 @@ CEntity* ScriptLoader::LoadDistanceFog(CStateManager& mgr, CInputStream& in, int
if (!EnsurePropertyCount(propCount, 8, "DistanceFog")) if (!EnsurePropertyCount(propCount, 8, "DistanceFog"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
u32 mode = in.readUint32Big(); u32 mode = in.readUint32Big();
zeus::CColor color; zeus::CColor color;
color.readRGBABig(in); color.readRGBABig(in);
@ -1476,7 +1476,7 @@ CEntity* ScriptLoader::LoadDistanceFog(CStateManager& mgr, CInputStream& in, int
else if (mode == 5) else if (mode == 5)
realMode = ERglFogMode::PerspRevExp2; realMode = ERglFogMode::PerspRevExp2;
return new CScriptDistanceFog(mgr.AllocateUniqueId(), *name, info, realMode, color, range, colorDelta, rangeDelta, return new CScriptDistanceFog(mgr.AllocateUniqueId(), name, info, realMode, color, range, colorDelta, rangeDelta,
expl, active, 0.f, 0.f, 0.f, 0.f); expl, active, 0.f, 0.f, 0.f, 0.f);
} }
@ -1495,11 +1495,11 @@ CEntity* ScriptLoader::LoadDockAreaChange(CStateManager& mgr, CInputStream& in,
if (!EnsurePropertyCount(propCount, 3, "DockAreaChange")) if (!EnsurePropertyCount(propCount, 3, "DockAreaChange"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
s32 w1 = in.readInt32Big(); s32 w1 = in.readInt32Big();
bool active = in.readBool(); bool active = in.readBool();
return new CScriptDockAreaChange(mgr.AllocateUniqueId(), *name, info, w1, active); return new CScriptDockAreaChange(mgr.AllocateUniqueId(), name, info, w1, active);
} }
CEntity* ScriptLoader::LoadActorRotate(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadActorRotate(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -1507,14 +1507,14 @@ CEntity* ScriptLoader::LoadActorRotate(CStateManager& mgr, CInputStream& in, int
if (!EnsurePropertyCount(propCount, 6, "ActorRotate")) if (!EnsurePropertyCount(propCount, 6, "ActorRotate"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f rotation = zeus::CVector3f::ReadBig(in); zeus::CVector3f rotation = zeus::CVector3f::ReadBig(in);
float scale = in.readFloatBig(); float scale = in.readFloatBig();
bool b1 = in.readBool(); bool b1 = in.readBool();
bool b2 = in.readBool(); bool b2 = in.readBool();
bool active = in.readBool(); bool active = in.readBool();
return new CScriptActorRotate(mgr.AllocateUniqueId(), *name, info, rotation, scale, b1, b2, active); return new CScriptActorRotate(mgr.AllocateUniqueId(), name, info, rotation, scale, b1, b2, active);
} }
CEntity* ScriptLoader::LoadSpecialFunction(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadSpecialFunction(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -1571,11 +1571,11 @@ CEntity* ScriptLoader::LoadPickupGenerator(CStateManager& mgr, CInputStream& in,
if (!EnsurePropertyCount(propCount, 4, "PickupGenerator")) if (!EnsurePropertyCount(propCount, 4, "PickupGenerator"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f pos = zeus::CVector3f::ReadBig(in); zeus::CVector3f pos = zeus::CVector3f::ReadBig(in);
bool active = in.readBool(); bool active = in.readBool();
float f1 = in.readFloatBig(); float f1 = in.readFloatBig();
return new CScriptPickupGenerator(mgr.AllocateUniqueId(), *name, info, pos, f1, active); return new CScriptPickupGenerator(mgr.AllocateUniqueId(), name, info, pos, f1, active);
} }
CEntity* ScriptLoader::LoadAIKeyframe(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadAIKeyframe(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -1716,12 +1716,12 @@ CEntity* ScriptLoader::LoadSwitch(CStateManager& mgr, CInputStream& in, int prop
if (!EnsurePropertyCount(propCount, 4, "Switch")) if (!EnsurePropertyCount(propCount, 4, "Switch"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
bool active = in.readBool(); bool active = in.readBool();
bool b2 = in.readBool(); bool b2 = in.readBool();
bool b3 = in.readBool(); bool b3 = in.readBool();
return new CScriptSwitch(mgr.AllocateUniqueId(), *name, info, active, b2, b3); return new CScriptSwitch(mgr.AllocateUniqueId(), name, info, active, b2, b3);
} }
CEntity* ScriptLoader::LoadPlayerStateChange(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadPlayerStateChange(CStateManager& mgr, CInputStream& in, int propCount,
@ -1769,7 +1769,7 @@ CEntity* ScriptLoader::LoadColorModulate(CStateManager& mgr, CInputStream& in, i
if (!EnsurePropertyCount(propCount, 12, "ColorModulate")) if (!EnsurePropertyCount(propCount, 12, "ColorModulate"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CColor c1; zeus::CColor c1;
c1.readRGBABig(in); c1.readRGBABig(in);
zeus::CColor c2; zeus::CColor c2;
@ -1783,7 +1783,7 @@ CEntity* ScriptLoader::LoadColorModulate(CStateManager& mgr, CInputStream& in, i
bool b4 = in.readBool(); bool b4 = in.readBool();
bool b5 = in.readBool(); bool b5 = in.readBool();
bool active = in.readBool(); bool active = in.readBool();
return new CScriptColorModulate(mgr.AllocateUniqueId(), *name, info, c1, c2, bm, f1, f2, b1, b2, b3, b4, b5, return new CScriptColorModulate(mgr.AllocateUniqueId(), name, info, c1, c2, bm, f1, f2, b1, b2, b3, b4, b5,
active); active);
} }
@ -1798,12 +1798,12 @@ CEntity* ScriptLoader::LoadMidi(CStateManager& mgr, CInputStream& in, int propCo
return nullptr; return nullptr;
} }
CEntity* ScriptLoader::LoadStreamedMusic(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadStreamedAudio(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
{ {
if (!EnsurePropertyCount(propCount, 9, "StreamedAudio")) if (!EnsurePropertyCount(propCount, 9, "StreamedAudio"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); const std::string name = mgr.HashInstanceName(in);
bool b1 = in.readBool(); bool b1 = in.readBool();
std::string fileName = in.readString(); std::string fileName = in.readString();
bool b2 = in.readBool(); bool b2 = in.readBool();
@ -1813,7 +1813,7 @@ CEntity* ScriptLoader::LoadStreamedMusic(CStateManager& mgr, CInputStream& in, i
u32 w2 = in.readUint32Big(); u32 w2 = in.readUint32Big();
bool b3 = in.readBool(); bool b3 = in.readBool();
return new CScriptStreamedMusic(mgr.AllocateUniqueId(), info, *name, b1, fileName, b2, f1, f2, w1, !w2, b3); return new CScriptStreamedMusic(mgr.AllocateUniqueId(), info, name, b1, fileName, b2, f1, f2, w1, !w2, b3);
} }
CEntity* ScriptLoader::LoadRepulsor(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadRepulsor(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -1821,12 +1821,12 @@ CEntity* ScriptLoader::LoadRepulsor(CStateManager& mgr, CInputStream& in, int pr
if (!EnsurePropertyCount(propCount, 4, "Repulsor")) if (!EnsurePropertyCount(propCount, 4, "Repulsor"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f center = in.readVec3fBig(); zeus::CVector3f center = in.readVec3fBig();
bool active = in.readBool(); bool active = in.readBool();
float radius = in.readFloatBig(); float radius = in.readFloatBig();
return new CRepulsor(mgr.AllocateUniqueId(), active, *name, info, center, radius); return new CRepulsor(mgr.AllocateUniqueId(), active, name, info, center, radius);
} }
CEntity* ScriptLoader::LoadGunTurret(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadGunTurret(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
@ -1854,7 +1854,7 @@ CEntity* ScriptLoader::LoadRadialDamage(CStateManager& mgr, CInputStream& in, in
if (!EnsurePropertyCount(propCount, 5, "RadialDamage")) if (!EnsurePropertyCount(propCount, 5, "RadialDamage"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f center = zeus::CVector3f::ReadBig(in); zeus::CVector3f center = zeus::CVector3f::ReadBig(in);
bool active = in.readBool(); bool active = in.readBool();
CDamageInfo dInfo(in); CDamageInfo dInfo(in);
@ -1862,7 +1862,7 @@ CEntity* ScriptLoader::LoadRadialDamage(CStateManager& mgr, CInputStream& in, in
zeus::CTransform xf = ConvertEditorEulerToTransform4f(zeus::CVector3f::skZero, center); zeus::CTransform xf = ConvertEditorEulerToTransform4f(zeus::CVector3f::skZero, center);
return new CScriptSpecialFunction( return new CScriptSpecialFunction(
mgr.AllocateUniqueId(), *name, info, xf, CScriptSpecialFunction::ESpecialFunction::RadialDamage, "", radius, mgr.AllocateUniqueId(), name, info, xf, CScriptSpecialFunction::ESpecialFunction::RadialDamage, "", radius,
0.f, 0.f, 0.f, zeus::CVector3f::skZero, zeus::CColor::skBlack, active, dInfo, -1, -1, -1, -1, -1, -1); 0.f, 0.f, 0.f, zeus::CVector3f::skZero, zeus::CColor::skBlack, active, dInfo, -1, -1, -1, -1, -1, -1);
} }
@ -2080,7 +2080,7 @@ CEntity* ScriptLoader::LoadShadowProjector(CStateManager& mgr, CInputStream& in,
if (!EnsurePropertyCount(propCount, 10, "ShadowProjector")) if (!EnsurePropertyCount(propCount, 10, "ShadowProjector"))
return nullptr; return nullptr;
const std::string* name = mgr.HashInstanceName(in); std::string name = mgr.HashInstanceName(in);
zeus::CVector3f position(zeus::CVector3f::ReadBig(in)); zeus::CVector3f position(zeus::CVector3f::ReadBig(in));
bool b1 = in.readBool(); bool b1 = in.readBool();
float f1 = in.readFloatBig(); float f1 = in.readFloatBig();
@ -2090,7 +2090,7 @@ CEntity* ScriptLoader::LoadShadowProjector(CStateManager& mgr, CInputStream& in,
float f4 = in.readFloatBig(); float f4 = in.readFloatBig();
bool b2 = in.readBool(); bool b2 = in.readBool();
u32 w1 = in.readUint32Big(); u32 w1 = in.readUint32Big();
return new CScriptShadowProjector(mgr.AllocateUniqueId(), *name, info, zeus::CTransform::Translate(position), b1, return new CScriptShadowProjector(mgr.AllocateUniqueId(), name, info, zeus::CTransform::Translate(position), b1,
vec2, b2, f1, f2, f3, f4, w1); vec2, b2, f1, f2, f3, f4, w1);
} }

View File

@ -123,7 +123,7 @@ public:
static CEntity* LoadColorModulate(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadColorModulate(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadThardusRockProjectile(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadThardusRockProjectile(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadMidi(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadMidi(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadStreamedMusic(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadStreamedAudio(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadRepulsor(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadRepulsor(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadGunTurret(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadGunTurret(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadFogVolume(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadFogVolume(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);