Finish CScriptActor

This commit is contained in:
Phillip Stephens 2017-02-12 16:00:07 -08:00
parent 6857e219b4
commit e062de1429
6 changed files with 103 additions and 30 deletions

View File

@ -320,7 +320,7 @@ void CStateManager::DrawSpaceWarp(const zeus::CVector3f& v, float strength) cons
CPlayerState::EPlayerVisor visor = x8b8_playerState->GetActiveVisor(*this);
if (visor == CPlayerState::EPlayerVisor::Scan || visor == CPlayerState::EPlayerVisor::Combat)
{
zeus::CVector3f screenV = x870_cameraManager->GetCurrentCamera(*this)->ConvertToScreenSpace(v);
zeus::CVector3f screenV = TCastToConstPtr<CGameCamera>(x870_cameraManager->GetCurrentCamera(*this))->ConvertToScreenSpace(v);
g_Renderer->DrawSpaceWarp(screenV, strength);
}
}

View File

@ -33,13 +33,13 @@ CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCamera
zeus::CVector3f CCameraManager::GetGlobalCameraTranslation(const CStateManager& stateMgr) const
{
const CGameCamera* camera = GetCurrentCamera(stateMgr);
TCastToConstPtr<CGameCamera> camera(GetCurrentCamera(stateMgr));
return camera->GetTransform() * x30_shakeOffset;
}
zeus::CTransform CCameraManager::GetCurrentCameraTransform(const CStateManager& stateMgr) const
{
const CGameCamera* camera = GetCurrentCamera(stateMgr);
TCastToConstPtr<CGameCamera> camera(GetCurrentCamera(stateMgr));
return camera->GetTransform() * zeus::CTransform::Translate(x30_shakeOffset);
}
@ -141,16 +141,16 @@ void CCameraManager::Update(float dt, CStateManager& stateMgr)
#endif
}
CGameCamera* CCameraManager::GetCurrentCamera(CStateManager& stateMgr) const
CEntity* CCameraManager::GetCurrentCamera(CStateManager& stateMgr) const
{
CObjectList* camList = stateMgr.ObjectListById(EGameObjectList::GameCamera);
return TCastToPtr<CGameCamera>(camList->GetObjectById(GetCurrentCameraId())).GetPtr();
return camList->GetObjectById(GetCurrentCameraId());
}
const CGameCamera* CCameraManager::GetCurrentCamera(const CStateManager& stateMgr) const
const CEntity* CCameraManager::GetCurrentCamera(const CStateManager& stateMgr) const
{
const CObjectList* camList = stateMgr.GetObjectListById(EGameObjectList::GameCamera);
return static_cast<const CGameCamera*>(camList->GetObjectById(GetCurrentCameraId()));
return camList->GetObjectById(GetCurrentCameraId());
}
float CCameraManager::sub80009148() const

View File

