Minor CStateManager fixes, CScriptColorModulate imps

This commit is contained in:
Phillip Stephens 2016-08-18 11:34:06 -07:00
parent 9ca7f9c9e4
commit 0ef4dbc7d2
8 changed files with 211 additions and 47 deletions

View File

@ -292,8 +292,16 @@ u32 CPlayerState::GetItemCapacity(CPlayerState::EItemType type) const
u32 CPlayerState::GetItemAmount(CPlayerState::EItemType type) const
{
if (type != EItemType::ThermalVisor && type < EItemType::Max)
if (type == EItemType::SpaceJumpBoots ||
type == EItemType::PowerBombs ||
type == EItemType::Flamethrower ||
type == EItemType::EnergyTanks ||
type == EItemType::Missiles ||
(type >= EItemType::ArtifactOfTruth && type <= EItemType::ArtifactOfNewborn))
{
return x24_powerups[u32(type)].x0_amount;
}
return 0;
}

View File

@ -17,47 +17,47 @@ class CPlayerState
public:
enum class EItemType : u32
{
PowerBeam,
IceBeam,
WaveBeam,
PlasmaBeam,
Missiles,
ScanVisor,
MorphBallBombs,
PowerBombs,
Flamethrower,
ThermalVisor,
ChargeBeam,
SuperMissile,
GrappleBeam,
XRayVisor,
IceSpreader,
SpaceJumpBoots,
MorphBall,
CombatVisor,
BoostBall,
SpiderBall,
PowerSuit,
GravitySuit,
VariaSuit,
PhazonSuit,
EnergyTanks,
UnknownItem1,
HealthRefill,
UnknownItem2,
Wavebuster,
ArtifactOfTruth,
ArtifactOfStrength,
ArtifactOfElder,
ArtifactOfWild,
ArtifactOfLifegiver,
ArtifactOfWarrior,
ArtifactOfChozo,
ArtifactOfNature,
ArtifactOfSun,
ArtifactOfWorld,
ArtifactOfSpirit,
ArtifactOfNewborn,
PowerBeam = 0,
IceBeam = 1,
WaveBeam = 2,
PlasmaBeam = 3,
Missiles = 4,
ScanVisor = 5,
MorphBallBombs = 6,
PowerBombs = 7,
Flamethrower = 8,
ThermalVisor = 9,
ChargeBeam = 10,
SuperMissile = 11,
GrappleBeam = 12,
XRayVisor = 13,
IceSpreader = 14,
SpaceJumpBoots = 15,
MorphBall = 16,
CombatVisor = 17,
BoostBall = 18,
SpiderBall = 19,
PowerSuit = 20,
GravitySuit = 21,
VariaSuit = 22,
PhazonSuit = 23,
EnergyTanks = 24,
UnknownItem1 = 25,
HealthRefill = 26,
UnknownItem2 = 27,
Wavebuster = 28,
ArtifactOfTruth = 29,
ArtifactOfStrength = 30,
ArtifactOfElder = 31,
ArtifactOfWild = 32,
ArtifactOfLifegiver = 33,
ArtifactOfWarrior = 34,
ArtifactOfChozo = 35,
ArtifactOfNature = 36,
ArtifactOfSun = 37,
ArtifactOfWorld = 38,
ArtifactOfSpirit = 39,
ArtifactOfNewborn = 40,
/* This must remain at the end of the list */
Max

View File

@ -237,7 +237,7 @@ void CStateManager::UpdateThermalVisor()
}
}
void CStateManager::RenderLast(TUniqueId)
bool CStateManager::RenderLast(TUniqueId)
{
}
@ -376,6 +376,13 @@ void CStateManager::SendScriptMsg(TUniqueId dest, TUniqueId src, EScriptObjectMe
SendScriptMsg(ent, src, msg);
}
void CStateManager::SendScriptMsgAlways(TUniqueId dest, TUniqueId src, EScriptObjectMessage msg)
{
CEntity* dst = ObjectById(dest);
if (dst)
dst->AcceptScriptMsg(msg, src, *this);
}
void CStateManager::SendScriptMsg(TUniqueId src, TEditorId dest,
EScriptObjectMessage msg, EScriptObjectState state)
{
@ -562,7 +569,7 @@ void CStateManager::InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId)
CPlayerState::EItemType iType = CPlayerState::EItemType(i);
u32 spawnPu = sp->GetPowerup(iType);
u32 statePu = x8b8_playerState->GetItemCapacity(iType);
u32 statePu = x8b8_playerState->GetItemAmount(iType);
if (statePu < spawnPu)
x8b8_playerState->InitializePowerUp(iType, spawnPu - statePu);

View File

@ -174,7 +174,7 @@ public:
const std::weak_ptr<CPlayerState>&,
const std::weak_ptr<CWorldTransManager>&);
void RenderLast(TUniqueId);
bool RenderLast(TUniqueId);
void AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const;
void SpecialSkipCinematic();
void GetVisAreaId() const;
@ -208,6 +208,7 @@ public:
void SendScriptMsg(TUniqueId dest, TUniqueId src, EScriptObjectMessage msg);
void SendScriptMsg(TUniqueId src, TEditorId dest,
EScriptObjectMessage msg, EScriptObjectState state);
void SendScriptMsgAlways(TUniqueId dest, TUniqueId src, EScriptObjectMessage);
void FreeScriptObjects(TAreaId);
void GetBuildForScript(TEditorId) const;
TEditorId GetEditorIdForUniqueId(TUniqueId) const;
@ -297,7 +298,6 @@ public:
CAiWaypointList& GetAiWaypointObjectList() const { return *x83c_aiWaypointObjs; }
CPlatformAndDoorList& GetPlatformAndDoorObjectList() const { return *x844_platformAndDoorObjs; }
};
}
#endif

