bool FGAIBallistic::init(bool search_in_AI_path) {
FGAIBase::init(search_in_AI_path);
+ reinit();
+ return true;
+}
+void FGAIBallistic::reinit() {
_impact_reported = false;
_collision_reported = false;
_expiry_reported = false;
setParentNodes(_selected_ac);
- return true;
+ FGAIBase::reinit();
}
void FGAIBallistic::bind() {
bool init(bool search_in_AI_path=false);
virtual void bind();
virtual void unbind();
+ virtual void reinit();
+ virtual void update(double dt);
- void update(double dt);
-
- FGAIBallistic *ballistic;
+ virtual const char* getTypeString(void) const { return "ballistic"; }
void Run(double dt);
// bool getFormate() const;
bool getSlavedLoad() const;
- virtual const char* getTypeString(void) const { return "ballistic"; }
+ FGAIBallistic *ballistic;
+
static const double slugs_to_kgs; //conversion factor
static const double slugs_to_lbs; //conversion factor
private:
- virtual void reinit() { init(); }
-
bool _aero_stabilised; // if true, object will align with trajectory
double _drag_area; // equivalent drag area in ft2
double _life_timer; // seconds
}
-bool FGAIBase::init(bool search_in_AI_path) {
-
+bool FGAIBase::init(bool search_in_AI_path)
+{
+ if (_model.valid())
+ {
+ SG_LOG(SG_AI, SG_WARN, "AIBase: Cannot initialize a model multiple times! " << model_path);
+ return false;
+ }
+
string f;
if(search_in_AI_path)
{
_aimodel = new FGAIModelData(props);
osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, _aimodel);
- if (_model.valid())
- {
- // reinit, dump the old model
- removeModel();
- }
-
_model = new osg::LOD;
_model->setName("AI-model range animation node");
bool FGAIEscort::init(bool search_in_AI_path) {
if (!FGAIShip::init(search_in_AI_path))
return false;
+ reinit();
+ return true;
+}
+void FGAIEscort::reinit() {
invisible = false;
no_roll = false;
hdg = _parent_hdg;
}
- return true;
+ FGAIShip::reinit();
}
void FGAIEscort::update(double dt) {
virtual ~FGAIEscort();
virtual void readFromScenario(SGPropertyNode* scFileNode);
+
+ bool init(bool search_in_AI_path=false);
virtual void bind();
virtual void unbind();
- virtual const char* getTypeString(void) const { return "escort"; }
+ virtual void reinit();
+ virtual void update (double dt);
- bool init(bool search_in_AI_path=false);
+ virtual const char* getTypeString(void) const { return "escort"; }
private:
-
- virtual void reinit() { init(); }
- virtual void update (double dt);
-
void setStnRange(double r);
void setStnBrg(double y);
void setStationSpeed();
bool FGAIGroundVehicle::init(bool search_in_AI_path) {
if (!FGAIShip::init(search_in_AI_path))
return false;
+ reinit();
+ return true;
+}
+void FGAIGroundVehicle::reinit() {
invisible = false;
_limit = 200;
no_roll = true;
setParent();
}
- return true;
+ FGAIShip::reinit();
}
void FGAIGroundVehicle::update(double dt) {
virtual ~FGAIGroundVehicle();
virtual void readFromScenario(SGPropertyNode* scFileNode);
+
+ bool init(bool search_in_AI_path=false);
virtual void bind();
virtual void unbind();
- virtual const char* getTypeString(void) const { return "groundvehicle"; }
+ virtual void reinit();
+ virtual void update (double dt);
- bool init(bool search_in_AI_path=false);
+ virtual const char* getTypeString(void) const { return "groundvehicle"; }
private:
- virtual void reinit() { init(); }
- virtual void update (double dt);
-
void setNoRoll(bool nr);
void setContactX1offset(double x1);
void setContactX2offset(double x2);
}
bool FGAIShip::init(bool search_in_AI_path) {
+ reinit();
+ return FGAIBase::init(search_in_AI_path);
+}
+
+void FGAIShip::reinit()
+{
prev = 0; // the one behind you
curr = 0; // the one ahead
next = 0; // the next plus 1
if (fp)
_fp_init = initFlightPlan();
- return FGAIBase::init(search_in_AI_path);
+ FGAIBase::reinit();
}
void FGAIShip::bind() {
virtual void bind();
virtual void unbind();
virtual void update(double dt);
+ virtual void reinit();
+
void setFlightPlan(FGAIFlightPlan* f);
-// void setName(const string&);
void setRudder(float r);
void setRoll(double rl);
void ProcessFlightPlan( double dt);
protected:
-// string _name; // The name of this ship.
-
private:
-
- virtual void reinit() { init(); }
-
void setRepeat(bool r);
void setRestart(bool r);
void setMissed(bool m);
bool FGAIWingman::init(bool search_in_AI_path) {
if (!FGAIBallistic::init(search_in_AI_path))
return false;
+ reinit();
+ return true;
+}
+void FGAIWingman::reinit() {
invisible = false;
_tgt_x_offset = _x_offset;
props->setStringValue("submodels/path", _path.c_str());
user_WoW_node = fgGetNode("gear/gear[1]/wow", true);
- return true;
+
+ FGAIBallistic::reinit();
}
void FGAIWingman::update(double dt) {
virtual ~FGAIWingman();
virtual void readFromScenario(SGPropertyNode* scFileNode);
+
+ bool init(bool search_in_AI_path=false);
virtual void bind();
virtual void unbind();
- virtual const char* getTypeString(void) const { return "wingman"; }
+ virtual void reinit();
+ virtual void update (double dt);
- bool init(bool search_in_AI_path=false);
+ virtual const char* getTypeString(void) const { return "wingman"; }
private:
-
- virtual void reinit() { init(); }
- virtual void update (double dt);
-
void formateToAC(double dt);
void Break(double dt);
void Join(double dt);