#include <boost/foreach.hpp>
#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
#include <Airports/airport.hxx>
#include <Scripting/NasalSys.hxx>
}
FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+ if (!nasalSys)
+ return;
+
std::string moduleName = "scenario_" + _internalName;
if (!_unloadScript.empty()) {
nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
globals->get_commands()->addCommand("load-scenario", this, &FGAIManager::loadScenarioCommand);
globals->get_commands()->addCommand("unload-scenario", this, &FGAIManager::unloadScenarioCommand);
+ _environmentVisiblity = fgGetNode("/environment/visibility-m");
}
void
}
ai_list.clear();
+ _environmentVisiblity.clear();
+
+ globals->get_commands()->removeCommand("load-scenario");
+ globals->get_commands()->removeCommand("unload-scenario");
}
void
p->setBoolValue("valid", true);
}
+bool FGAIManager::isVisible(const SGGeod& pos) const
+{
+ double visibility_meters = _environmentVisiblity->getDoubleValue();
+ return ( dist(globals->get_view_position_cart(), SGVec3d::fromGeod(pos)) ) <= visibility_meters;
+}
+
int
FGAIManager::getNumAiObjects() const
{
}
ai->readFromScenario(const_cast<SGPropertyNode*>(definition));
- attach(ai);
+ if((ai->isValid())){
+ attach(ai);
+ SG_LOG(SG_AI, SG_DEBUG, "attached scenario " << ai->_getName());
+ }
+ else{
+ ai->setDie(true);
+ SG_LOG(SG_AI, SG_ALERT, "killed invalid scenario " << ai->_getName());
+ }
return ai;
}