View File

@ -71,6 +71,7 @@ set(WORLD_SOURCES
CScriptDistanceFog.hpp CScriptDistanceFog.cpp
CScriptActorRotate.hpp CScriptActorRotate.cpp
CScriptSpecialFunction.hpp CScriptSpecialFunction.cpp
CScriptColorModulate.hpp CScriptColorModulate.cpp
CGrappleParameters.hpp
CActorParameters.hpp
CLightParameters.hpp

View File

@ -0,0 +1,74 @@
#include "CScriptColorModulate.hpp"
#include "Graphics/CModel.hpp"
#include "CStateManager.hpp"
namespace urde
{
CScriptColorModulate::CScriptColorModulate(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CColor& c1, const zeus::CColor& c2,
EBlendMode bm, float f1, float f2,
bool b1, bool b2, bool b3, bool b4, bool b5, bool active)
: CEntity(uid, info, active, name),
x40_(c1),
x44_(c2),
x48_blendMode(bm),
x4c_(f1),
x50_(f2),
x54_24_(b1),
x54_25_(b2),
x54_26_(b3),
x54_27_(b4),
x54_28_(b5)
{
}
void CScriptColorModulate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr)
{
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
}
void CScriptColorModulate::Think(float, CStateManager &)
{
}
zeus::CColor CScriptColorModulate::CalculateFlags(const zeus::CColor &) const
{
return {};
}
void CScriptColorModulate::SetTargetFlags(CStateManager &, const CModelFlags &)
{
}
void CScriptColorModulate::FadeOutHelper(CStateManager &, TUniqueId, float)
{
}
void CScriptColorModulate::FadeInHelper(CStateManager &, TUniqueId, float)
{
}
void CScriptColorModulate::End(CStateManager& stateMgr)
{
x3c_ = 0.f;
if (x54_24_ && !x54_29_)
{
x54_29_ = true;
x38_ = 0;
return;
}
x54_30_ = false;
x54_29_ = false;
if (x54_25_)
SetTargetFlags(stateMgr, CModelFlags(0, 0, 3, zeus::CColor::skWhite));
if (x54_24_)
stateMgr.SendScriptMsg(x8_uid, x34_, EScriptObjectMessage::Deactivate);
CEntity::SendScriptMsgs(EScriptObjectState::MaxReached, stateMgr, EScriptObjectMessage::None);
if (!x54_31_)
stateMgr.DeleteObjectRequest(x8_uid);
}
}

View File

@ -0,0 +1,56 @@
#ifndef __URDE_CSCRIPTCOLORMODULATE_HPP__
#define __URDE_CSCRIPTCOLORMODULATE_HPP__
#include "CEntity.hpp"
#include "zeus/CColor.hpp"
namespace urde
{
class CModelFlags;
class CScriptColorModulate : public CEntity
{
public:
enum class EBlendMode
{
};
private:
TUniqueId x34_ = kInvalidUniqueId;
u32 x38_ = 0;
float x3c_;
zeus::CColor x40_;
zeus::CColor x44_;
EBlendMode x48_blendMode;
float x4c_;
float x50_;
union
{
struct
{
bool x54_24_ : 1;
bool x54_25_ : 1;
bool x54_26_ : 1;
bool x54_27_ : 1;
bool x54_28_ : 1;
bool x54_29_ : 1;
bool x54_30_ : 1;
bool x54_31_ : 1;
bool x55_24_ : 1;
};
u32 _dummy = 0;
};
public:
CScriptColorModulate(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CColor&, const zeus::CColor&,
EBlendMode, float, float, bool, bool, bool, bool, bool, bool);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
void Think(float, CStateManager &);
zeus::CColor CalculateFlags(const zeus::CColor&) const;
void SetTargetFlags(CStateManager&, const CModelFlags&);
void FadeOutHelper(CStateManager&, TUniqueId, float);
void FadeInHelper(CStateManager&, TUniqueId, float);
void End(CStateManager&);
};
}
#endif // __URDE_CSCRIPTCOLORMODULATE_HPP__

View File

@ -42,6 +42,7 @@
#include "CScriptDistanceFog.hpp"
#include "CScriptActorRotate.hpp"
#include "CScriptSpecialFunction.hpp"
#include "CScriptColorModulate.hpp"
#include "Camera/CCinematicCamera.hpp"
#include "MP1/CNewIntroBoss.hpp"
#include "MP1/CBeetle.hpp"
@ -1767,7 +1768,24 @@ CEntity* ScriptLoader::LoadRoomAcoustics(CStateManager& mgr, CInputStream& in,
CEntity* ScriptLoader::LoadColorModulate(CStateManager& mgr, CInputStream& in,
int propCount, const CEntityInfo& info)
{
if (!EnsurePropertyCount(propCount, 12, "ColorModulate"))
return nullptr;
const std::string* name = mgr.HashInstanceName(in);
zeus::CColor c1;
c1.readRGBABig(in);
zeus::CColor c2;
c2.readRGBABig(in);
CScriptColorModulate::EBlendMode bm = CScriptColorModulate::EBlendMode(in.readUint32Big());
float f1 = in.readFloatBig();
float f2 = in.readFloatBig();
bool b1 = in.readBool();
bool b2 = in.readBool();
bool b3 = in.readBool();
bool b4 = in.readBool();
bool b5 = in.readBool();
bool active = in.readBool();
return new CScriptColorModulate(mgr.AllocateUniqueId(), *name, info, c1, c2, bm, f1, f2, b1, b2, b3, b4, b5, active);
}
CEntity* ScriptLoader::LoadThardusRockProjectile(CStateManager& mgr, CInputStream& in,