// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #ifndef RYAI_AI_EVENT_ACTION_NODE_H #define RYAI_AI_EVENT_ACTION_NODE_H #include "nel/misc/types_nl.h" #include "nel/misc/entity_id.h" #include "nel/misc/smart_ptr.h" #include "nel/net/message.h" #include "ai_types.h" #include #include #include "ai_vector.h" class CTmpPropertyZone : public NLMISC::CRefCount { public: enum TTarget { All, Fauna, Npc }; CTmpPropertyZone() :verticalPos(AITYPES::vp_auto), Target(All) {} typedef NLMISC::CSmartPtr TSmartPtr; AITYPES::TVerticalPos verticalPos; std::vector points; AITYPES::CPropertySet properties; TTarget Target; }; class CAIEventActionNode : public NLMISC::CRefCount { public: typedef NLMISC::CSmartPtr TSmartPtr; std::string Action; std::vector Args; std::vector _PropertyZones; std::vector Children; uint32 Weight; uint32 Alias; void pushToPdr(CPersistentDataRecord& pdr) const { pdr.push(pdr.addString("type"),Action); if (Weight!=1) pdr.push(pdr.addString("weight"),Weight); if (Alias!=0) pdr.push(pdr.addString("alias"),Alias); for (uint32 i=0;ipushToPdr(pdr); pdr.pushStructEnd(pdr.addString("child")); } } static CAIEventActionNode* popFromPdr(CPersistentDataRecord& pdr) { CAIEventActionNode* result= new CAIEventActionNode; result->Weight= 1; result->Alias= 0; while (!pdr.isEndOfStruct()) { uint16 token= pdr.peekNextToken(); const std::string& tokenName= pdr.peekNextTokenName(); if (tokenName=="type") { result->Action= pdr.popNextArg(token).asString(); continue; } if (tokenName=="weight") { result->Weight= (uint32) pdr.popNextArg(token).asUint(); continue; } if (tokenName=="alias") { result->Alias= (uint32) pdr.popNextArg(token).asUint(); continue; } if (tokenName=="arg") { result->Args.push_back( pdr.popNextArg(token).asString() ); continue; } if (tokenName=="child") { pdr.popStructBegin(token); vectAppend(result->Children)= CAIEventActionNode::popFromPdr(pdr); pdr.popStructEnd(token); continue; } WARN("Unrecognised content found in pdr: "+tokenName); if (pdr.isStartOfStruct()) pdr.skipStruct(); else pdr.skipData(); } return result; } }; class CAIEventDescription : public NLMISC::CRefCount { public: typedef NLMISC::CSmartPtr TSmartPtr; std::string EventType; std::vector StateKeywords; std::vector NamedStates; std::vector GroupKeywords; std::vector NamedGroups; CAIEventActionNode::TSmartPtr Action; void pushToPdr(CPersistentDataRecord& pdr) const { pdr.push(pdr.addString("type"),EventType); for (uint32 i=0;ipushToPdr(pdr); pdr.pushStructEnd(pdr.addString("action")); } } static CAIEventDescription* popFromPdr(CPersistentDataRecord& pdr) { CAIEventDescription* result= new CAIEventDescription; while (!pdr.isEndOfStruct()) { uint16 token= pdr.peekNextToken(); const std::string& tokenName= pdr.peekNextTokenName(); if (tokenName=="type") { result->EventType= pdr.popNextArg(token).asString(); continue; } if (tokenName=="stateKeyword") { result->StateKeywords.push_back( pdr.popNextArg(token).asString() ); continue; } if (tokenName=="state") { result->NamedStates.push_back( pdr.popNextArg(token).asString() ); continue; } if (tokenName=="groupKeyword") { result->GroupKeywords.push_back( pdr.popNextArg(token).asString() ); continue; } if (tokenName=="group") { result->NamedGroups.push_back( pdr.popNextArg(token).asString() ); continue; } if (tokenName=="action") { pdr.popStructBegin(token); result->Action= CAIEventActionNode::popFromPdr(pdr); pdr.popStructEnd(token); continue; } WARN("Unrecognised content found in pdr: "+tokenName); if (pdr.isStartOfStruct()) pdr.skipStruct(); else pdr.skipData(); } return result; } }; #endif