Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
RailroadBehavior Class Reference

#include <RailroadGuideAIUpdate.h>

Inherits PhysicsBehavior.

Classes

struct  PullInfo
 

Public Types

typedef std::vector< AsciiStringTemplateNameVector
 
typedef TemplateNameVector::const_iterator TemplateNameIterator
 

Public Member Functions

 RailroadBehavior (Thing *thing, const ModuleData *moduleData)
 
virtual void onCollide (Object *other, const Coord3D *loc, const Coord3D *normal)
 
virtual Bool isRailroad () const
 
virtual UpdateSleepTime update (void)
 
void getPulled (PullInfo *info)
 
void destroyTheWholeTrainNow (void)
 
void hitchNewCarriagebyTemplate (ObjectID parentID, const TemplateNameVector &list, TemplateNameIterator &iter, TrainTrack *trackPointList)
 
void hitchNewCarriagebyProximity (ObjectID parentID, TrainTrack *trackPointList)
 
void disembark (void)
 
Bool hasEverBeenHitched (void)
 
void setHeld (Bool held)
 
void makeAWallOutOfThisTrain (Bool on)
 
- Public Member Functions inherited from PhysicsBehavior
 PhysicsBehavior (Thing *thing, const ModuleData *moduleData)
 
virtual void onObjectCreated ()
 
virtual CollideModuleInterfacegetCollide ()
 
virtual Bool wouldLikeToCollideWith (const Object *other) const
 
virtual Bool isCarBombCrateCollide () const
 
virtual Bool isHijackedVehicleCrateCollide () const
 
virtual Bool isSalvageCrateCollide () const
 
virtual Bool isSabotageBuildingCrateCollide () const
 
virtual DisabledMaskType getDisabledTypesToProcess () const
 
void applyForce (const Coord3D *force)
 apply a force at the object's CG
 
void applyShock (const Coord3D *force)
 apply a shockwave force against the object's CG
 
void applyRandomRotation ()
 apply a random rotation at the object's CG
 
void addVelocityTo (const Coord3D *vel)
 
void applyMotiveForce (const Coord3D *force)
 
void clearAcceleration ()
 
void transferVelocityTo (PhysicsBehavior *that) const
 
void setAngles (Real yaw, Real pitch, Real roll)
 
Real getMass () const
 
void setMass (Real mass)
 
Real getCenterOfMassOffset () const
 
const Coord3DgetAcceleration () const
 get last frame's acceleration
 
const Coord3DgetVelocity () const
 get current velocity
 
Real getVelocityMagnitude () const
 return velocity magnitude (speed)
 
Real getForwardSpeed2D () const
 compute speed along object's 2d direction vector
 
Real getForwardSpeed3D () const
 compute speed along object's 3d direction vector
 
ObjectID getCurrentOverlap () const
 return object(s) being overlapped
 
ObjectID getPreviousOverlap () const
 return object(s) that were overlapped last frame
 
ObjectID getLastCollidee () const
 return object that was last collided with... can be quite old
 
Bool isCurrentlyOverlapped (Object *obj) const
 
Bool wasPreviouslyOverlapped (Object *obj) const
 
void addOverlap (Object *obj)
 
Bool isMotive () const
 
PhysicsTurningType getTurning (void) const
 0 = not turning, -1 = turn negative, 1 = turn positive.
 
void setTurning (PhysicsTurningType turning)
 
void scrubVelocity2D (Real desiredVelocity)
 
void scrubVelocityZ (Real desiredVelocity)
 
void setPitchRate (Real pitch)
 
void setRollRate (Real roll)
 
void setYawRate (Real yaw)
 
void setAllowToFall (Bool allow)
 
void setStickToGround (Bool allow)
 
void setAllowBouncing (Bool allow)
 
void setAllowCollideForce (Bool allow)
 
void setAllowAirborneFriction (Bool allow)
 
void setImmuneToFallingDamage (Bool allow)
 
