Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / server / src / ai_service / event_reaction_include.h
blob3c44b03dc4eed8241d27248a265d38c80b3647ab
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef RYAI_EVENT_REACTION_INCLUDE_H
21 #define RYAI_EVENT_REACTION_INCLUDE_H
23 /*#include "ai_mgr.h"
24 #include "ai.h"
25 #include "event_reaction.h"
26 #include "ai_grp.h"
27 #include "ais_actions.h" // for CWorkPtr::instance()
28 #include "continent.h"*/
30 template <class TState>
31 bool CAIEventReaction::testCompatibility(CStateInstance *const stateInstance, const TState *const state) const
33 if (!stateInstance)
34 return false;
36 const uint32 grpAlias=stateInstance->aliasTreeOwner()->getAlias();
37 const uint32 stateAlias=state->getAlias();
39 // if group list is empty and filters are clear then accept all groups
40 bool grpOK=(_groups.empty() && _groupFilter.isEmpty());
42 // as long as group not flagged OK - test the list of named groups to see if we match
43 for (uint i=0;!grpOK && i<_groups.size();++i)
44 grpOK=(grpAlias==_groups[i]);
46 // if all else fails try the keyword test
47 if (!grpOK && !(!_groupFilter.isEmpty() && _groupFilter.test(stateInstance->getPersistentStateInstance()->getKeywords())))
48 return false;
50 // if state list is empty and filters are clear then accept all states
51 bool stateOK=(_states.empty() && _stateFilter.isEmpty());
53 // as long as state not flagged OK - test the list of named states to see if we match
54 for (uint j=0;!stateOK && j<_states.size();++j)
55 stateOK=(stateAlias==_states[j]);
57 // if all else fails try the keyword test
58 return (stateOK || (!_stateFilter.isEmpty() && _stateFilter.test(state->getKeywords())));
62 #endif