mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added basic tanker and AWACS enroute tasks
Tanker not working propertly yet, frequency setting still needed
This commit is contained in:
@@ -103,12 +103,16 @@ public:
|
||||
void pushActivePathBack(Coords newActivePathBack);
|
||||
void popActivePathFront();
|
||||
void setTargetID(int newTargetID) { targetID = newTargetID; addMeasure(L"targetID", json::value(newTargetID));}
|
||||
void setIsTanker(bool newIsTanker) { isTanker = newIsTanker; addMeasure(L"isTanker", json::value(newIsTanker));}
|
||||
void setIsAWACS(bool newIsAWACS) { isAWACS = newIsAWACS; addMeasure(L"isAWACS", json::value(newIsAWACS));}
|
||||
wstring getCurrentTask() { return currentTask; }
|
||||
virtual double getTargetSpeed() { return targetSpeed; };
|
||||
virtual double getTargetAltitude() { return targetAltitude; };
|
||||
Coords getActiveDestination() { return activeDestination; }
|
||||
list<Coords> getActivePath() { return activePath; }
|
||||
int getTargetID() { return targetID; }
|
||||
bool getIsTanker() { return isTanker; }
|
||||
bool getIsAWACS() { return isAWACS; }
|
||||
|
||||
/********** Options data **********/
|
||||
void setROE(wstring newROE);
|
||||
@@ -168,6 +172,8 @@ protected:
|
||||
list<Coords> activePath;
|
||||
Coords activeDestination = Coords(0);
|
||||
int targetID = NULL;
|
||||
bool isTanker = false;
|
||||
bool isAWACS = false;
|
||||
|
||||
/********** Options data **********/
|
||||
wstring ROE = L"";
|
||||
|
||||
@@ -22,6 +22,7 @@ void AirUnit::setState(int newState)
|
||||
{
|
||||
if (state != newState)
|
||||
{
|
||||
/* Perform any action required when LEAVING a certain state */
|
||||
switch (state) {
|
||||
case State::IDLE: {
|
||||
break;
|
||||
@@ -44,10 +45,14 @@ void AirUnit::setState(int newState)
|
||||
case State::LAND: {
|
||||
break;
|
||||
}
|
||||
case State::REFUEL: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Perform any action required when ENTERING a certain state */
|
||||
switch (newState) {
|
||||
case State::IDLE: {
|
||||
resetActiveDestination();
|
||||
@@ -79,6 +84,11 @@ void AirUnit::setState(int newState)
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
case State::REFUEL: {
|
||||
clearActivePath();
|
||||
resetActiveDestination();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -225,8 +235,23 @@ void AirUnit::AIloop()
|
||||
break;
|
||||
}
|
||||
case State::REACH_DESTINATION: {
|
||||
wstring enrouteTask = L"nil";
|
||||
currentTask = L"Reaching destination";
|
||||
wstring enrouteTask = L"";
|
||||
|
||||
if (isTanker)
|
||||
{
|
||||
enrouteTask = L"{" "id = 'Tanker' }";
|
||||
currentTask = L"Tanker";
|
||||
}
|
||||
else if (isAWACS)
|
||||
{
|
||||
enrouteTask = L"{" "id = 'AWACS' }";
|
||||
currentTask = L"AWACS";
|
||||
}
|
||||
else
|
||||
{
|
||||
enrouteTask = L"nil";
|
||||
currentTask = L"Reaching destination";
|
||||
}
|
||||
|
||||
if (activeDestination == NULL || !hasTask)
|
||||
{
|
||||
@@ -338,6 +363,17 @@ void AirUnit::AIloop()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case State::REFUEL: {
|
||||
if (!hasTask) {
|
||||
std::wostringstream taskSS;
|
||||
taskSS << "{"
|
||||
<< "id = 'Refuel'"
|
||||
<< "}";
|
||||
Command* command = dynamic_cast<Command*>(new SetTask(ID, taskSS.str()));
|
||||
scheduler->appendCommand(command);
|
||||
hasTask = true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -250,6 +250,26 @@ void Scheduler::handleRequest(wstring key, json::value value)
|
||||
int ID = value[L"ID"].as_integer();
|
||||
unitsManager->deleteUnit(ID);
|
||||
}
|
||||
else if (key.compare(L"refuel") == 0)
|
||||
{
|
||||
int ID = value[L"ID"].as_integer();
|
||||
Unit* unit = unitsManager->getUnit(ID);
|
||||
unit->setState(State::REFUEL);
|
||||
}
|
||||
else if (key.compare(L"setIsTanker") == 0)
|
||||
{
|
||||
int ID = value[L"ID"].as_integer();
|
||||
bool state = value[L"state"].as_bool();
|
||||
Unit* unit = unitsManager->getUnit(ID);
|
||||
unit->setIsTanker(state);
|
||||
}
|
||||
else if (key.compare(L"setIsAWACS") == 0)
|
||||
{
|
||||
int ID = value[L"ID"].as_integer();
|
||||
bool state = value[L"state"].as_bool();
|
||||
Unit* unit = unitsManager->getUnit(ID);
|
||||
unit->setIsAWACS(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
log(L"Unknown command: " + key);
|
||||
|
||||
Reference in New Issue
Block a user