Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions Generals/Code/GameEngine/Include/GameClient/Drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Shadow;
class ModuleInfo;
class Anim2DTemplate;
class Image;
class DynamicAudioEventInfo;
enum BodyDamageType CPP_11(: Int);

// this is a very worthwhile performance win. left conditionally defined for now, just
Expand Down Expand Up @@ -148,6 +149,8 @@ class DrawableLocoInfo : public MemoryPoolObject
Real m_overlapZVel; ///< fake Z velocity
Real m_overlapZ; ///< current height (additional)
Real m_wobble; ///< for wobbling
Real m_yawModulator; ///< for the swimmy soft hover of a helicopter
Real m_pitchModulator; ///< for the swimmy soft hover of a helicopter
TWheelInfo m_wheelInfo; ///< Wheel offset & angle info for a wheeled type locomotor.

DrawableLocoInfo();
Expand Down Expand Up @@ -240,6 +243,8 @@ enum TintStatus CPP_11(: Int)
TINT_STATUS_DISABLED = 0x00000001,///< drawable tint color is deathly dark grey
TINT_STATUS_IRRADIATED = 0x00000002,///< drawable tint color is sickly green
TINT_STATUS_POISONED = 0x00000004,///< drawable tint color is open-sore red
TINT_STATUS_GAINING_SUBDUAL_DAMAGE = 0x00000008,///< When gaining subdual damage, we tint SUBDUAL_DAMAGE_COLOR
TINT_STATUS_FRENZY = 0x00000010,///< When frenzied, we tint FRENZY_COLOR

};

Expand Down Expand Up @@ -297,6 +302,7 @@ class Drawable : public Thing,
Drawable( const ThingTemplate *thing, DrawableStatusBits statusBits = DRAWABLE_STATUS_DEFAULT );

void onDestroy(); ///< run from GameClient::destroyDrawable
void onLevelStart(); ///< run from GameLogic::startNewGame

Drawable *getNextDrawable() const { return m_nextDrawable; } ///< return the next drawable in the global list
Drawable *getPrevDrawable() const { return m_prevDrawable; } ///< return the prev drawable in the global list
Expand Down Expand Up @@ -360,6 +366,7 @@ class Drawable : public Thing,
ClientUpdateModule* findClientUpdateModule( NameKeyType key );

// never returns null
DrawModule** getDrawModulesNonDirty();
DrawModule** getDrawModules();
DrawModule const** getDrawModules() const;

Expand Down Expand Up @@ -409,10 +416,11 @@ class Drawable : public Thing,

void drawIconUI(); ///< draw "icon"(s) needed on drawable (health bars, veterency, etc)

void startAmbientSound();
void startAmbientSound( Bool onlyIfPermanent = false );
void stopAmbientSound();
void enableAmbientSound( Bool enable );
void setTimeOfDay( TimeOfDay tod );
Bool getAmbientSoundEnabledFromScript() const { return m_ambientSoundEnabledFromScript; }

void prependToList(Drawable **pListHead);
void removeFromList(Drawable **pListHead);
Expand Down Expand Up @@ -455,6 +463,8 @@ class Drawable : public Thing,

const TWheelInfo *getWheelInfo() const { return m_locoInfo ? &m_locoInfo->m_wheelInfo : nullptr; }

const DrawableLocoInfo *getLocoInfo() const { return m_locoInfo; }

// this method must ONLY be called from the client, NEVER From the logic, not even indirectly.
Bool clientOnly_getFirstRenderObjInfo(Coord3D* pos, Real* boundingSphereRadius, Matrix3D* transform);

Expand Down Expand Up @@ -492,6 +502,10 @@ class Drawable : public Thing,
"in between", it is included in the completion time.
*/
void setAnimationCompletionTime(UnsignedInt numFrames);

//Kris: Manually set a drawable's current animation to specific frame.
virtual void setAnimationFrame( int frame );

void updateSubObjects();
void showSubObject( const AsciiString& name, Bool show );

Expand Down Expand Up @@ -554,11 +568,26 @@ class Drawable : public Thing,
void killIcon(DrawableIconType t) { if (m_iconInfo) m_iconInfo->killIcon(t); }
Bool hasIconInfo() const { return m_iconInfo != nullptr; }

const AudioEventRTS * getAmbientSound() const { return m_ambientSound == nullptr ? nullptr : &m_ambientSound->m_event; }

Bool getReceivesDynamicLights() { return m_receivesDynamicLights; };
void setReceivesDynamicLights( Bool set ) { m_receivesDynamicLights = set; };