void setStunned (Bool allow)
 
Bool getAllowToFall () const
 
void setIsInFreeFall (Bool allow)
 
Bool getIsInFreeFall () const
 
Bool getIsStunned () const
 
void setExtraBounciness (Real b)
 
void setExtraFriction (Real b)
 
void setBounceSound (const AudioEventRTS *bounceSound)
 
const AudioEventRTSgetBounceSound ()
 
void resetDynamicPhysics ()
 
void setIgnoreCollisionsWith (const Object *obj)
 
Bool isIgnoringCollisionsWith (ObjectID id) const
 
Bool getAllowCollideForce () const
 
- Public Member Functions inherited from UpdateModule
 UpdateModule (Thing *thing, const ModuleData *moduleData)
 
virtual UpdateModuleInterfacegetUpdate ()
 
DisabledMaskType getDisabledTypesToProcess () const
 
UPDATEMODULE_FRIEND_DECLARATOR UnsignedInt friend_getPriority () const
 
UPDATEMODULE_FRIEND_DECLARATOR UnsignedInt friend_getNextCallFrame () const
 
UPDATEMODULE_FRIEND_DECLARATOR SleepyUpdatePhase friend_getNextCallPhase () const
 
UPDATEMODULE_FRIEND_DECLARATOR void friend_setNextCallFrame (UnsignedInt frame)
 
UPDATEMODULE_FRIEND_DECLARATOR Int friend_getIndexInLogic () const
 
UPDATEMODULE_FRIEND_DECLARATOR void friend_setIndexInLogic (Int i)
 
UPDATEMODULE_FRIEND_DECLARATOR const Objectfriend_getObject () const
 
- Public Member Functions inherited from BehaviorModule
 BehaviorModule (Thing *thing, const ModuleData *moduleData)
 
virtual BodyModuleInterfacegetBody ()
 
virtual ContainModuleInterfacegetContain ()
 
virtual CreateModuleInterfacegetCreate ()
 
virtual DamageModuleInterfacegetDamage ()
 
virtual DestroyModuleInterfacegetDestroy ()
 
virtual DieModuleInterfacegetDie ()
 
virtual SpecialPowerModuleInterfacegetSpecialPower ()
 
virtual UpgradeModuleInterfacegetUpgrade ()
 
virtual StealthUpdategetStealth ()
 
virtual SpyVisionUpdategetSpyVisionUpdate ()
 
virtual ParkingPlaceBehaviorInterfacegetParkingPlaceBehaviorInterface ()
 
virtual RebuildHoleBehaviorInterfacegetRebuildHoleBehaviorInterface ()
 
virtual BridgeBehaviorInterfacegetBridgeBehaviorInterface ()
 
virtual BridgeTowerBehaviorInterfacegetBridgeTowerBehaviorInterface ()
 
virtual BridgeScaffoldBehaviorInterfacegetBridgeScaffoldBehaviorInterface ()
 
virtual OverchargeBehaviorInterfacegetOverchargeBehaviorInterface ()
 
virtual TransportPassengerInterfacegetTransportPassengerInterface ()
 
virtual CaveInterfacegetCaveInterface ()
 
virtual LandMineInterfacegetLandMineInterface ()
 
virtual DieModuleInterfacegetEjectPilotDieInterface ()
 
virtual ProjectileUpdateInterfacegetProjectileUpdateInterface ()
 
virtual AIUpdateInterfacegetAIUpdateInterface ()
 
virtual ExitInterfacegetUpdateExitInterface ()
 
virtual DockUpdateInterfacegetDockUpdateInterface ()
 
virtual RailedTransportDockUpdateInterfacegetRailedTransportDockUpdateInterface (void)
 
virtual SlowDeathBehaviorInterfacegetSlowDeathBehaviorInterface ()
 
virtual SpecialPowerUpdateInterfacegetSpecialPowerUpdateInterface ()
 
