#include "MW4Headers.hpp" #include "Gyro.hpp" #include "Mech.hpp" #include "AI.hpp" #include //############################################################################# //########################### 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()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(m_fallDownTime - gos_GetElapsedTime()); }