//---------------------------------------------------------------------------------
// Stuff for overriding ambient sound
const AudioEventInfo * getBaseSoundAmbientInfo() const; //< Possible starting point if only some parameters are customized
void enableAmbientSoundFromScript( Bool enable );
const AudioEventRTS * getAmbientSound() const { return m_ambientSound == nullptr ? nullptr : &m_ambientSound->m_event; }
void setCustomSoundAmbientOff(); //< Kill the ambient sound
void setCustomSoundAmbientInfo( DynamicAudioEventInfo * customAmbientInfo ); //< Set ambient sound.
void clearCustomSoundAmbient() { clearCustomSoundAmbient( true ); } //< Return to using defaults
Bool getAmbientSoundEnabled() const { return m_ambientSoundEnabled; }
void mangleCustomAudioName( DynamicAudioEventInfo * audioToMangle ) const;


Real friend_getStealthOpacity() { return m_stealthOpacity; }
Real friend_getExplicitOpacity() { return m_explicitOpacity; }
Real friend_getEffectiveStealthOpacity() { return m_effectiveStealthOpacity; }

protected:

// snapshot methods
Expand All @@ -567,7 +596,7 @@ class Drawable : public Thing,
virtual void loadPostProcess() override;
void xferDrawableModules( Xfer *xfer );

void startAmbientSound(BodyDamageType dt, TimeOfDay tod);
void startAmbientSound( BodyDamageType dt, TimeOfDay tod, Bool onlyIfPermanent = false );

virtual Drawable *asDrawableMeth() override { return this; }
virtual const Drawable *asDrawableMeth() const override { return this; }
Expand Down Expand Up @@ -601,9 +630,12 @@ class Drawable : public Thing,
void calcPhysicsXformHoverOrWings(const Locomotor *locomotor, PhysicsXformInfo& info);
void calcPhysicsXformTreads(const Locomotor *locomotor, PhysicsXformInfo& info);
void calcPhysicsXformWheels(const Locomotor *locomotor, PhysicsXformInfo& info);
void calcPhysicsXformMotorcycle( const Locomotor *locomotor, PhysicsXformInfo& info );

const AudioEventRTS& getAmbientSoundByDamage(BodyDamageType dt);

void clearCustomSoundAmbient( bool restartSound ); //< Return to using defaults

#ifdef RTS_DEBUG
void validatePos() const;
#endif
Expand Down Expand Up @@ -642,6 +674,8 @@ class Drawable : public Thing,
Drawable *m_nextDrawable;
Drawable *m_prevDrawable; ///< list links

DynamicAudioEventInfo *m_customSoundAmbientInfo; ///< If not nullptr, info about the ambient sound to attach to this object

DrawableStatusBits m_status; ///< status bits (see DrawableStatus enum)
UnsignedInt m_tintStatus; ///< tint color status bits (see TintStatus enum)
UnsignedInt m_prevTintStatus;///< for edge testing with m_tintStatus
Expand All @@ -663,7 +697,6 @@ class Drawable : public Thing,
PhysicsXformInfo* m_physicsXform;

DynamicAudioEventRTS* m_ambientSound; ///< sound module for ambient sound (lazily allocated)
Bool m_ambientSoundEnabled;

Module** m_modules[NUM_DRAWABLE_MODULE_TYPES];

Expand Down Expand Up @@ -694,6 +727,8 @@ class Drawable : public Thing,
Bool m_hiddenByStealth; ///< drawable is hidden due to stealth
Bool m_instanceIsIdentity; ///< If true, instance matrix can be skipped
Bool m_drawableFullyObscuredByShroud; ///<drawable is hidden by shroud/fog
Bool m_ambientSoundEnabled;
Bool m_ambientSoundEnabledFromScript;

Bool m_receivesDynamicLights;

Expand Down
20 changes: 19 additions & 1 deletion Generals/Code/GameEngine/Include/GameLogic/Locomotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ enum LocomotorAppearance CPP_11(: Int)
LOCO_WINGS,
LOCO_CLIMBER, // human climber - backs down cliffs.
LOCO_OTHER,
LOCO_MOTORCYCLE, // Added in Zero Hour

LOCOMOTOR_APPEARANCE_COUNT
};
Expand All @@ -82,6 +83,7 @@ static const char *const TheLocomotorAppearanceNames[] =
"WINGS",
"CLIMBER",
"OTHER",
"MOTORCYCLE",

nullptr
};
Expand Down Expand Up @@ -171,7 +173,8 @@ class LocomotorTemplate : public Overridable
LocomotorAppearance m_appearance; ///< how we should diddle the Drawable to imitate this motion
LocomotorPriority m_movePriority; ///< Where we move - front, middle, back.

Real m_accelPitchLimit; ///< Maximum amount we will pitch up or down under acceleration (including recoil.)
Real m_accelPitchLimit; ///< Maximum amount we will pitch up under acceleration (including recoil.)
Real m_decelPitchLimit; ///< Maximum amount we will pitch down under deceleration (including recoil.)
Real m_bounceKick; ///< How much simulating rough terrain "bounces" a wheel up.
Real m_pitchStiffness; ///< How stiff the springs are forward & back.
Real m_rollStiffness; ///< How stiff the springs are side to side.
Expand Down Expand Up @@ -209,6 +212,12 @@ class LocomotorTemplate : public Overridable
Real m_wanderWidthFactor;
Real m_wanderLengthFactor;
Real m_wanderAboutPointRadius;


