Files
firestorm/Gameleap/code/mw4/Code/MW4/Gyro.cpp
T
Cyd 2b8ca921cb Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS
Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
2026-06-24 21:28:16 -05:00

150 lines
3.5 KiB
C++

#include "MW4Headers.hpp"
#include "Gyro.hpp"
#include "Mech.hpp"
#include "AI.hpp"
#include <Adept\Mission.hpp>
//#############################################################################
//########################### Gyro ###############################
//#############################################################################
Gyro::ClassData*
Gyro::DefaultData = NULL;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Gyro::InitializeClass()
{
Verify(!DefaultData);
DefaultData =
new ClassData(
GyroClassID,
"MechWarrior4::Gyro",
Receiver::DefaultData,
0,
NULL
);
Check_Object(DefaultData);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Gyro::TerminateClass()
{
Check_Object(DefaultData);
delete DefaultData;
DefaultData = NULL;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Gyro::Gyro(Mech *parent) :
Adept::Receiver(DefaultData)
{
m_parentMech = parent;
m_fallDownTime = 0.0;
AbortFall();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Gyro::~Gyro()
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Gyro::Reuse()
{
Check_Object(this);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Gyro::TestInstance()
{
Verify(IsDerivedFrom(DefaultData));
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Gyro::Execute()
{
Check_Object(this);
//
//-----------------------------------------------------------------------
// If we aren't in falldown mode, or if the timer isn't done, just return
//-----------------------------------------------------------------------
//
if (m_fallMode==Mech::NoFallMode || gos_GetElapsedTime()<m_fallDownTime)
return;
//
//-----------------
// Time to go boom!
//-----------------
//
if ((m_parentMech->GetReplicatorMode() & (7 << Replicator::ReplicantFlagBit)) == Replicator::ClientMasterMode || (m_parentMech->GetReplicatorMode() & (7 << Replicator::ReplicantFlagBit) )== Replicator::MasterMode)
{
m_parentMech->queFallState = m_fallMode;
m_fallMode = Mech::NoFallMode;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Gyro::FallDown(
Mech::FallMode fall_mode,
Stuff::Scalar delay
)
{
Check_Object(this);
//
//--------------------------------------------------------------------------
// Compute the new time that we wish the mech to fall down at. If we aren't
// falling yet, or if the new fall time is sooner than that we already have,
// set the new fall mode and time
//--------------------------------------------------------------------------
//
Time new_time = gos_GetElapsedTime() + delay;
if (m_parentMech->queFallState == Mech::NoFallMode)
{
if (m_fallMode == Mech::NoFallMode || new_time < m_fallDownTime)
{
m_fallDownTime = new_time;
m_fallMode = fall_mode;
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Gyro::AbortFall()
{
Check_Object(this);
m_fallMode = Mech::NoFallMode;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Scalar
Gyro::GetTimeTillFall()
{
Check_Object(this);
if (m_fallMode == Mech::NoFallMode)
return -1.0f;
return static_cast<Scalar>(m_fallDownTime - gos_GetElapsedTime());
}