fgcommands "add-aiobject" and "remove-aiobject" for adding/removing objects to the AI subsystem.
This commit is contained in:
parent
0239d5ef44
commit
a8b550ee95
2 changed files with 20 additions and 4 deletions
|
@ -134,6 +134,8 @@ FGAIManager::init() {
|
|||
|
||||
globals->get_commands()->addCommand("load-scenario", this, &FGAIManager::loadScenarioCommand);
|
||||
globals->get_commands()->addCommand("unload-scenario", this, &FGAIManager::unloadScenarioCommand);
|
||||
globals->get_commands()->addCommand("add-aiobject", this, &FGAIManager::addObjectCommand);
|
||||
globals->get_commands()->addCommand("remove-aiobject", this, &FGAIManager::removeObjectCommand);
|
||||
_environmentVisiblity = fgGetNode("/environment/visibility-m");
|
||||
_groundSpeedKts_node = fgGetNode("/velocities/groundspeed-kt", true);
|
||||
|
||||
|
@ -213,6 +215,8 @@ FGAIManager::shutdown()
|
|||
|
||||
globals->get_commands()->removeCommand("load-scenario");
|
||||
globals->get_commands()->removeCommand("unload-scenario");
|
||||
globals->get_commands()->removeCommand("add-aiobject");
|
||||
globals->get_commands()->removeCommand("remove-aiobject");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -418,16 +422,19 @@ bool FGAIManager::unloadScenarioCommand(const SGPropertyNode * arg, SGPropertyNo
|
|||
return unloadScenario(name);
|
||||
}
|
||||
|
||||
bool FGAIManager::addObjectCommand(const SGPropertyNode* definition)
|
||||
bool FGAIManager::addObjectCommand(const SGPropertyNode* arg, const SGPropertyNode* root)
|
||||
{
|
||||
addObject(definition);
|
||||
if (!arg){
|
||||
return false;
|
||||
}
|
||||
addObject(arg);
|
||||
return true;
|
||||
}
|
||||
|
||||
FGAIBasePtr FGAIManager::addObject(const SGPropertyNode* definition)
|
||||
{
|
||||
const std::string& type = definition->getStringValue("type", "aircraft");
|
||||
|
||||
|
||||
FGAIBase* ai = NULL;
|
||||
if (type == "tanker") { // refueling scenarios
|
||||
ai = new FGAITanker;
|
||||
|
@ -465,6 +472,14 @@ FGAIBasePtr FGAIManager::addObject(const SGPropertyNode* definition)
|
|||
return ai;
|
||||
}
|
||||
|
||||
bool FGAIManager::removeObjectCommand(const SGPropertyNode* arg, const SGPropertyNode* root)
|
||||
{
|
||||
if (!arg) {
|
||||
return false;
|
||||
}
|
||||
return removeObject(arg);
|
||||
}
|
||||
|
||||
bool FGAIManager::removeObject(const SGPropertyNode* args)
|
||||
{
|
||||
int id = args->getIntValue("id");
|
||||
|
|
|
@ -115,7 +115,8 @@ private:
|
|||
|
||||
bool loadScenarioCommand(const SGPropertyNode* args, SGPropertyNode* root);
|
||||
bool unloadScenarioCommand(const SGPropertyNode* args, SGPropertyNode* root);
|
||||
bool addObjectCommand(const SGPropertyNode* definition);
|
||||
bool addObjectCommand(const SGPropertyNode* arg, const SGPropertyNode* root);
|
||||
bool removeObjectCommand(const SGPropertyNode* arg, const SGPropertyNode* root);
|
||||
|
||||
bool removeObject(const SGPropertyNode* args);
|
||||
bool unloadScenario( const std::string &filename );
|
||||
|
|
Loading…
Add table
Reference in a new issue