00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "nel/ai/agent/agent_digital.h"
00028 #include "nel/ai/script/interpret_methodes.h"
00029 #include "nel/ai/script/type_def.h"
00030 #include "nel/ai/agent/object_type.h"
00031 #include "nel/ai/agent/agent_method_def.h"
00032 #include "nel/ai/agent/agent_3dvector.h"
00033
00034
00035 namespace NLAIAGENT
00036 {
00037
00038
00039
00040
00041 sint32 IVector::getMethodIndexSize() const
00042 {
00043 return getMethodIndexSize() + 10;
00044 }
00045
00046
00047
00048
00049 tQueue IVector::isMember(const IVarName *baseClass,const IVarName *methodName,const IObjectIA &p) const
00050 {
00051
00052 static const CStringVarName methodX("x");
00053 static const CStringVarName methodY("y");
00054 static const CStringVarName methodZ("z");
00055 static const CStringVarName methodSquareLength("SquareLength");
00056 static const CStringVarName methodLength("Length");
00057 static const CStringVarName methodUnit("Unit");
00058 static const CStringVarName selfName((const char *)getType());
00059 static const CStringVarName constructor(_CONSTRUCTOR_);
00060
00061
00062 const NLAISCRIPT::CParam ¶m = (const NLAISCRIPT::CParam &)p;
00063
00064 if(baseClass == NULL || (*baseClass) == selfName)
00065 {
00066 if((*methodName) == methodX)
00067 {
00068 if(!param.size())
00069 {
00070 tQueue a;
00071
00072
00073 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(DDigitalType::IdDDigitalType));
00074 t->incRef();
00075
00076 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 1,0.0,NULL,t));
00077 return a;
00078 }
00079 else
00080 {
00081 NLAISCRIPT::CParam xParam;
00082 xParam.push(NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(DDigitalType::IdDDigitalType)));
00083 if(param == xParam)
00084 {
00085 tQueue a;
00086
00087
00088
00089 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
00090 t->incRef();
00091
00092 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 2,0.0,NULL,t));
00093 return a;
00094 }
00095 }
00096 }
00097 else if((*methodName) == methodY)
00098 {
00099 if(!param.size())
00100 {
00101 tQueue a;
00102
00103
00104 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(DDigitalType::IdDDigitalType));
00105 t->incRef();
00106
00107 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 3,0.0,NULL,t));
00108 return a;
00109 }
00110 else
00111 {
00112 NLAISCRIPT::CParam xParam;
00113 xParam.push(NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(DDigitalType::IdDDigitalType)));
00114 if(param == xParam)
00115 {
00116 tQueue a;
00117
00118
00119
00120 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
00121
00122 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 4,0.0,NULL,t));
00123 return a;
00124 }
00125 }
00126 }
00127 if((*methodName) == methodZ)
00128 {
00129 if(!param.size())
00130 {
00131 tQueue a;
00132
00133
00134 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(DDigitalType::IdDDigitalType));
00135
00136 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 5,0.0,NULL,t));
00137 return a;
00138 }
00139 else
00140 {
00141 NLAISCRIPT::CParam xParam;
00142 xParam.push(NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(DDigitalType::IdDDigitalType)));
00143 if(param == xParam)
00144 {
00145 tQueue a;
00146
00147
00148
00149 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
00150
00151 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 6,0.0,NULL,t));
00152 return a;
00153 }
00154 }
00155 }
00156 else if((*methodName) == methodSquareLength)
00157 {
00158 if(!param.size())
00159 {
00160 tQueue a;
00161
00162 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(DDigitalType::IdDDigitalType));
00163 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 7,0.0,NULL,t));
00164 return a;
00165 }
00166 }
00167 else if((*methodName) == methodLength)
00168 {
00169 if(!param.size())
00170 {
00171 tQueue a;
00172
00173 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(DDigitalType::IdDDigitalType));
00174 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 8,0.0,NULL,t));
00175 return a;
00176 }
00177 }
00178 else if((*methodName) == methodUnit)
00179 {
00180 if(!param.size())
00181 {
00182 tQueue a;
00183
00184 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
00185 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 9,0.0,NULL,t));
00186 return a;
00187 }
00188 }
00189 else if((*methodName) == constructor)
00190 {
00191 NLAISCRIPT::CParam constructParam;
00192 constructParam.push(NLAISCRIPT::COperandSimpleListOr(2,new NLAIC::CIdentType(DDigitalType::IdDDigitalType),new NLAIC::CIdentType(DDigitalType::IdDDigitalType)));
00193 constructParam.push(NLAISCRIPT::COperandSimpleListOr(2,new NLAIC::CIdentType(DDigitalType::IdDDigitalType),new NLAIC::CIdentType(DDigitalType::IdDDigitalType)));
00194 constructParam.push(NLAISCRIPT::COperandSimpleListOr(2,new NLAIC::CIdentType(DDigitalType::IdDDigitalType),new NLAIC::CIdentType(DDigitalType::IdDDigitalType)));
00195 if(constructParam.eval(param) >= 0.0 )
00196 {
00197 tQueue a;
00198
00199
00200
00201 NLAIAGENT::CObjectType *t = new NLAIAGENT::CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
00202
00203 a.push(CIdMethod(IObjetOp::getMethodIndexSize() + 0,0.0,NULL,t));
00204 return a;
00205 }
00206 }
00207 }
00208 return IObjetOp::isMember(baseClass,methodName,p);
00209 }
00210
00211
00212
00213
00214 sint32 IVector::isClassInheritedFrom(const IVarName &baseClass) const
00215 {
00216
00218
00219 const CStringVarName selfName((const char *)getType());
00220
00221 if((baseClass) == selfName) return 0;
00222 else return -1;
00224
00225
00226
00227
00228
00229
00230
00231 }
00232
00233
00234
00235
00236 IObjectIA::CProcessResult IVector::runMethodeMember(sint32 baseClassTag, sint32 methodTag, IObjectIA *p)
00237 {
00239 if(baseClassTag == 0)
00240 {
00241 return runMethodeMember(methodTag,p);
00242 }
00244
00245
00246
00247
00248
00249 return IObjectIA::runMethodeMember(baseClassTag,methodTag,p);
00250
00251 }
00252
00253
00254
00255
00256 IObjectIA::CProcessResult IVector::runMethodeMember(sint32 methodTag,IObjectIA *p)
00257 {
00258 IBaseGroupType ¶m = (IBaseGroupType &)*p;
00259
00260 switch(methodTag - IObjetOp::getMethodIndexSize())
00261 {
00262 case 0:
00263 {
00264 CIteratorContener i = param.getIterator();
00265 const INombreDefine *o = (const INombreDefine *)i++;
00266 x(o->getNumber());
00267 o = (const INombreDefine *)i++;
00268 y(o->getNumber());
00269 o = (const INombreDefine *)i++;
00270 z(o->getNumber());
00271 IObjectIA::CProcessResult a;
00272 a.ResultState = processIdle;
00273 a.Result = NULL;
00274 return a;
00275 }
00276
00277 case 1:
00278 {
00279 DDigitalType *r = new DDigitalType(x());
00280 r->incRef();
00281 IObjectIA::CProcessResult a;
00282 a.ResultState = processIdle;
00283 a.Result = r;
00284 return a;
00285 }
00286
00287 case 2:
00288 {
00289
00290 x(((const INombreDefine *)param.get())->getNumber());
00291 IObjectIA::CProcessResult a;
00292 a.ResultState = processIdle;
00293 a.Result = NULL;
00294 return a;
00295 }
00296
00297 case 3:
00298 {
00299 DDigitalType *r = new DDigitalType(y());
00300 r->incRef();
00301 IObjectIA::CProcessResult a;
00302 a.ResultState = processIdle;
00303 a.Result = r;
00304 return a;
00305 }
00306
00307 case 4:
00308 {
00309 y(((const INombreDefine *)param.get())->getNumber());
00310 IObjectIA::CProcessResult a;
00311 a.ResultState = processIdle;
00312 a.Result = NULL;
00313 return a;
00314 }
00315
00316 case 5:
00317 {
00318 DDigitalType *r = new DDigitalType(z());
00319 r->incRef();
00320 IObjectIA::CProcessResult a;
00321 a.ResultState = processIdle;
00322 a.Result = r;
00323 return a;
00324 }
00325
00326 case 6:
00327 {
00328 z(((const INombreDefine *)param.get())->getNumber());
00329 IObjectIA::CProcessResult a;
00330 a.ResultState = processIdle;
00331 a.Result = NULL;
00332 return a;
00333 }
00334
00335 case 7:
00336 {
00337 DDigitalType *r = new DDigitalType(squareLength());
00338 r->incRef();
00339 IObjectIA::CProcessResult a;
00340 a.ResultState = processIdle;
00341 a.Result = r;
00342 return a;
00343 }
00344
00345 case 8:
00346 {
00347 DDigitalType *r = new DDigitalType(length());
00348 r->incRef();
00349 IObjectIA::CProcessResult a;
00350 a.ResultState = processIdle;
00351 a.Result = r;
00352 return a;
00353 }
00354
00355 case 9:
00356 {
00357 unit();
00358 IObjectIA::CProcessResult a;
00359 a.ResultState = processIdle;
00360 a.Result = NULL;
00361 return a;
00362 }
00363
00364 default:
00365 return IObjetOp::runMethodeMember(methodTag,p);
00366 break;
00367 }
00368 }
00369
00370
00371
00372
00373 const IObjectIA::CProcessResult &VectorType::run()
00374 {
00375 return IObjectIA::ProcessRun;
00376 }
00377
00378
00379
00380
00381 const NLAIC::CIdentType &VectorType::getType() const
00382 {
00383 return IdVectorType;
00384 }
00385
00386 }
00387
00388 using namespace NLAIAGENT;
00389 const NLAIC::CIdentType VectorType::IdVectorType("Vector3D",NLAIC::CSelfClassFactory(VectorType(0, 0, 0)),
00390 NLAIC::CTypeOfObject(NLAIC::CTypeOfObject::tObject),
00391 NLAIC::CTypeOfOperator(NLAIC::CTypeOfOperator::opAdd |
00392 NLAIC::CTypeOfOperator::opSub |
00393 NLAIC::CTypeOfOperator::opEq |
00394 NLAIC::CTypeOfOperator::opDiff));
00395