Real m_rudderCorrectionDegree;
Real m_rudderCorrectionRate;
Real m_elevatorCorrectionDegree;
Real m_elevatorCorrectionRate;
};

typedef OVERRIDE<LocomotorTemplate> LocomotorTemplateOverride;
Expand Down Expand Up @@ -251,6 +260,7 @@ class Locomotor : public MemoryPoolObject, public Snapshot
AsciiString getTemplateName() const { return m_template->m_name;}
Real getMinSpeed() const { return m_template->m_minSpeed;}
Real getAccelPitchLimit() const { return m_template->m_accelPitchLimit;} ///< Maximum amount we will pitch up or down under acceleration (including recoil.)
Real getDecelPitchLimit() const { return m_template->m_decelPitchLimit;} ///< Maximum amount we will pitch down under deceleration (including recoil.)
Real getBounceKick() const { return m_template->m_bounceKick;} ///< How much simulating rough terrain "bounces" a wheel up.
Real getPitchStiffness() const { return m_template->m_pitchStiffness;} ///< How stiff the springs are forward & back.
Real getRollStiffness() const { return m_template->m_rollStiffness;} ///< How stiff the springs are side to side.
Expand Down Expand Up @@ -282,6 +292,13 @@ class Locomotor : public MemoryPoolObject, public Snapshot
Real getMaxWheelCompression() const {return m_template->m_maximumWheelCompression;}
Real getWheelTurnAngle() const {return m_template->m_wheelTurnAngle;}


Real getRudderCorrectionDegree() const { return m_template->m_rudderCorrectionDegree;} ///< How much we roll in response to acceleration.
Real getRudderCorrectionRate() const { return m_template->m_rudderCorrectionRate;} ///< How much we roll in response to acceleration.
Real getElevatorCorrectionDegree() const { return m_template->m_elevatorCorrectionDegree;} ///< How much we roll in response to acceleration.
Real getElevatorCorrectionRate() const { return m_template->m_elevatorCorrectionRate;} ///< How much we roll in response to acceleration.


Real getWanderWidthFactor() const {return m_template->m_wanderWidthFactor;}
Real getWanderAboutPointRadius() const {return m_template->m_wanderAboutPointRadius;}

Expand All @@ -300,6 +317,7 @@ class Locomotor : public MemoryPoolObject, public Snapshot
void setAllowInvalidPosition(Bool allow) { setFlag(ALLOW_INVALID_POSITION, allow); }
void setCloseEnoughDist( Real dist ) { m_closeEnoughDist = dist; }
void setCloseEnoughDist3D( Bool setting ) { setFlag(IS_CLOSE_ENOUGH_DIST_3D, setting); }
Bool isInvalidPositionAllowed() const { return getFlag( ALLOW_INVALID_POSITION ); }

void setPreferredHeight( Real height ) { m_preferredHeight = height; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,15 @@ class PhysicsBehavior : public UpdateModule,
void setAllowCollideForce(Bool allow) { setFlag(ALLOW_COLLIDE_FORCE, allow); }
void setAllowAirborneFriction(Bool allow) { setFlag(APPLY_FRICTION2D_WHEN_AIRBORNE, allow); }
void setImmuneToFallingDamage(Bool allow) { setFlag(IMMUNE_TO_FALLING_DAMAGE, allow); }
void setStunned(Bool allow) { setFlag(IS_STUNNED, allow); }

Bool getAllowToFall() const { return getFlag(ALLOW_TO_FALL); }

void setIsInFreeFall(Bool allow) { setFlag(IS_IN_FREEFALL, allow); }
Bool getIsInFreeFall() const { return getFlag(IS_IN_FREEFALL); }

Bool getIsStunned() const { return getFlag(IS_STUNNED); }

void setExtraBounciness(Real b) { m_extraBounciness = b; }
void setExtraFriction(Real b) { m_extraFriction = b; }

Expand Down Expand Up @@ -238,7 +241,8 @@ class PhysicsBehavior : public UpdateModule,
HAS_PITCHROLLYAW = 0x0080,
IMMUNE_TO_FALLING_DAMAGE = 0x0100,
IS_IN_FREEFALL = 0x0200,
IS_IN_UPDATE = 0x0400
IS_IN_UPDATE = 0x0400,
IS_STUNNED = 0x0800, // Added in Zero Hour
};

/*
Expand Down
1 change: 1 addition & 0 deletions Generals/Code/GameEngine/Include/GameLogic/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class Object : public Thing, public Snapshot

void onCollide( Object *other, const Coord3D *loc, const Coord3D *normal );

Real getCarrierDeckHeight() const;
// access to modules
//-----------------------------------------------------------------------------

Expand Down
Loading
Loading