virtual SlavedUpdateInterfacegetSlavedUpdateInterface ()
 
virtual ProductionUpdateInterfacegetProductionUpdateInterface ()
 
virtual HordeUpdateInterfacegetHordeUpdateInterface ()
 
virtual PowerPlantUpdateInterfacegetPowerPlantUpdateInterface ()
 
virtual SpawnBehaviorInterfacegetSpawnBehaviorInterface ()
 
virtual CountermeasuresBehaviorInterfacegetCountermeasuresBehaviorInterface ()
 
virtual const CountermeasuresBehaviorInterfacegetCountermeasuresBehaviorInterface () const
 
- Public Member Functions inherited from ObjectModule
 ObjectModule (Thing *thing, const ModuleData *moduleData)
 < this abstract class needs memory pool hooks
 
virtual void onCapture (Player *oldOwner, Player *newOwner)
 
virtual void onDisabledEdge (Bool nowDisabled)
 
- Public Member Functions inherited from Module
 Module (const ModuleData *moduleData)
 < this abstract class needs memory pool hooks
 
virtual NameKeyType getModuleNameKey () const =0
 
NameKeyType getModuleTagNameKey () const
 
virtual void onDrawableBoundToObject ()
 
virtual void preloadAssets (TimeOfDay timeOfDay)
 preload any assets we might have for this time of day
 
virtual void onDelete (void)
 
- Public Member Functions inherited from MemoryPoolObject
void deleteInstance ()
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 

Static Public Member Functions

static Int getInterfaceMask ()
 
- Static Public Member Functions inherited from PhysicsBehavior
static Int getInterfaceMask ()
 
- Static Public Member Functions inherited from UpdateModule
static Int getInterfaceMask ()
 
- Static Public Member Functions inherited from BehaviorModule
static Int getInterfaceMask ()
 
static ModuleType getModuleType ()
 
- Static Public Member Functions inherited from Module
static ModuleDatafriend_newModuleData (INI *ini)
 

Protected Types

enum  ConductorState { APPLY_BRAKES , WAIT_AT_STATION , ACCELERATE , COAST }
 
enum  StationTask { DO_NOTHING , DISEMBARK }
 

Protected Member Functions

void updatePositionTrackDistance (PullInfo *pullerInfo, PullInfo *myInfo)
 
void loadTrackData (void)
 
void createCarriages (void)
 
void FindPosByPathDistance (Coord3D *pos, const Real dist, const Real length, Bool setState=FALSE)
 
void playImpactSound (Object *victim, const Coord3D *impactPosition)
 
- Protected Member Functions inherited from PhysicsBehavior
virtual SleepyUpdatePhase getUpdatePhase () const
 
Real getAerodynamicFriction () const
 
Real getForwardFriction () const
 
Real getLateralFriction () const
 
Real getZFriction () const
 
void applyGravitationalForces ()
 
void applyFrictionalForces ()
 
Bool handleBounce (Real oldZ, Real newZ, Real groundZ, Coord3D *bounceForce)
 
void applyYPRDamping (Real factor)
 
UpdateSleepTime calcSleepTime () const
 
void doBounceSound (const Coord3D &prevPos)
 
Bool checkForOverlapCollision (Object *other)
 
void testStunnedUnitForDestruction (void)
 
- Protected Member Functions inherited from UpdateModule
void setWakeFrame (Object *obj, UpdateSleepTime wakeDelay)
 
UpdateSleepTime getWakeFrame () const
 
UpdateSleepTime frameToSleepTime (UnsignedInt frame1, UnsignedInt frame2=FOREVER, UnsignedInt frame3=FOREVER, UnsignedInt frame4=FOREVER)
 
- Protected Member Functions inherited from BehaviorModule
virtual void crc (Xfer *xfer)
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess (void)
 
- Protected Member Functions inherited from ObjectModule
ObjectgetObject ()
 
const ObjectgetObject () const
 
