From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/goal__path_8cpp-source.html | 336 +++++++++++++++++++++++++++ 1 file changed, 336 insertions(+) create mode 100644 docs/doxygen/nel/goal__path_8cpp-source.html (limited to 'docs/doxygen/nel/goal__path_8cpp-source.html') diff --git a/docs/doxygen/nel/goal__path_8cpp-source.html b/docs/doxygen/nel/goal__path_8cpp-source.html new file mode 100644 index 00000000..874cb205 --- /dev/null +++ b/docs/doxygen/nel/goal__path_8cpp-source.html @@ -0,0 +1,336 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

goal_path.cpp

Go to the documentation of this file.
00001 
+00006 /* Copyright, 2000 Nevrax Ltd.
+00007  *
+00008  * This file is part of NEVRAX NEL.
+00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00010  * it under the terms of the GNU General Public License as published by
+00011  * the Free Software Foundation; either version 2, or (at your option)
+00012  * any later version.
+00013 
+00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00017  * General Public License for more details.
+00018 
+00019  * You should have received a copy of the GNU General Public License
+00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00022  * MA 02111-1307, USA.
+00023  */
+00024 #include "nel/ai/logic/goal_path.h"
+00025 #include "nel/ai/agent/object_type.h"
+00026 #include "nel/ai/agent/msg_goal.h"
+00027 
+00028 
+00029 namespace NLAILOGIC
+00030 {
+00031         CGoalPath::CGoalPath(NLAIAGENT::IAgentManager *manager) : CActorScript( manager, true )
+00032         {
+00033         }
+00034 
+00035         CGoalPath::CGoalPath(NLAIAGENT::IAgentManager *manager, 
+00036                                                         NLAIAGENT::IBasicAgent *father,
+00037                                                            std::list<NLAIAGENT::IObjectIA *> &components,       
+00038                                                            NLAISCRIPT::CAgentClass *actor_class )
+00039         : CActorScript(manager, father, components, actor_class )
+00040         {       
+00041         }       
+00042 
+00043 
+00044         void CGoalPath::addGoal( CGoal *goal, bool action, int on_success, int on_failure )
+00045         {
+00046                 _Goals.push_back( goal );
+00047                 _JmpNext.push_back( action );
+00048                 _OnSucces.push_back( on_success );
+00049                 _OnFailure.push_back( on_failure );
+00050         }
+00051 
+00052         void CGoalPath::success()
+00053         {
+00054                 if ( _CurrentState < ( int(_Goals.size()) - 1 ) )
+00055                 {
+00056                         _CurrentState++;
+00057                         NLAIAGENT::IMessageBase *msg = new NLAIAGENT::CGoalMsg((NLAIAGENT::IBasicAgent *)NULL);
+00058                         msg->setPerformatif(NLAIAGENT::IMessageBase::PAchieve);
+00059                         CGoal *g = _Goals[ _CurrentState ];
+00060                         g->setSender( this );
+00061                         msg->set(0, g );
+00062                         msg->setSender( this );
+00063                         msg->setReceiver( _Father);
+00064                         _Father->sendMessage(msg);
+00065                 }
+00066                 else
+00067                 {
+00068                         // Sends the launcher a succes, then dies
+00069                         CActorScript::success();
+00070                 }
+00071         }
+00072 
+00073         void CGoalPath::failure()
+00074         {
+00075                 if ( _CurrentState < ( int(_Goals.size()) - 1 ) )
+00076                 {
+00077                         // Relaunches 
+00078                         NLAIAGENT::IMessageBase *msg = new NLAIAGENT::CGoalMsg((NLAIAGENT::IBasicAgent *)NULL);
+00079                         msg->setPerformatif(NLAIAGENT::IMessageBase::PAchieve);
+00080                         CGoal *g = _Goals[ _CurrentState ];
+00081                         g->setSender( this );
+00082                         msg->set(0, g );
+00083                         msg->setSender( this );
+00084                         msg->setReceiver( _Father);
+00085                         _Father->sendMessage(msg);
+00086 
+00087                 }
+00088                 else
+00089                 {
+00090                         // Sends the launcher a failure, then dies
+00091                         CActorScript::failure();
+00092                 }
+00093         }
+00094 
+00095 
+00096 //      sint32 getMethodIndexSize() const;
+00097 //      virtual tQueue getPrivateMember(const IVarName *,const IVarName *,const IObjectIA &) const;
+00098 //      virtual IObjectIA::CProcessResult runMethodBase(int heritance, int index,IObjectIA *);
+00099 //      virtual IObjectIA::CProcessResult runMethodBase(int index,IObjectIA *);
+00100 
+00101 
+00102         NLAIAGENT::tQueue CGoalPath::getPrivateMember(const NLAIAGENT::IVarName *className,const NLAIAGENT::IVarName *funcName,const NLAIAGENT::IObjectIA &params) const
+00103         {
+00104 
+00105 #ifdef NL_DEBUG 
+00106         std::string nameP;
+00107         std::string nameM;
+00108         funcName->getDebugString(nameM);
+00109         params.getDebugString(nameP);
+00110         const char *dbg_class_name = (const char *) getType();
+00111 #endif
+00112                 static NLAIAGENT::CStringVarName constructor_name("Constructor");
+00113                 static NLAIAGENT::CStringVarName add_goal_name("AddGoal");
+00114 
+00115                 NLAIAGENT::tQueue r;
+00116                 if(className == NULL)
+00117                 {
+00118                         if( (*funcName) == constructor_name )
+00119                         {                                       
+00120                                 NLAIAGENT::CObjectType *c = new NLAIAGENT::CObjectType( new NLAIC::CIdentType( CGoal::IdGoal ) );                                       
+00121                                 r.push( NLAIAGENT::CIdMethod( 0 + CActorScript::getMethodIndexSize(), 0.0, NULL, c) );                                  
+00122                         }
+00123 
+00124                         if( (*funcName) == add_goal_name )
+00125                         {                                       
+00126                                 NLAIAGENT::CObjectType *c = new NLAIAGENT::CObjectType( new NLAIC::CIdentType( CGoal::IdGoal ) );                                       
+00127                                 r.push( NLAIAGENT::CIdMethod( 1 + CActorScript::getMethodIndexSize(), 0.0, NULL, c) );                                  
+00128                         }
+00129                 }
+00130 
+00131                 if ( r.empty() )
+00132                         return CActorScript::getPrivateMember(className, funcName, params);
+00133                 else
+00134                         return r;
+00135         }
+00136 
+00137 
+00138         NLAIAGENT::IObjectIA::CProcessResult CGoalPath::runMethodBase(int heritance, int index, NLAIAGENT::IObjectIA *)
+00139         {
+00140                 return IObjectIA::CProcessResult();
+00141         }
+00142 
+00143         NLAIAGENT::IObjectIA::CProcessResult CGoalPath::runMethodBase(int index, NLAIAGENT::IObjectIA *p)
+00144         {
+00145                 NLAIAGENT::IBaseGroupType *param = (NLAIAGENT::IBaseGroupType *)p;
+00146 
+00147                 switch(index - CActorScript::getMethodIndexSize())
+00148                 {
+00149                         case 0:
+00150                                 {                                       
+00151 #ifdef NL_DEBUG
+00152                                         //const char *dbg_name = name->getStr().getString();
+00153 #endif
+00154                                         _Father = (NLAIAGENT::CProxyAgentMail *) param->getFront();
+00155                                         param->popFront();
+00156                                         // If the constructor() function is explicitely called and the object has already been initialised
+00157                                         while ( param->size() )
+00158                                         {
+00159                                                 _Goals.push_back( (NLAILOGIC::CGoal *) param->getFront()->clone() );
+00160                                                 param->popFront();
+00161                                         }
+00162                                         _CurrentState = 0;
+00163                                         return IObjectIA::CProcessResult();
+00164                                 } 
+00165                                 break;
+00166 
+00167                         case 1:
+00168                                 {                                       
+00169                                         // If the constructor() function is explicitely called and the object has already been initialised
+00170                                         while ( param->size() )
+00171                                         {
+00172                                                 _Goals.push_back( (NLAILOGIC::CGoal *) param->getFront()->clone() );
+00173                                                 param->popFront();
+00174                                         }
+00175                                         return IObjectIA::CProcessResult();
+00176                                 } 
+00177                                 break;
+00178 
+00179                 }
+00180 
+00181                 return CActorScript::runMethodBase( index, p );
+00182         }
+00183 
+00184         sint32 CGoalPath::getMethodIndexSize() const
+00185         {
+00186                 return CActorScript::getMethodIndexSize() + 2;
+00187         }
+00188 
+00189         const NLAIC::IBasicType *CGoalPath::clone() const
+00190         {
+00191                 NLAIC::IBasicInterface *m = new CGoalPath( *this );
+00192                 return m;
+00193         }
+00194 
+00195         const NLAIC::IBasicType *CGoalPath::newInstance() const
+00196         {
+00197                 return clone();
+00198         }
+00199 
+00200         const NLAIC::CIdentType &CGoalPath::getType() const
+00201         {
+00202                 return IdGoalPath;
+00203         }
+00204 
+00205         int CGoalPath::getBaseMethodCount() const
+00206         {
+00207                 return CActorScript::getBaseMethodCount() + 2;
+00208         }
+00209 /*
+00210         void CGoalPath::onPause()
+00211         {
+00212                 if ( _Father != NULL )
+00213                 {
+00214                         NLAIAGENT::IMessageBase *msg = new NLAIAGENT::CCancelGoalMsg((NLAIAGENT::IBasicAgent *)NULL);
+00215                         msg->setPerformatif(NLAIAGENT::IMessageBase::PAchieve);
+00216                         msg->set(0, _Goals[ _CurrentState ] );
+00217                         msg->setSender( this );
+00218                         msg->setReceiver( _Father);
+00219                         _Father->sendMessage(msg);
+00220                 }
+00221         }
+00222 
+00223         void CGoalPath::onRestart()
+00224         {
+00225                 if ( _Father != NULL )
+00226                 {
+00227                         NLAIAGENT::IMessageBase *msg = new NLAIAGENT::CGoalMsg((NLAIAGENT::IBasicAgent *)NULL);
+00228                         msg->setPerformatif(NLAIAGENT::IMessageBase::PAchieve);
+00229                         msg->set(0, _Goals[ _CurrentState ] );
+00230                         msg->setSender( this );
+00231                         msg->setReceiver( _Father);
+00232                         _Father->sendMessage(msg);
+00233                 }
+00234         }
+00235 */
+00236 
+00237         void CGoalPath::onActivate()
+00238         {
+00239                 _CurrentState = 0;
+00240                 if ( _Father != NULL )
+00241                 {
+00242                         NLAIAGENT::IMessageBase *msg = new NLAIAGENT::CGoalMsg((NLAIAGENT::IBasicAgent *)NULL);
+00243                         msg->setPerformatif(NLAIAGENT::IMessageBase::PAchieve);
+00244                         CGoal *g = _Goals[ _CurrentState ];
+00245                         g->setSender( this );
+00246                         msg->set(0, g );
+00247                         msg->setSender( this );
+00248                         msg->setReceiver( _Father);
+00249                         _Father->sendMessage(msg);
+00250                 }
+00251         }
+00252 
+00253         void CGoalPath::onUnActivate()
+00254         {
+00255                 _CurrentState = 0;
+00256                 if ( _Father != NULL )
+00257                 {
+00258                         NLAIAGENT::IMessageBase *msg = new NLAIAGENT::CCancelGoalMsg((NLAIAGENT::IBasicAgent *)NULL);
+00259                         msg->setPerformatif(NLAIAGENT::IMessageBase::PAchieve);
+00260                         msg->set(0, _Goals[ _CurrentState ] );
+00261                         msg->setSender( this );
+00262                         msg->setReceiver( _Father);
+00263                         _Father->sendMessage(msg);
+00264                 }
+00265         }
+00266 } // NLAILOGIC
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1