Added backend for altitude type, onOff, follow roads and explosion

This commit is contained in:
Pax1601
2023-06-05 21:22:22 +02:00
parent ec0b179e32
commit dca3438db0
24 changed files with 198 additions and 91 deletions

View File

@@ -10,12 +10,4 @@ public:
virtual void changeSpeed(wstring change);
virtual void changeAltitude(wstring change);
virtual double getTargetSpeed() { return targetSpeed; };
virtual double getTargetAltitude() { return targetAltitude; };
virtual void setTargetSpeed(double newTargetSpeed);
virtual void setTargetAltitude(double newTargetAltitude);
protected:
double targetSpeed = 300 / 1.94384;
double targetAltitude = 20000 * 0.3048;
};

View File

@@ -15,8 +15,10 @@ public:
virtual wstring getCategory() = 0;
virtual void changeSpeed(wstring change) {};
virtual void changeAltitude(wstring change) {};
virtual void setTargetSpeed(double newTargetSpeed) {};
virtual void setTargetAltitude(double newTargetAltitude) {};
virtual void setTargetSpeed(double newTargetSpeed);
virtual void setTargetAltitude(double newTargetAltitude);
virtual void setTargetSpeedType(wstring newTargetSpeedType);
virtual void setTargetAltitudeType(wstring newTargetAltitudeType);
protected:
virtual void AIloop();

View File

@@ -81,8 +81,6 @@ namespace ECMUse {
};
}
/* Base command class */
class Command
{
@@ -99,11 +97,13 @@ protected:
class Move : public Command
{
public:
Move(int ID, Coords destination, double speed, double altitude, wstring taskOptions):
Move(int ID, Coords destination, double speed, wstring speedType, double altitude, wstring altitudeType, wstring taskOptions):
ID(ID),
destination(destination),
speed(speed),
speedType(speedType),
altitude(altitude),
altitudeType(altitudeType),
taskOptions(taskOptions)
{
priority = CommandPriority::HIGH;
@@ -115,7 +115,9 @@ private:
const int ID;
const Coords destination;
const double speed;
const wstring speedType;
const double altitude;
const wstring altitudeType;
const wstring taskOptions;
};
@@ -203,8 +205,9 @@ private:
class Delete : public Command
{
public:
Delete(int ID) :
ID(ID)
Delete(int ID, bool explosion) :
ID(ID),
explosion(explosion)
{
priority = CommandPriority::HIGH;
};
@@ -213,6 +216,7 @@ public:
private:
const int ID;
const bool explosion;
};
/* Follow command */
@@ -299,4 +303,22 @@ private:
const int optionValue;
const bool optionBool;
const bool isBoolean;
};
};
/* Set on ooff */
class SetOnOff : public Command
{
public:
SetOnOff(int ID, bool onOff) :
ID(ID),
onOff(onOff)
{
priority = CommandPriority::HIGH;
};
virtual wstring getString(lua_State* L);
virtual int getLoad() { return 10; }
private:
const int ID;
const bool onOff;
};

View File

@@ -12,8 +12,7 @@ public:
virtual wstring getCategory() { return L"GroundUnit"; };
virtual void changeSpeed(wstring change);
virtual void changeAltitude(wstring change) {};
virtual double getTargetSpeed() { return targetSpeed; };
virtual void setOnOff(bool newOnOff);
virtual void setFollowRoads(bool newFollowRoads);
protected:
double targetSpeed = 10;
};

View File

@@ -10,12 +10,4 @@ public:
virtual void changeSpeed(wstring change);
virtual void changeAltitude(wstring change);
virtual double getTargetSpeed() { return targetSpeed; };
virtual double getTargetAltitude() { return targetAltitude; };
virtual void setTargetSpeed(double newTargetSpeed);
virtual void setTargetAltitude(double newTargetAltitude);
protected:
double targetSpeed = 100 / 1.94384;
double targetAltitude = 5000 * 0.3048;
};

View File