- Protected Member Functions inherited from Module
const ModuleDatagetModuleData () const
 
- Protected Member Functions inherited from MemoryPoolObject
virtual ~MemoryPoolObject ()
 
void * operator new (size_t s)
 
void operator delete (void *p)
 
virtual MemoryPoolgetObjectMemoryPool ()=0
 

Protected Attributes

TemplateNameIterator m_carriageTemplateNameIterator
 
StationTask m_nextStationTask
 
ObjectID m_trailerID
 the ID of the object I am directly pulling
 
PullInfo conductorPullInfo
 
PullInfo m_pullInfo
 
AudioEventRTS m_whistleSound
 
AudioEventRTS m_clicketyClackSound
 
AudioEventRTS m_runningSound
 
AudioHandle m_runningSoundHandle
 
TrainTrackm_track
 
Int m_currentPointHandle
 
Int m_waitAtStationTimer
 
Bool m_carriagesCreated
 TRUE once we have made all the cars in the train.
 
Bool m_hasEverBeenHitched
 
Bool m_trackDataLoaded
 has somebody ever hitched me? Remains true, even after puller dies.
 
Bool m_waitingInWings
 
Bool m_endOfLine
 I have not entered the real track yet, so leave me alone.
 
Bool m_isLocomotive
 I have reached the end of a non looping track.
 
Bool m_isLeadCarraige
 Am the carraige in front,.
 
Int m_wantsToBeLeadCarraige
 Am the carraige in front,.
 
Bool m_disembark
 If I wait at a station, I should also evacuate everybody when I get theres.
 
Bool m_inTunnel
 Am I in a tunnel, so I wil not snap to ground height, until the next waypoint,.
 
Bool m_held
 This will prevent a loco from departing a station.
 
ConductorState m_conductorState
 
WaypointID m_anchorWaypointID
 

Detailed Description

Definition at line 189 of file RailroadGuideAIUpdate.h.

Member Typedef Documentation

◆ TemplateNameIterator

typedef TemplateNameVector::const_iterator RailroadBehavior::TemplateNameIterator

Definition at line 217 of file RailroadGuideAIUpdate.h.

◆ TemplateNameVector

Definition at line 216 of file RailroadGuideAIUpdate.h.

Member Enumeration Documentation

◆ ConductorState

Enumerator
APPLY_BRAKES 
WAIT_AT_STATION 
ACCELERATE 
COAST 

Definition at line 246 of file RailroadGuideAIUpdate.h.

◆ StationTask

Enumerator
DO_NOTHING 
DISEMBARK 

Definition at line 254 of file RailroadGuideAIUpdate.h.

Constructor & Destructor Documentation

◆ RailroadBehavior()

RailroadBehavior::RailroadBehavior ( Thing * thing,
const ModuleData * moduleData )

Definition at line 105 of file RailroadGuideAIUpdate.cpp.

Member Function Documentation

◆ createCarriages()

void RailroadBehavior::createCarriages ( void )
protected

Definition at line 945 of file RailroadGuideAIUpdate.cpp.

◆ destroyTheWholeTrainNow()

void RailroadBehavior::destroyTheWholeTrainNow ( void )

Definition at line 1348 of file RailroadGuideAIUpdate.cpp.

◆ disembark()

void RailroadBehavior::disembark ( void )

Definition at line 864 of file RailroadGuideAIUpdate.cpp.

◆ FindPosByPathDistance()

void RailroadBehavior::FindPosByPathDistance ( Coord3D * pos,
const Real dist,
const Real length,
Bool setState = FALSE )
protected

Definition at line 1379 of file RailroadGuideAIUpdate.cpp.

◆ getInterfaceMask()

static Int RailroadBehavior::getInterfaceMask ( void )
inlinestatic

Definition at line 200 of file RailroadGuideAIUpdate.h.

◆ getPulled()

void RailroadBehavior::getPulled ( PullInfo * info)

Definition at line 1172 of file RailroadGuideAIUpdate.cpp.

