1
0
Fork 0

David Culp:

Here's code to support a new AICarrier class, which I think will be
sufficiently different from a basic AIShip that it should have its own class.
This commit is contained in:
ehofman 2004-10-28 08:33:55 +00:00
parent e5b1ab4831
commit 670ea7c881
5 changed files with 109 additions and 1 deletions

39
src/AIModel/AICarrier.cxx Normal file
View file

@ -0,0 +1,39 @@
// FGAICarrier - FGAIShip-derived class creates an AI aircraft carrier
//
// Written by David Culp, started October 2004.
// - davidculp2@comcast.net
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "AICarrier.hxx"
FGAICarrier::FGAICarrier(FGAIManager* mgr) : FGAIShip(mgr) {
}
FGAICarrier::~FGAICarrier() {
}
void FGAICarrier::update(double dt) {
FGAIShip::update(dt);
}

39
src/AIModel/AICarrier.hxx Normal file
View file

@ -0,0 +1,39 @@
// FGAICarrier - AIShip-derived class creates an AI aircraft carrier
//
// Written by David Culp, started October 2004.
//
// Copyright (C) 2004 David P. Culp - davidculp2@comcast.net
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef _FG_AICARRIER_HXX
#define _FG_AICARRIER_HXX
#include "AIShip.hxx"
class FGAIManager;
class FGAICarrier : public FGAIShip {
public:
FGAICarrier(FGAIManager* mgr);
~FGAICarrier();
private:
void update(double dt);
};
#endif // _FG_AICARRIER_HXX

View file

@ -30,6 +30,7 @@
#include "AIBallistic.hxx"
#include "AIStorm.hxx"
#include "AIThermal.hxx"
#include "AICarrier.hxx"
SG_USING_STD(list);
@ -184,6 +185,30 @@ FGAIManager::createShip( FGAIModelEntity *entity ) {
return ai_ship;
}
void*
FGAIManager::createCarrier( FGAIModelEntity *entity ) {
FGAIShip* ai_carrier = new FGAICarrier(this);
ai_list.push_back(ai_carrier);
++numObjects[0];
++numObjects[FGAIBase::otShip];
ai_carrier->setHeading(entity->heading);
ai_carrier->setSpeed(entity->speed);
ai_carrier->setPath(entity->path.c_str());
ai_carrier->setAltitude(entity->altitude);
ai_carrier->setLongitude(entity->longitude);
ai_carrier->setLatitude(entity->latitude);
ai_carrier->setBank(entity->rudder);
if ( entity->fp ) {
ai_carrier->setFlightPlan(entity->fp);
}
ai_carrier->init();
ai_carrier->bind();
return ai_carrier;
}
void*
FGAIManager::createBallistic( FGAIModelEntity *entity ) {
@ -301,6 +326,9 @@ void FGAIManager::processScenario( string &filename ) {
} else if ( en->m_type == "ship") {
createShip( en );
} else if ( en->m_type == "carrier") {
createCarrier( en );
} else if ( en->m_type == "thunderstorm") {
createStorm( en );

View file

@ -67,6 +67,7 @@ public:
void* createThermal( FGAIModelEntity *entity );
void* createStorm( FGAIModelEntity *entity );
void* createShip( FGAIModelEntity *entity );
void* createCarrier( FGAIModelEntity *entity );
void destroyObject( void* ID );

View file

@ -10,6 +10,7 @@ libAIModel_a_SOURCES = \
AIStorm.hxx AIStorm.cxx \
AIThermal.hxx AIThermal.cxx \
AIFlightPlan.hxx AIFlightPlan.cxx \
AIScenario.hxx AIScenario.cxx
AIScenario.hxx AIScenario.cxx \
AICarrier.hxx AICarrier.cxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src