1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
#ifndef GROUNDMOVETYPE_H
#define GROUNDMOVETYPE_H
#include "MoveType.h"
#include "Sim/Objects/SolidObject.h"
struct MoveData;
class CGroundMoveType : public AMoveType
{
CR_DECLARE(CGroundMoveType);
public:
CGroundMoveType(CUnit* owner);
~CGroundMoveType(void);
void PostLoad();
void Update();
void SlowUpdate();
void SetDeltaSpeed(bool);
void StartMoving(float3 pos, float goalRadius);
void StartMoving(float3 pos, float goalRadius, float speed);
void StopMoving();
virtual void SetMaxSpeed(float speed);
void ImpulseAdded(void);
void KeepPointingTo(float3 pos, float distance, bool aggressive);
void KeepPointingTo(CUnit* unit, float distance, bool aggressive);
bool OnSlope(void);
float baseTurnRate;
float turnRate;
float accRate;
float decRate;
float maxReverseSpeed;
float wantedSpeed;
float currentSpeed;
float deltaSpeed;
short int deltaHeading;
float3 oldPos;
float3 oldSlowUpdatePos;
float3 flatFrontDir;
unsigned int pathId;
float goalRadius;
SyncedFloat3 waypoint;
SyncedFloat3 nextWaypoint;
/// by this time it really should have gotten there genereate new path otherwise
int etaWaypoint;
/// by this time we get suspicious, check if goal is clogged if we are close
int etaWaypoint2;
bool atGoal;
bool haveFinalWaypoint;
float terrainSpeed;
float requestedSpeed;
short requestedTurnRate;
float currentDistanceToWaypoint;
float3 avoidanceVec;
unsigned int restartDelay;
float3 lastGetPathPos;
unsigned int pathFailures;
/// how many times we havent gotten to a waypoint in time
unsigned int etaFailures;
/// how many times we have requested a path from the same place
unsigned int nonMovingFailures;
bool floatOnWater;
int moveSquareX;
int moveSquareY;
protected:
int nextDeltaSpeedUpdate;
int nextObstacleAvoidanceUpdate;
int lastTrackUpdate;
float3 ObstacleAvoidance(float3 desiredDir);
float Distance2D(CSolidObject *object1, CSolidObject *object2, float marginal = 0.0f);
void GetNewPath();
void GetNextWaypoint();
float BreakingDistance(float speed);
float3 Here();
float MinDistanceToWaypoint();
float MaxDistanceToWaypoint();
void StartEngine();
void StopEngine();
void Arrived();
void Fail();
void CheckCollision(void);
void ChangeHeading(short wantedHeading);
void UpdateSkid(void);
void UpdateControlledDrop(void);
void CheckCollisionSkid(void);
float GetFlyTime(float3 pos, float3 speed);
void CalcSkidRot(void);
void AdjustPosToWaterLine();
bool UpdateDirectControl();
void UpdateOwnerPos(bool);
bool WantReverse(const float3&) const;
unsigned int lastHeatRequestFrame;
unsigned int RequestPath(float3 startPos, float3 goalPos, float goalRadius = 8);
void UpdateHeatMap();
bool skidding;
bool flying;
bool reversing;
float skidRotSpeed;
float dropSpeed;
float dropHeight;
float3 skidRotVector;
float skidRotSpeed2;
float skidRotPos2;
CSolidObject::PhysicalState oldPhysState;
bool CheckColH(int x, int y1, int y2, float xmove, int squareTestX);
bool CheckColV(int y, int x1, int x2, float zmove, int squareTestY);
static std::vector<int2> (*lineTable)[11];
float3 mainHeadingPos;
bool useMainHeading;
void SetMainHeading();
public:
static void CreateLineTable(void);
static void DeleteLineTable(void);
void TestNewTerrainSquare(void);
bool CheckGoalFeasability(void);
virtual void LeaveTransport(void);
void StartSkidding(void);
void StartFlying(void);
bool IsSkidding() const { return skidding; }
bool IsFlying() const { return flying; }
bool IsReversing() const { return reversing; }
};
#endif // GROUNDMOVETYPE_H
|