]> git.mxchange.org Git - flightgear.git/commitdiff
David Culp:
authorehofman <ehofman>
Thu, 28 Oct 2004 08:33:55 +0000 (08:33 +0000)
committerehofman <ehofman>
Thu, 28 Oct 2004 08:33:55 +0000 (08:33 +0000)
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.

src/AIModel/AICarrier.cxx [new file with mode: 0644]
src/AIModel/AICarrier.hxx [new file with mode: 0644]
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx
src/AIModel/Makefile.am

diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx
new file mode 100644 (file)
index 0000000..bb52128
--- /dev/null
@@ -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);
+}
+
+
+
diff --git a/src/AIModel/AICarrier.hxx b/src/AIModel/AICarrier.hxx
new file mode 100644 (file)
index 0000000..c536c45
--- /dev/null
@@ -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
index a3d670e33f4148c656e82a5591553e38f0ce7744..c925deaa87cdccfecc7c875ee2dad15d03c31163 100644 (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 );
 
index 619d91961d60bb9d0a6c805f1bf94d282e17b4fc..59b879b1f5d4f50638fe0966a2a5604bdd4c28cf 100644 (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 );
 
index d3429a8caf0e4f0fb7d3bad06cc55cf03f3307f2..a44c13f90c00186e339f93898cfbbd9ddfe9df53 100644 (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