@@ -10,8 +10,5 @@ public:
virtual wstring getCategory() { return L"NavyUnit"; };
virtual void changeSpeed(wstring change);
virtual void changeAltitude(wstring change) {};
virtual double getTargetSpeed() { return targetSpeed; };
protected:
double targetSpeed = 10;
};

View File

@@ -112,9 +112,11 @@ public:
Offset getFormationoffset() { return formationOffset; }
/********** Task data **********/
void setCurrentTask(wstring newCurrentTask) { currentTask = newCurrentTask;addMeasure(L"currentTask", json::value(newCurrentTask)); }
void setCurrentTask(wstring newCurrentTask) { currentTask = newCurrentTask; addMeasure(L"currentTask", json::value(newCurrentTask)); }
virtual void setTargetSpeed(double newTargetSpeed) { targetSpeed = newTargetSpeed; addMeasure(L"targetSpeed", json::value(newTargetSpeed));}
virtual void setTargetAltitude(double newTargetAltitude) { targetAltitude = newTargetAltitude; addMeasure(L"targetAltitude", json::value(newTargetAltitude));} //TODO fix, double definition
virtual void setTargetAltitude(double newTargetAltitude) { targetAltitude = newTargetAltitude; addMeasure(L"targetAltitude", json::value(newTargetAltitude));}
virtual void setTargetSpeedType(wstring newTargetSpeedType) { targetSpeedType = newTargetSpeedType; addMeasure(L"targetSpeedType", json::value(newTargetSpeedType)); }
virtual void setTargetAltitudeType(wstring newTargetAltitudeType) { targetAltitudeType = newTargetAltitudeType; addMeasure(L"targetAltitudeType", json::value(newTargetAltitudeType)); }
void setActiveDestination(Coords newActiveDestination) { activeDestination = newActiveDestination; addMeasure(L"activeDestination", json::value("")); } // TODO fix
void setActivePath(list<Coords> newActivePath);
void clearActivePath();
@@ -124,15 +126,21 @@ public:
void setTargetID(int newTargetID) { targetID = newTargetID; addMeasure(L"targetID", json::value(newTargetID));}
void setIsTanker(bool newIsTanker);
void setIsAWACS(bool newIsAWACS);
virtual void setOnOff(bool newOnOff) { onOff = newOnOff; addMeasure(L"onOff", json::value(newOnOff));};
virtual void setFollowRoads(bool newFollowRoads) { followRoads = newFollowRoads; addMeasure(L"followRoads", json::value(newFollowRoads)); };
wstring getCurrentTask() { return currentTask; }
virtual double getTargetSpeed() { return targetSpeed; };
virtual double getTargetAltitude() { return targetAltitude; };
virtual wstring getTargetSpeedType() { return targetSpeedType; };
virtual wstring getTargetAltitudeType() { return targetAltitudeType; };
Coords getActiveDestination() { return activeDestination; }
list<Coords> getActivePath() { return activePath; }
int getTargetID() { return targetID; }
bool getIsTanker() { return isTanker; }
bool getIsAWACS() { return isAWACS; }
bool getOnOff() { return onOff; };
bool getFollowRoads() { return followRoads; };
/********** Options data **********/
void setROE(wstring newROE);
@@ -196,11 +204,15 @@ protected:
wstring currentTask = L"";
double targetSpeed = 0;
double targetAltitude = 0;
wstring targetSpeedType = L"GS";
wstring targetAltitudeType = L"AGL";
list<Coords> activePath;
Coords activeDestination = Coords(0);
int targetID = NULL;
bool isTanker = false;
bool isAWACS = false;
bool onOff = true;
bool followRoads = false;
/********** Options data **********/
wstring ROE = L"Designated";

View File

@@ -14,7 +14,7 @@ public:
void updateExportData(lua_State* L);
void updateMissionData(json::value missionData);
void getData(json::value& answer, long long time);
void deleteUnit(int ID);
void deleteUnit(int ID, bool explosion);
private:
map<int, Unit*> units;