mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
feat: started implementing infrared and laser
This commit is contained in:
@@ -430,3 +430,43 @@ private:
|
||||
const unsigned int intensity;
|
||||
const string explosionType;
|
||||
};
|
||||
|
||||
/* Shine a laser with a specific code */
|
||||
class Laser : public Command
|
||||
{
|
||||
public:
|
||||
Laser(unsigned int ID, unsigned int code, Coords destination, function<void(void)> callback = []() {}) :
|
||||
Command(callback),
|
||||
ID(ID),
|
||||
destination(destination),
|
||||
code(code)
|
||||
{
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const unsigned int ID;
|
||||
const unsigned int code;
|
||||
const Coords destination;
|
||||
};
|
||||
|
||||
/* Shine a infrared light */
|
||||
class Infrared : public Command
|
||||
{
|
||||
public:
|
||||
Infrared(unsigned int ID, Coords destination, function<void(void)> callback = []() {}) :
|
||||
Command(callback),
|
||||
ID(ID),
|
||||
destination(destination)
|
||||
{
|
||||
priority = CommandPriority::LOW;
|
||||
};
|
||||
virtual string getString();
|
||||
virtual unsigned int getLoad() { return 5; }
|
||||
|
||||
private:
|
||||
const unsigned int ID;
|
||||
const Coords destination;
|
||||
};
|
||||
|
||||
@@ -257,4 +257,29 @@ string Explosion::getString()
|
||||
<< location.lat << ", "
|
||||
<< location.lng;
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Laser command */
|
||||
string Laser::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.laser, "
|
||||
<< ID << ", "
|
||||
<< code << ", "
|
||||
<< destination.lat << ", "
|
||||
<< destination.lng;
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
/* Infrared command */
|
||||
string Infrared::getString()
|
||||
{
|
||||
std::ostringstream commandSS;
|
||||
commandSS.precision(10);
|
||||
commandSS << "Olympus.infrared, "
|
||||
<< ID << ", "
|
||||
<< destination.lat << ", "
|
||||
<< destination.lng;
|
||||
return commandSS.str();
|
||||
}
|
||||
@@ -695,6 +695,37 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("fireLaser") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
Unit* unit = unitsManager->getUnit(ID);
|
||||
if (unit != nullptr) {
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
unsigned int code = value[L"code"].as_integer();
|
||||
|
||||
log("Adding laser with code " + to_string(code) + " from unit " + unit->getUnitName() + " to (" + to_string(lat) + ", " + to_string(lng) + ")");
|
||||
|
||||
command = dynamic_cast<Command*>(new Laser(ID, code, loc));
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("fireInfrared") == 0)
|
||||
{
|
||||
unsigned int ID = value[L"ID"].as_integer();
|
||||
Unit* unit = unitsManager->getUnit(ID);
|
||||
if (unit != nullptr) {
|
||||
double lat = value[L"location"][L"lat"].as_double();
|
||||
double lng = value[L"location"][L"lng"].as_double();
|
||||
Coords loc; loc.lat = lat; loc.lng = lng;
|
||||
|
||||
log("Adding infrared from unit " + unit->getUnitName() + " to (" + to_string(lat) + ", " + to_string(lng) + ")");
|
||||
|
||||
command = dynamic_cast<Command*>(new Infrared(ID, loc));
|
||||
}
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("setCommandModeOptions") == 0)
|
||||
{
|
||||
setCommandModeOptions(value);
|
||||
|
||||
Reference in New Issue
Block a user