Merge branch 'master' into omegapirate

# Conflicts:
#	Runtime/GuiSys/CAuiImagePane.cpp
This commit is contained in:
Luke Street 2020-04-19 22:12:18 -04:00
commit 32c44cbf05
37 changed files with 149 additions and 130 deletions

View File

@ -8,6 +8,7 @@
#include "Runtime/rstl.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/AutoMapper/CMapUniverse.hpp"
#include "Runtime/MP1/CInGameGuiManager.hpp"
#include <zeus/CQuaternion.hpp>
@ -17,7 +18,6 @@
#include <zeus/CVector3f.hpp>
namespace urde {
class CMapUniverse;
class CMapWorldInfo;
class CStateManager;
class IWorld;

View File

@ -1377,7 +1377,11 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
in.readByte();
if (error || ent == nullptr) {
LogModule.report(logvisor::Error, FMT_STRING("Script load error while loading {}"), ScriptObjectTypeToStr(type));
in.seek(startPos, athena::SeekOrigin::Begin);
std::string name = HashInstanceName(in);
in.seek(startPos + length, athena::SeekOrigin::Begin);
LogModule.report(logvisor::Error, FMT_STRING("Script load error while loading {}, name: {}"),
ScriptObjectTypeToStr(type), name);
return {kInvalidEditorId, kInvalidUniqueId};
} else {
LogModule.report(logvisor::Info, FMT_STRING("Loaded {} in area {}"), ent->GetName(), ent->GetAreaIdAlways());

View File

@ -12,17 +12,17 @@ public:
double report(const char* name) const {
double t = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::steady_clock::now() - m_start).count() / 1000000.0;
#ifndef NDEBUG
fmt::print(FMT_STRING("{} {}\n"), name, t);
#endif
//#ifndef NDEBUG
// fmt::print(FMT_STRING("{} {}\n"), name, t);
//#endif
return t;
}
double reportReset(const char* name) {
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
double t = std::chrono::duration_cast<std::chrono::microseconds>(now - m_start).count() / 1000000.0;
#ifndef NDEBUG
fmt::print(FMT_STRING("{} {}\n"), name, t);
#endif
//#ifndef NDEBUG
// fmt::print(FMT_STRING("{} {}\n"), name, t);
//#endif
m_start = now;
return t;
}

View File

@ -107,7 +107,7 @@ public:
TToken(std::unique_ptr<T>&& obj) : CToken(GetIObjObjectFor(std::move(obj))) {}
TToken& operator=(std::unique_ptr<T>&& obj) {
*this = CToken(GetIObjObjectFor(std::move(obj)));
return this;
return *this;
}
virtual void Unlock() { CToken::Unlock(); }
virtual void Lock() { CToken::Lock(); }

View File

@ -5,14 +5,13 @@
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"
#include "Runtime/Graphics/Shaders/CXRayBlurFilter.hpp"
#include <zeus/CColor.hpp>
namespace urde {
class CTexture;
enum class EFilterType {
Passthru,
Multiply,

View File

@ -5,10 +5,10 @@
#include "Runtime/CRandom16.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/GCNTypes.hpp"
#include "Runtime/Character/CTransitionDatabaseGame.hpp"
namespace urde {
class CSimplePool;
class CTransitionDatabaseGame;
struct CAnimSysContext {
TToken<CTransitionDatabaseGame> x0_transDB;

View File

@ -3,13 +3,12 @@
#include <memory>
#include "Runtime/CToken.hpp"
#include "Runtime/Character/CAnimationDatabaseGame.hpp"
#include "Runtime/Character/CAnimSysContext.hpp"
namespace urde {
class CAnimTreeNode;
class CAnimationDatabaseGame;
class CSimplePool;
class CTransitionDatabaseGame;
class IMetaAnim;
struct CMetaAnimTreeBuildOrders;

View File

@ -5,6 +5,7 @@
#include <utility>
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Character/CCharLayoutInfo.hpp"
#include "Runtime/Character/CSegId.hpp"
#include <zeus/CMatrix3f.hpp>
@ -12,8 +13,6 @@
#include <zeus/CVector3f.hpp>
namespace urde {
class CCharLayoutInfo;
class CPoseAsTransforms {
friend class CAnimData;
public:

View File

@ -9,9 +9,9 @@
#include "Runtime/Character/CInt32POINode.hpp"
#include "Runtime/Character/CParticlePOINode.hpp"
#include "Runtime/Character/CSoundPOINode.hpp"
#include "Runtime/Character/CTransitionDatabaseGame.hpp"
namespace urde {
class CTransitionDatabaseGame;
class IMetaAnim;
class CSequenceFundamentals {

View File

@ -4,12 +4,12 @@
#include "Runtime/CToken.hpp"
#include "Runtime/Character/CAnimSysContext.hpp"
#include "Runtime/Character/CTransitionDatabaseGame.hpp"
namespace urde {
class CAnimTreeNode;
class CRandom16;
class CSimplePool;
class CTransitionDatabaseGame;
class CTransitionManager {
CAnimSysContext x0_animCtx;

View File

@ -14,15 +14,15 @@ namespace urde {
CActorList::CActorList() : CObjectList(EGameObjectList::Actor) {}
bool CActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CActor>(ent); }
bool CActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CActor>(ent).IsValid(); }
CPhysicsActorList::CPhysicsActorList() : CObjectList(EGameObjectList::PhysicsActor) {}
bool CPhysicsActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CPhysicsActor>(ent); }
bool CPhysicsActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CPhysicsActor>(ent).IsValid(); }
CGameCameraList::CGameCameraList() : CObjectList(EGameObjectList::GameCamera) {}
bool CGameCameraList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CGameCamera>(ent); }
bool CGameCameraList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CGameCamera>(ent).IsValid(); }
CListeningAiList::CListeningAiList() : CObjectList(EGameObjectList::ListeningAi) {}
@ -41,12 +41,14 @@ CPlatformAndDoorList::CPlatformAndDoorList() : CObjectList(EGameObjectList::Plat
bool CPlatformAndDoorList::IsQualified(const CEntity& ent) const { return IsDoor(ent) || IsPlatform(ent); }
bool CPlatformAndDoorList::IsDoor(const CEntity& ent) const { return TCastToConstPtr<CScriptDoor>(ent); }
bool CPlatformAndDoorList::IsDoor(const CEntity& ent) const { return TCastToConstPtr<CScriptDoor>(ent).IsValid(); }
bool CPlatformAndDoorList::IsPlatform(const CEntity& ent) const { return TCastToConstPtr<CScriptPlatform>(ent); }
bool CPlatformAndDoorList::IsPlatform(const CEntity& ent) const {
return TCastToConstPtr<CScriptPlatform>(ent).IsValid();
}
CGameLightList::CGameLightList() : CObjectList(EGameObjectList::GameLight) {}
bool CGameLightList::IsQualified(const CEntity& lt) const { return TCastToConstPtr<CGameLight>(lt); }
bool CGameLightList::IsQualified(const CEntity& lt) const { return TCastToConstPtr<CGameLight>(lt).IsValid(); }
} // namespace urde

View File

@ -5,12 +5,13 @@
#include <unordered_map>
#include <vector>
#include "DNACommon/CMDL.hpp"
#include "DNAMP1/CMDLMaterials.hpp"
#include "DataSpec/DNACommon/CMDL.hpp"
#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Shaders/CModelShaders.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/Graphics/Shaders/CModelShaders.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <hecl/HMDLMeta.hpp>
@ -22,7 +23,6 @@ class CLight;
class CModel;
class CPoseAsTransforms;
class CSkinRules;
class CTexture;
class IObjectStore;
struct CModelFlags {

View File

@ -1,5 +1,6 @@
#include "Runtime/Graphics/Shaders/CTextSupportShader.hpp"
#include "Runtime/GuiSys/CFontImageDef.hpp"
#include "Runtime/GuiSys/CRasterFont.hpp"
#include <hecl/Pipeline.hpp>

View File

@ -69,9 +69,9 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& t
const zeus::CVector2f res(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight());
const zeus::CVector2f tmp = res / x138_tileSize;
const zeus::CVector2f tmpRecip = x138_tileSize / res;
const float x0 = tmpRecip.x() * (frame % int(tmp.x()));
const float x0 = tmpRecip.x() * static_cast<float>(frame % static_cast<int>(tmp.x()));
const float x1 = x0 + tmpRecip.x();
const float y0 = tmpRecip.y() * (frame % int(tmp.y()));
const float y0 = tmpRecip.y() * static_cast<float>(frame % static_cast<int>(tmp.y()));
const float y1 = y0 + tmpRecip.y();
vec.push_back(zeus::CVector2f(x0, y0));
vec.push_back(zeus::CVector2f(x0, y1));
@ -96,7 +96,7 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& t
} else {
const float tmp = (1.f - x14c_deResFactor) * alpha;
const float tmp3 = 1.f - tmp * tmp * tmp;
const float mip = tmp3 * (tex.GetNumMips() - 1);
const float mip = tmp3 * static_cast<float>(tex.GetNumMips() - 1);
quad.drawVerts(useColor, verts, mip);
}
}
@ -117,11 +117,11 @@ void CAuiImagePane::Draw(const CGuiWidgetDrawParms& params) {
// SetZUpdate(xac_drawFlags == EGuiModelDrawFlags::Shadeless || xac_drawFlags == EGuiModelDrawFlags::Opaque);
float blur0 = 1.f;
float blur1 = 0.f;
int frame0 = x144_frameTimer;
const int frame0 = static_cast<int>(x144_frameTimer);
int frame1 = 0;
if (x140_interval < 1.f && x140_interval > 0.f) {
zeus::CVector2f tmp = zeus::CVector2f(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight()) / x138_tileSize;
frame1 = (frame0 + 1) % int(tmp.x() * tmp.y());
frame1 = (frame0 + 1) % static_cast<int>(tmp.x() * tmp.y());
if (x148_fadeDuration == 0.f)
blur1 = 1.f;
else

View File

@ -220,7 +220,7 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
std::max(x214_fullChargeFadeTimer - dt / g_tweakTargeting->GetFullChargeFadeDuration(), 0.f);
}
const bool missileActive = gun->GetMissleMode() == CPlayerGun::EMissleMode::Active;
const bool missileActive = gun->GetMissleMode() == CPlayerGun::EMissileMode::Active;
if (missileActive != x1f4_missileActive) {
if (x1f8_missileBracketTimer != 0.f) {
x1f8_missileBracketTimer = FLT_EPSILON - x1f8_missileBracketTimer;

View File

@ -9,12 +9,12 @@
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/GuiSys/CGuiWidget.hpp"
#include "Runtime/GuiSys/CRasterFont.hpp"
#include "Runtime/GuiSys/CTextRenderBuffer.hpp"
#include <zeus/CColor.hpp>
namespace urde {
class CRasterFont;
class CSimplePool;
class CTextExecuteBuffer;
class CTextRenderBuffer;
@ -34,8 +34,6 @@ enum class EVerticalJustification {
RightMono
};
enum class EColorType { Main, Outline, Geometry, Foreground, Background };
enum class ETextDirection { Horizontal, Vertical };
class CGuiTextProperties {

View File

@ -8,7 +8,6 @@
#include "Runtime/GCNTypes.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/GuiSys/CGuiTextSupport.hpp"
#include <zeus/CVector2i.hpp>
@ -17,6 +16,8 @@ class CDrawStringOptions;
class CTextRenderBuffer;
class IObjectStore;
enum class EColorType { Main, Outline, Geometry, Foreground, Background };
/* NOTE: Is this a good place for CGlyph and CKernPair? */
class CGlyph {
private:

View File

@ -6,12 +6,11 @@
#include "Runtime/GCNTypes.hpp"
#include "Runtime/GuiSys/CDrawStringOptions.hpp"
#include "Runtime/GuiSys/CGuiTextSupport.hpp"
#include "Runtime/GuiSys/CRasterFont.hpp"
#include <zeus/CColor.hpp>
namespace urde {
class CRasterFont;
class CSaveableState {
friend class CColorOverrideInstruction;
friend class CFontInstruction;

View File

@ -7,6 +7,7 @@
#include "DataSpec/DNACommon/Tweaks/ITweakGui.hpp"
#include "Runtime/CDependencyGroup.hpp"
#include "Runtime/CRandom16.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/CStateManager.hpp"
@ -30,7 +31,6 @@ namespace urde {
class CActorLights;
class CArchitectureQueue;
class CAutoMapper;
class CDependencyGroup;
class CGuiCamera;
class CGuiModel;
class CModelData;

View File

@ -139,7 +139,7 @@ void CSamusHud::InitializeFrameGlueMutable(const CStateManager& mgr) {
CPlayerState& playerState = *mgr.GetPlayerState();
CPlayerGun& gun = *player.GetPlayerGun();
float chargeFactor = gun.IsCharging() ? gun.GetChargeBeamFactor() : 0.f;
bool missilesActive = gun.GetMissleMode() == CPlayerGun::EMissleMode::Active;
bool missilesActive = gun.GetMissleMode() == CPlayerGun::EMissileMode::Active;
bool lockedOnObj = player.GetOrbitTargetId() != kInvalidUniqueId;
switch (x2bc_nextState) {
@ -477,7 +477,7 @@ void CSamusHud::UpdateMissile(float dt, const CStateManager& mgr, bool init) {
u32 numMissles = playerState.GetItemAmount(CPlayerState::EItemType::Missiles);
u32 missileCap = playerState.GetItemCapacity(CPlayerState::EItemType::Missiles);
CPlayerGun::EMissleMode missileMode = gun.GetMissleMode();
CPlayerGun::EMissileMode missileMode = gun.GetMissleMode();
float chargeFactor = gun.IsCharging() ? gun.GetChargeBeamFactor() : 0.f;
if (x294_missileIntf)
@ -491,7 +491,7 @@ void CSamusHud::UpdateMissile(float dt, const CStateManager& mgr, bool init) {
if (numMissles != x2d8_missileAmount)
x294_missileIntf->SetNumMissiles(numMissles, mgr);
if (missileMode != x2ec_missileMode)
x294_missileIntf->SetIsMissilesActive(missileMode == CPlayerGun::EMissleMode::Active);
x294_missileIntf->SetIsMissilesActive(missileMode == CPlayerGun::EMissileMode::Active);
}
x2d8_missileAmount = numMissles;
x2ec_missileMode = missileMode;
@ -600,7 +600,7 @@ void CSamusHud::UpdateCameraDebugSettings() {
}
void CSamusHud::UpdateEnergyLow(float dt, const CStateManager& mgr) {
bool cineCam = TCastToConstPtr<CCinematicCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr));
const bool cineCam = TCastToConstPtr<CCinematicCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr)).IsValid();
float oldTimer = x57c_energyLowTimer;
x57c_energyLowTimer = std::fmod(x57c_energyLowTimer + dt, 0.5f);

View File

@ -101,7 +101,7 @@ class CSamusHud {
bool x2e0_27_energyLow : 1;
u32 x2e4_ = 0;
u32 x2e8_ = 0;
CPlayerGun::EMissleMode x2ec_missileMode = CPlayerGun::EMissleMode::Inactive;
CPlayerGun::EMissileMode x2ec_missileMode = CPlayerGun::EMissileMode::Inactive;
float x2f0_visorBeamMenuAlpha = 1.f;
zeus::CVector3f x2f8_fpCamDir;
zeus::CVector3f x304_basewidgetIdlePos;

View File

@ -4,6 +4,7 @@
#include <string>
#include <vector>
#include "Runtime/CDependencyGroup.hpp"
#include "Runtime/CIOWin.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
@ -16,7 +17,6 @@
#include <zeus/CVector2f.hpp>
namespace urde {
class CDependencyGroup;
class CTexture;
class CSlideShow : public CIOWin {

View File

@ -297,9 +297,9 @@ void CFlaahgra::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, E
return;
}
case EUserEventType::BeginAction: {
#ifndef NDEBUG
printf("BeginAction\n");
#endif
//#ifndef NDEBUG
// printf("BeginAction\n");
//#endif
x8e4_26_ = true;
x7c4_ = GetEndActionTime();
break;

View File

@ -132,7 +132,8 @@ headerf.write('''
operator T*() const { return GetPtr(); }
T& operator*() const { return *GetPtr(); }
T* operator->() const { return GetPtr(); }
operator bool() const { return ptr != nullptr; }
bool IsValid() const { return ptr != nullptr; }
explicit operator bool() const { return IsValid(); }
};
template <class T>
@ -147,7 +148,8 @@ public:
operator const T*() const { return GetPtr(); }
const T& operator*() const { return *GetPtr(); }
const T* operator->() const { return GetPtr(); }
operator bool() const { return TCastToPtr<T>::ptr != nullptr; }
bool IsValid() const { return TCastToPtr<T>::ptr != nullptr; }
explicit operator bool() const { return IsValid(); }
};
}

View File

@ -8,6 +8,7 @@
#include "Runtime/IOStreams.hpp"
#include "Runtime/IObj.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/CModel.hpp"
namespace urde {
class CColorElement;
@ -16,7 +17,6 @@ class CEmitterElement;
class CGenDescription;
class CIntElement;
class CModVectorElement;
class CModel;
class CRealElement;
class CSimplePool;
class CSwooshDescription;
@ -100,3 +100,9 @@ CFactoryFnReturn FParticleFactory(const SObjectTag& tag, CInputStream& in, const
CObjectReference* selfRef);
} // namespace urde
// FIXME hacky workaround for MSVC; these need to be complete types
// but introduce circular dependencies if included at the start
#include "Runtime/Particle/CGenDescription.hpp"
#include "Runtime/Particle/CSwooshDescription.hpp"
#include "Runtime/Particle/CElectricDescription.hpp"

View File

@ -19,18 +19,22 @@ CBurstFire::CBurstFire(const SBurst* const* burstDefs, s32 firstBurstCount)
void CBurstFire::Update(CStateManager& mgr, float dt) {
x14_24_shouldFire = false;
if (x18_curBursts) {
x8_timeToNextShot -= dt;
if (x8_timeToNextShot < 0.f) {
x4_angleIdx += 1;
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
x14_24_shouldFire = true;
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
x8_timeToNextShot += (mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
} else {
x18_curBursts = nullptr;
}
}
if (!x18_curBursts) {
return;
}
x8_timeToNextShot -= dt;
if (x8_timeToNextShot >= 0.f) {
return;
}
x4_angleIdx += 1;
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
x14_24_shouldFire = true;
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
x8_timeToNextShot += (mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
} else {
x18_curBursts = nullptr;
}
}
@ -67,18 +71,25 @@ void CBurstFire::Start(CStateManager& mgr) {
}
zeus::CVector3f CBurstFire::GetError(float xMag, float zMag) const {
zeus::CVector3f ret;
if (x14_24_shouldFire && x18_curBursts) {
s32 r0 = x18_curBursts->x4_shotAngles[x4_angleIdx];
if (x14_25_avoidAccuracy && (r0 == 4 || r0 == 12))
r0 = x4_angleIdx > 0 ? x18_curBursts->x4_shotAngles[x4_angleIdx - 1]
: x18_curBursts->x4_shotAngles[x4_angleIdx + 1];
if (r0 > 0) {
float angle = r0 * zeus::degToRad(-22.5f);
ret.x() = std::cos(angle) * xMag;
ret.z() = std::sin(angle) * zMag;
}
if (!x14_24_shouldFire || !x18_curBursts) {
return {};
}
s32 r0 = x18_curBursts->x4_shotAngles[x4_angleIdx];
if (x14_25_avoidAccuracy && (r0 == 4 || r0 == 12)) {
r0 =
x4_angleIdx > 0 ? x18_curBursts->x4_shotAngles[x4_angleIdx - 1] : x18_curBursts->x4_shotAngles[x4_angleIdx + 1];
}
if (r0 <= 0) {
return {};
}
const float angle = r0 * zeus::degToRad(-22.5f);
zeus::CVector3f ret;
ret.x() = std::cos(angle) * xMag;
ret.z() = std::sin(angle) * zMag;
return ret;
}

View File

@ -13,6 +13,7 @@
#include "Runtime/Character/CAnimCharacterSet.hpp"
#include "Runtime/Collision/CMaterialList.hpp"
#include "Runtime/Particle/CElementGen.hpp"
#include "Runtime/Particle/CWeaponDescription.hpp"
#include "Runtime/Weapon/CGunController.hpp"
#include "Runtime/Weapon/CGunMotion.hpp"
#include "Runtime/Weapon/CWeaponMgr.hpp"
@ -25,7 +26,6 @@ namespace urde {
class CActorLights;
struct CModelFlags;
class CWeaponDescription;
enum class EChargeState { Normal, Charged };

View File

@ -501,7 +501,7 @@ void CPlayerGun::ResetCharge(CStateManager& mgr, bool resetBeam) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
}
@ -587,7 +587,7 @@ void CPlayerGun::Reset(CStateManager& mgr, bool b1) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
} else {
x2f8_stateFlags &= ~0x7;
@ -784,7 +784,7 @@ void CPlayerGun::CancelFiring(CStateManager& mgr) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
if (x32c_chargePhase != EChargePhase::NotCharging) {
x72c_currentBeam->ActivateCharge(false, false);
@ -820,8 +820,7 @@ void CPlayerGun::StopContinuousBeam(CStateManager& mgr, bool b1) {
} else if (x833_28_phazonBeamActive) {
if (static_cast<CPhazonBeam*>(x72c_currentBeam)->IsFiring())
static_cast<CPhazonBeam*>(x72c_currentBeam)->StopBeam(mgr, b1);
} else if (x310_currentBeam == CPlayerState::EBeamId::Plasma) // Plasma
{
} else if (x310_currentBeam == CPlayerState::EBeamId::Plasma) {
if (static_cast<CPlasmaBeam*>(x72c_currentBeam)->IsFiring())
static_cast<CPlasmaBeam*>(x72c_currentBeam)->StopBeam(mgr, b1);
}
@ -839,35 +838,34 @@ void CPlayerGun::CMotionState::Update(bool firing, float dt, zeus::CTransform& x
if (x0_24_extendParabola && x20_state == EMotionState::LockOn) {
float extendT = xc_curExtendDist / gGunExtendDistance;
xf = xf * zeus::CTransform::RotateZ(zeus::degToRad(extendT * -4.f * (extendT - 1.f) * 15.f));
} else {
if (x24_fireState == EFireState::StartFire || x24_fireState == EFireState::Firing) {
if (std::fabs(x14_rotationT - 1.f) < 0.1f) {
x18_startRotation = x1c_endRotation;
x14_rotationT = 0.f;
if (x24_fireState == EFireState::StartFire) {
x1c_endRotation = mgr.GetActiveRandom()->Next() % 15;
x1c_endRotation *= (mgr.GetActiveRandom()->Next() % 100) > 45 ? 1.f : -1.f;
} else {
x1c_endRotation = 0.f;
if (x18_startRotation == x1c_endRotation) {
x10_curRotation = x1c_endRotation;
x24_fireState = EFireState::NotFiring;
}
}
xf = xf * zeus::CTransform(zeus::CMatrix3f::RotateZ(zeus::degToRad(extendT * -4.f * (extendT - 1.f) * 15.f)),
{0.f, xc_curExtendDist, 0.f});
} else if (x24_fireState == EFireState::StartFire || x24_fireState == EFireState::Firing) {
if (std::fabs(x14_rotationT - 1.f) < 0.1f) {
x18_startRotation = x1c_endRotation;
x14_rotationT = 0.f;
if (x24_fireState == EFireState::StartFire) {
x1c_endRotation = mgr.GetActiveRandom()->Next() % 15;
x1c_endRotation *= (mgr.GetActiveRandom()->Next() % 100) > 45 ? 1.f : -1.f;
} else {
x10_curRotation = (x1c_endRotation - x18_startRotation) * x14_rotationT + x18_startRotation;
x1c_endRotation = 0.f;
if (x18_startRotation == x1c_endRotation) {
x10_curRotation = x1c_endRotation;
x24_fireState = EFireState::NotFiring;
}
}
x14_rotationT += (1.f - x14_rotationT) * 0.8f * (10.f * dt);
zeus::CTransform tmpXf =
zeus::CQuaternion::fromAxisAngle(xf.basis[1], zeus::degToRad(x10_curRotation)).toTransform() *
xf.getRotation();
tmpXf.origin = xf.origin;
xf = tmpXf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
} else {
xf = xf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
x10_curRotation = (x1c_endRotation - x18_startRotation) * x14_rotationT + x18_startRotation;
}
x14_rotationT += (1.f - x14_rotationT) * 0.8f * (10.f * dt);
zeus::CTransform tmpXf =
zeus::CQuaternion::fromAxisAngle(xf.frontVector(), zeus::degToRad(x10_curRotation)).toTransform() *
xf.getRotation();
tmpXf.origin = xf.origin;
xf = tmpXf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
} else {
xf = xf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
}
switch (x20_state) {
@ -1272,7 +1270,7 @@ void CPlayerGun::UpdateAuxWeapons(float dt, const zeus::CTransform& targetXf, CS
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
} else if (x833_28_phazonBeamActive) {
static_cast<CPhazonBeam*>(x72c_currentBeam)->UpdateBeam(dt, targetXf, x418_beamLocalXf.origin, mgr);
@ -1581,7 +1579,7 @@ void CPlayerGun::UpdateWeaponFire(float dt, const CPlayerState& playerState, CSt
x2f8_stateFlags &= ~0x1;
x2f8_stateFlags |= 0x6;
x318_comboAmmoIdx = 1;
x31c_missileMode = EMissleMode::Active;
x31c_missileMode = EMissileMode::Active;
}
FireSecondary(dt, mgr);
} else {
@ -1875,7 +1873,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= ~0x1;
x2f8_stateFlags |= 0x6;
x318_comboAmmoIdx = 1;
x31c_missileMode = EMissleMode::Active;
x31c_missileMode = EMissileMode::Active;
break;
case ENextState::ExitMissile:
if ((x2f8_stateFlags & 0x8) != 0x8) {
@ -1883,7 +1881,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
x390_cooldown = x72c_currentBeam->GetWeaponInfo().x0_coolDown;
break;
case ENextState::MissileReload:
@ -1905,7 +1903,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
break;
case ENextState::EnterPhazonBeam:
if (x75c_phazonBeam->IsLoaded())
@ -1970,7 +1968,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
zeus::CAABox aabb = x72c_currentBeam->GetBounds().getTransformedAABox(x4a8_gunWorldXf);
mgr.BuildNearList(nearList, aabb, sAimFilter, &player);
TUniqueId bestId = kInvalidUniqueId;
zeus::CVector3f dir = x4a8_gunWorldXf.basis[1].normalized();
zeus::CVector3f dir = x4a8_gunWorldXf.frontVector().normalized();
zeus::CVector3f pos = dir * -0.5f + x4a8_gunWorldXf.origin;
CRayCastResult result = mgr.RayWorldIntersection(bestId, pos, dir, 3.5f, sAimFilter, nearList);
x833_29_pointBlankWorldSurface = result.IsValid();

View File

@ -35,7 +35,7 @@ struct CFinalInput;
class CPlayerGun {
public:
static float skTractorBeamFactor;
enum class EMissleMode { Inactive, Active };
enum class EMissileMode { Inactive, Active };
enum class EBWeapon { Bomb, PowerBomb };
enum class EPhazonBeamState { Inactive, Entering, Exiting, Active };
enum class EChargePhase {
@ -141,7 +141,7 @@ private:
CPlayerState::EBeamId x310_currentBeam = CPlayerState::EBeamId::Power;
CPlayerState::EBeamId x314_nextBeam = CPlayerState::EBeamId::Power;
u32 x318_comboAmmoIdx = 0;
EMissleMode x31c_missileMode = EMissleMode::Inactive;
EMissileMode x31c_missileMode = EMissileMode::Inactive;
CPlayerState::EBeamId x320_currentAuxBeam = CPlayerState::EBeamId::Power;
EIdleState x324_idleState = EIdleState::Four;
float x328_animSfxPitch = 0.f;
@ -323,7 +323,7 @@ public:
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void AsyncLoadSuit(CStateManager& mgr);
void TouchModel(const CStateManager& stateMgr);
EMissleMode GetMissleMode() const { return x31c_missileMode; }
EMissileMode GetMissleMode() const { return x31c_missileMode; }
bool IsFidgeting() const { return x833_24_notFidgeting; }
bool IsCharging() const { return x834_24_charging; }
float GetChargeBeamFactor() const { return x340_chargeBeamFactor; }

View File

@ -18,9 +18,10 @@
namespace urde {
static bool IsMediumOrLarge(CActor& act) {
if (TCastToConstPtr<CPatterned> pat = act)
static bool IsMediumOrLarge(const CActor& act) {
if (const TCastToConstPtr<CPatterned> pat = act) {
return pat->GetKnockBackController().GetVariant() != EKnockBackVariant::Small;
}
return false;
}

View File

@ -3323,7 +3323,7 @@ void CPlayer::UpdateAimTargetPrediction(const zeus::CTransform& xf, const CState
return;
}
x9c6_27_aimingAtProjectile = TCastToConstPtr<CGameProjectile>(target.GetPtr());
x9c6_27_aimingAtProjectile = TCastToConstPtr<CGameProjectile>(target.GetPtr()).IsValid();
const zeus::CVector3f instantTarget = target->GetAimPosition(mgr, 0.f);
const zeus::CVector3f gunToTarget = instantTarget - xf.origin;
const float timeToTarget = gunToTarget.magnitude() / x490_gun->GetBeamVelocity();
@ -5076,7 +5076,7 @@ bool CPlayer::ValidateOrbitTargetIdAndPointer(TUniqueId uid, CStateManager& mgr)
if (uid == kInvalidUniqueId) {
return false;
}
return TCastToConstPtr<CActor>(mgr.GetObjectById(uid));
return TCastToConstPtr<CActor>(mgr.GetObjectById(uid)).IsValid();
}
zeus::CVector3f CPlayer::GetBallPosition() const {

View File

@ -8,6 +8,7 @@
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/Collision/CCollidableOBBTreeGroup.hpp"
#include "Runtime/World/CDamageVulnerability.hpp"
#include "Runtime/World/CHealthInfo.hpp"
#include "Runtime/World/CPhysicsActor.hpp"
@ -17,8 +18,6 @@
#include <zeus/CVector3f.hpp>
namespace urde {
class CCollidableOBBTreeGroup;
class CCollidableOBBTreeGroupContainer;
class CFluidPlane;
struct SRiders {

View File

@ -4,6 +4,8 @@
#include "Runtime/World/CAi.hpp"
namespace urde {
static logvisor::Module Log("urde::CStateMachine");
CStateMachine::CStateMachine(CInputStream& in) {
CAiTrigger* lastTrig = nullptr;
u32 stateCount = in.readUint32Big();
@ -78,10 +80,8 @@ void CStateMachineState::Update(CStateManager& mgr, CAi& ai, float delta) {
if (andPassed && state) {
x4_state->CallFunc(mgr, ai, EStateMsg::Deactivate, 0.f);
x4_state = state;
//#ifndef NDEBUG
// fmt::print(FMT_STRING("{} {} {} - {} {}\n"), ai.GetUniqueId(), ai.GetEditorId(), ai.GetName(),
// state->xc_name, int(state - x0_machine->GetStateVector().data()));
//#endif
Log.report(logvisor::Info, FMT_STRING("{} {} {} - {} {}"), ai.GetUniqueId(), ai.GetEditorId(), ai.GetName(),
state->xc_name, int(state - x0_machine->GetStateVector().data()));
x8_time = 0.f;
x18_24_codeTrigger = false;
xc_random = mgr.GetActiveRandom()->Float();

View File

@ -14,6 +14,7 @@
#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp"
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Runtime/GuiSys/CGuiTextSupport.hpp"
#include "Runtime/GuiSys/CStringTable.hpp"
#include <zeus/CTransform.hpp>
#include <zeus/CVector2f.hpp>
@ -21,7 +22,6 @@
namespace urde {
class CSimplePool;
class CStringTable;
class CWorldTransManager {
public:

2
hecl

@ -1 +1 @@
Subproject commit 95ac3ef77c8a5dfe70f498fdffea5fe92091bd73
Subproject commit d1ed2b5d4d4ef1a56097492fe8a57c6911adf708

@ -1 +1 @@
Subproject commit c66d33b0b2fca695c39d1c0c829489ba67a52f47
Subproject commit e5e3713b12f6c6b93cae5ca59b1879f45d498f22

@ -1 +1 @@
Subproject commit fc0d79ace7063f24efaeaf8153753855eb3e2b95
Subproject commit f54b6e2650711b9872b230d27f15e0e231a5f12d