@ -81,8 +81,8 @@ public:
void AddCinemaCamera(TUniqueId, CStateManager& stateMgr);
void SetInsideFluid(bool, TUniqueId);
void Update(float dt, CStateManager& stateMgr);
CGameCamera* GetCurrentCamera(CStateManager& stateMgr) const;
const CGameCamera* GetCurrentCamera(const CStateManager& stateMgr) const;
CEntity* GetCurrentCamera(CStateManager& stateMgr) const;
const CEntity* GetCurrentCamera(const CStateManager& stateMgr) const;
void SetCurrentCameraId(TUniqueId id, CStateManager& stateMgr) {x0_curCameraId = id;}
TUniqueId GetCurrentCameraId() const
{

View File

@ -22,12 +22,12 @@ CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntity
, x2d8_(w1)
, x2dc_xrayAlpha(f3)
, x2e2_24_(b2)
, x2e2_25_(false)
, x2e2_26_(true)
, x2e2_25_dead(false)
, x2e2_26_animating(true)
, x2e2_27_(std::fabs(f3 - 1.f) > 0.00001)
, x2e2_28_(false)
, x2e2_29_((x2e2_24_ && x2e2_25_ && x2d8_ != 0))
, x2e2_30_(b4)
, x2e2_29_((x2e2_24_ && x2e2_25_dead && x2d8_ != 0))
, x2e2_30_transposeRotate(b4)
, x2e2_31_(b5)
{
if (x64_modelData && (x64_modelData->HasAnimData() || x64_modelData->HasNormalModel()) && castsShadow)
@ -45,17 +45,17 @@ void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
{
if (msg == EScriptObjectMessage::Reset)
{
x2e2_25_ = false;
x2e2_25_dead = false;
x260_currentHealth = x258_initialHealth;
}
else if (msg == EScriptObjectMessage::Increment && !GetActive())
{
mgr.SendScriptMsg(this, x8_uid, EScriptObjectMessage::Activate);
CScriptColorModulate::FadeInHelper(mgr, x8_uid, x2d0_);
CScriptColorModulate::FadeInHelper(mgr, x8_uid, x2d0_alphaMax);
}
else if (msg == EScriptObjectMessage::Decrement)
{
CScriptColorModulate::FadeOutHelper(mgr, x8_uid, x2d4_);
CScriptColorModulate::FadeOutHelper(mgr, x8_uid, x2d4_alphaMin);
}
else if (msg == EScriptObjectMessage::InternalMessage13)
{
@ -89,14 +89,87 @@ void CScriptActor::Think(float dt, CStateManager& mgr)
if (HasModelData() && x64_modelData->HasAnimData())
{
bool animTimeRemaining = x64_modelData->GetAnimationData()->IsAnimTimeRemaining(dt - FLT_EPSILON, "Whole Body");
bool timeRemaining = x64_modelData->GetAnimationData()->IsAnimTimeRemaining(dt - FLT_EPSILON, "Whole Body");
bool loop = x64_modelData->GetIsLoop();
CActor::UpdateAnimation(dt, mgr, true);
SAdvancementDeltas deltas = CActor::UpdateAnimation(dt, mgr, true);
if (timeRemaining || loop)
{
x2e2_26_animating = true;
if (x2e2_30_transposeRotate)
MoveToOR(
x34_transform.rotate(x64_modelData->GetScale() * x34_transform.transposeRotate(deltas.x0_posDelta)),
dt);
else
MoveToOR(deltas.x0_posDelta, dt);
RotateToOR(deltas.xc_rotDelta, dt);
}
if (!timeRemaining && x2e2_26_animating && !loop)
{
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
x2e2_26_animating = false;
}
}
if (!x2e2_25_dead && HealthInfo()->GetHP() <= 0.f)
{
x2e2_25_dead = true;
SendScriptMsgs(EScriptObjectState::Dead, mgr, EScriptObjectMessage::None);
}
}
void CScriptActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {}
void CScriptActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
{
CActor::PreRender(mgr, frustum);
if (xe4_30_ && TCastToPtr<CCinematicCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr)))
xe4_30_ = false;
if (xe4_30_ && !x2e2_29_ && !x2e2_27_)
{
zeus::CColor col(1.f, 1.f, x2dc_xrayAlpha);
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)
{
xb4_ = 5;
xb5_ = 0;
xb6_ = 3;
xb8_ = col;
x2e2_28_ = true;
}
if (x2e2_28_)
{
x2e2_28_ = false;
if (xb4_ != 5 && xb5_ != 0 && xb4_ != 3 && xb8_ != col)
{
xb4_ = 5;
xb5_ = 0;
xb6_ = 3;
xb8_ = col;
}
}
if (!x2e2_24_ && xe6_27_ == 2 &&
mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)
{
xb6_ &= ~3;
}
else
{
xb6_ |= 3;
}
if (x2d8_ != 0)
xb5_ = 0;
}
if (mgr.GetObjectById(x2e0_triggerId) == nullptr)
x2e0_triggerId = kInvalidUniqueId;
}
zeus::CAABox CScriptActor::GetSortingBounds(const CStateManager& mgr) const
{

View File

@ -14,18 +14,18 @@ protected:
CHealthInfo x258_initialHealth;
CHealthInfo x260_currentHealth;
CDamageVulnerability x268_damageVulnerability;
float x2d0_;
float x2d4_;
float x2d0_alphaMax;
float x2d4_alphaMin;
s32 x2d8_;
float x2dc_xrayAlpha;
TUniqueId x2e0_triggerId = kInvalidUniqueId;
bool x2e2_24_ : 1;
bool x2e2_25_ : 1;
bool x2e2_26_ : 1;
bool x2e2_25_dead : 1;
bool x2e2_26_animating : 1;
bool x2e2_27_ : 1;
bool x2e2_28_ : 1;
bool x2e2_29_ : 1;
bool x2e2_30_ : 1;
bool x2e2_30_transposeRotate : 1;
bool x2e2_31_ : 1;
bool x2e3_24_ : 1;

View File

@ -393,8 +393,8 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC
bool b1 = in.readBool();
bool snow = in.readBool();
bool grass = in.readBool();
bool metalGrating = in.readBool();
bool solid = in.readBool();
bool cameraPassthrough = in.readBool();
bool b5 = in.readBool();
u32 w2 = in.readUint32Big();
float f3 = in.readFloatBig();
@ -413,11 +413,11 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC
if (snow) // Bool 2
list.Add(EMaterialTypes::Snow);
if (grass) // Bool 3
list.Add(EMaterialTypes::Grass);
if (solid) // Bool 3
list.Add(EMaterialTypes::Solid);
if (metalGrating) // Bool 4
list.Add(EMaterialTypes::MetalGrating);
if (cameraPassthrough) // Bool 4
list.Add(EMaterialTypes::CameraPassthrough);
bool generateExtent = false;
if (collisionExtent.x < 0.f || collisionExtent.y < 0.f || collisionExtent.z < 0.f)