// 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_STATE_H #define RYAI_STATE_H #include "state_profil.h" #include "state_chat.h" #include "keyword_owner.h" #include "event_reaction.h" #include "profile_in_state.h" #include "ai_share/ai_vector.h" #include "ai_place_xyr.h" class CStateMachine; class CAIState : public NLMISC::CDbgRefCount, public CKeyWordOwner, public CAliasChild, public NLMISC::CRefCount, public CProfileInState { public: // ctor & dtor ------------------------------------------------------ CAIState(const CStateMachine *container,CAIAliasDescriptionNode *aliasTree) : CKeyWordOwner(), CAliasChild(const_cast(container),aliasTree) {} CAIState(CStateMachine const* container, uint32 alias, std::string const& name) : CKeyWordOwner() , CAliasChild(const_cast(container), alias, name) {} virtual ~CAIState() {} std::string getIndexString () const; virtual bool isPositional () const =0; // Profile property accessors -------------------------------------- const CAliasCont& profiles() const { return _Profiles; } const CAliasCont& chats() const { return _Chats; } IAliasCont* getAliasCont (AITYPES::TAIType type); CAliasTreeOwner* createChild (IAliasCont *cont, CAIAliasDescriptionNode *aliasTree); void updateDependencies (const CAIAliasDescriptionNode &aliasTree, CAliasTreeOwner *aliasTreeOwner); protected: CAliasCont _Profiles; CAliasCont _Chats; }; class CAIStatePunctual: public CAIState { public: virtual bool isPositional () const { return false; } CAIStatePunctual(const CStateMachine *container,CAIAliasDescriptionNode *aliasTree) : CAIState(container,aliasTree) {} private: }; class CShape :public CPlaceRandomPos { public: CShape(bool acceptInvalidPos=false) : _GeometryType(NONE) , _AcceptInvalidPos(acceptInvalidPos) {} virtual ~CShape() {} typedef RYAI_MAP_CRUNCH::CWorldPosition TPosition; // methods for managing geometry bool setPath(AITYPES::TVerticalPos verticalPos, const std::vector &points); bool setPatat(AITYPES::TVerticalPos verticalPos, const std::vector &points); // dumb little geometry type reporting accessors bool hasPath () const { return _GeometryType==PATH && hasPoints(); } bool hasPatat () const { return _GeometryType==PATAT && hasPoints(); } bool hasPoints () const { return _Geometry.size()!=0; } // accessors for path & patat geometry - whichever of the 2 exists uint32 numPoints() { return _Geometry.size(); } const TPosition *point(uint32 idx) { return idx<_Geometry.size()? &_Geometry[idx]: NULL; } const std::vector &getGeometry() const { return _Geometry; } bool contains (const CAIVector &pos) const; bool calcRandomPos(CAIPos &pos) const; protected: private: enum { NONE, PATH, PATAT } _GeometryType; std::vector _Geometry; /// bouding box info CAIVector _VMin, _VMax; bool _AcceptInvalidPos; }; class CAIStatePositional :public NLMISC::CDbgRefCount ,public NLMISC::CDbgRefCount ,public CAIState { public: CAIStatePositional (const CStateMachine *container,CAIAliasDescriptionNode *aliasTree) : CAIState(container,aliasTree) { } CAIStatePositional(CStateMachine const* container, uint32 alias, std::string const& name) : CAIState(container, alias, name) { } virtual bool isPositional () const { return true; } const std::vector &getGeometry() const { return _Shape.getGeometry(); } bool contains (const CAIVector &pos) const { return _Shape.contains(pos); } CShape &shape() { return _Shape; } const CShape &shape() const { return _Shape; } private: CShape _Shape; }; #endif