◆ hasEverBeenHitched()

Bool RailroadBehavior::hasEverBeenHitched ( void )
inline

Definition at line 236 of file RailroadGuideAIUpdate.h.

◆ hitchNewCarriagebyProximity()

void RailroadBehavior::hitchNewCarriagebyProximity ( ObjectID parentID,
TrainTrack * trackPointList )

Definition at line 1096 of file RailroadGuideAIUpdate.cpp.

◆ hitchNewCarriagebyTemplate()

void RailroadBehavior::hitchNewCarriagebyTemplate ( ObjectID parentID,
const TemplateNameVector & list,
TemplateNameIterator & iter,
TrainTrack * trackPointList )

Definition at line 1037 of file RailroadGuideAIUpdate.cpp.

◆ isRailroad()

Bool RailroadBehavior::isRailroad ( ) const
virtual

Reimplemented from PhysicsBehavior.

Definition at line 195 of file RailroadGuideAIUpdate.cpp.

◆ loadTrackData()

void RailroadBehavior::loadTrackData ( void )
protected

Definition at line 504 of file RailroadGuideAIUpdate.cpp.

◆ makeAWallOutOfThisTrain()

void RailroadBehavior::makeAWallOutOfThisTrain ( Bool on)

Definition at line 646 of file RailroadGuideAIUpdate.cpp.

◆ onCollide()

void RailroadBehavior::onCollide ( Object * other,
const Coord3D * loc,
const Coord3D * normal )
virtual

Resolve the collision between getObject() and other by computing the amount the objects have overlapd, and applying proportional forces to push them apart. Note that this call only applies forces to our object, not to "other". Since the forces should be equal and opposite, this could be optimized.

Todo

Make this work properly for non-cylindrical objects (MSB)

Physics collision resolution is 2D - should it be 3D? (MSB)

Todo
srj – ugh, an awful hack for paradrop problems. fix someday.
Todo
srj – what the hell is this code doing here? ack!

Reimplemented from PhysicsBehavior.

Definition at line 217 of file RailroadGuideAIUpdate.cpp.

◆ playImpactSound()

void RailroadBehavior::playImpactSound ( Object * victim,
const Coord3D * impactPosition )
protected

Definition at line 432 of file RailroadGuideAIUpdate.cpp.

◆ setHeld()

void RailroadBehavior::setHeld ( Bool held)
inline

Definition at line 238 of file RailroadGuideAIUpdate.h.

◆ update()

UpdateSleepTime RailroadBehavior::update ( void )
virtual

Basic rigid body physics using an Euler integrator.

Todo
Currently, only translations are integrated. Rotations should also be integrated. (MSB)
Todo
Rotation should use torques, and integrate just like forces (MSB)

Reimplemented from PhysicsBehavior.

Definition at line 676 of file RailroadGuideAIUpdate.cpp.

◆ updatePositionTrackDistance()

void RailroadBehavior::updatePositionTrackDistance ( PullInfo * pullerInfo,
PullInfo * myInfo )
protected

Definition at line 1257 of file RailroadGuideAIUpdate.cpp.

Member Data Documentation

◆ conductorPullInfo

PullInfo RailroadBehavior::conductorPullInfo
protected

Definition at line 271 of file RailroadGuideAIUpdate.h.

◆ m_anchorWaypointID

WaypointID RailroadBehavior::m_anchorWaypointID
protected

Definition at line 302 of file RailroadGuideAIUpdate.h.

◆ m_carriagesCreated

Bool RailroadBehavior::m_carriagesCreated
protected

TRUE once we have made all the cars in the train.

Definition at line 285 of file RailroadGuideAIUpdate.h.

◆ m_carriageTemplateNameIterator

TemplateNameIterator RailroadBehavior::m_carriageTemplateNameIterator
protected

Definition at line 268 of file RailroadGuideAIUpdate.h.

◆ m_clicketyClackSound

AudioEventRTS RailroadBehavior::m_clicketyClackSound
protected

Definition at line 275 of file RailroadGuideAIUpdate.h.

◆ m_conductorState

ConductorState RailroadBehavior::m_conductorState
protected

Definition at line 300 of file RailroadGuideAIUpdate.h.

◆ m_currentPointHandle

Int RailroadBehavior::m_currentPointHandle
protected

Definition at line 281 of file RailroadGuideAIUpdate.h.

◆ m_disembark

Bool RailroadBehavior::m_disembark
protected

If I wait at a station, I should also evacuate everybody when I get theres.

Definition at line 293 of file RailroadGuideAIUpdate.h.

◆ m_endOfLine

Bool RailroadBehavior::m_endOfLine
protected

I have not entered the real track yet, so leave me alone.

Definition at line 289 of file RailroadGuideAIUpdate.h.

◆ m_hasEverBeenHitched

Bool RailroadBehavior::m_hasEverBeenHitched
protected

Definition at line 286 of file RailroadGuideAIUpdate.h.

◆ m_held

Bool RailroadBehavior::m_held
protected

This will prevent a loco from departing a station.

Definition at line 298 of file RailroadGuideAIUpdate.h.

◆ m_inTunnel

Bool RailroadBehavior::m_inTunnel
protected

Am I in a tunnel, so I wil not snap to ground height, until the next waypoint,.

Definition at line 294 of file RailroadGuideAIUpdate.h.

◆ m_isLeadCarraige

Bool RailroadBehavior::m_isLeadCarraige
protected

Am the carraige in front,.

Definition at line 291 of file RailroadGuideAIUpdate.h.

◆ m_isLocomotive

Bool RailroadBehavior::m_isLocomotive
protected

I have reached the end of a non looping track.

Am I a locomotive,

Definition at line 290 of file RailroadGuideAIUpdate.h.

◆ m_nextStationTask

StationTask RailroadBehavior::m_nextStationTask
protected

Definition at line 269 of file RailroadGuideAIUpdate.h.

◆ m_pullInfo

PullInfo RailroadBehavior::m_pullInfo
protected

Definition at line 272 of file RailroadGuideAIUpdate.h.

◆ m_runningSound

AudioEventRTS RailroadBehavior::m_runningSound
protected

Definition at line 276 of file RailroadGuideAIUpdate.h.

◆ m_runningSoundHandle

AudioHandle RailroadBehavior::m_runningSoundHandle
protected

Definition at line 277 of file RailroadGuideAIUpdate.h.

◆ m_track

TrainTrack* RailroadBehavior::m_track
protected

Definition at line 279 of file RailroadGuideAIUpdate.h.

◆ m_trackDataLoaded

Bool RailroadBehavior::m_trackDataLoaded
protected

has somebody ever hitched me? Remains true, even after puller dies.

have I TRIED to load track data, yet? I only try once!

Definition at line 287 of file RailroadGuideAIUpdate.h.

◆ m_trailerID

ObjectID RailroadBehavior::m_trailerID
protected

the ID of the object I am directly pulling

Definition at line 270 of file RailroadGuideAIUpdate.h.

◆ m_waitAtStationTimer

Int RailroadBehavior::m_waitAtStationTimer
protected

Definition at line 282 of file RailroadGuideAIUpdate.h.

◆ m_waitingInWings

Bool RailroadBehavior::m_waitingInWings
protected

Definition at line 288 of file RailroadGuideAIUpdate.h.

◆ m_wantsToBeLeadCarraige

Int RailroadBehavior::m_wantsToBeLeadCarraige
protected

Am the carraige in front,.

Definition at line 292 of file RailroadGuideAIUpdate.h.

◆ m_whistleSound

AudioEventRTS RailroadBehavior::m_whistleSound
protected

Definition at line 274 of file RailroadGuideAIUpdate.h.


The documentation for this class was generated from the following files: