2013-07-26 21:43:15 +02:00
|
|
|
/*
|
|
|
|
|
Copyright (C) 2013 Erik Ogenvik
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 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 General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef EXTERNALMINDSMANAGER_H_
|
|
|
|
|
#define EXTERNALMINDSMANAGER_H_
|
|
|
|
|
|
|
|
|
|
#include "ExternalMindsConnection.h"
|
|
|
|
|
|
2013-08-09 16:25:04 +02:00
|
|
|
#include <sigc++/trackable.h>
|
|
|
|
|
|
2013-08-08 00:50:29 +02:00
|
|
|
#include <map>
|
2013-08-09 16:25:04 +02:00
|
|
|
#include <unordered_set>
|
2013-07-26 21:43:15 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
2013-08-09 16:25:04 +02:00
|
|
|
class Character;
|
2013-07-26 21:43:15 +02:00
|
|
|
|
2013-08-09 16:25:04 +02:00
|
|
|
class ExternalMindsManager : public virtual sigc::trackable
|
2013-07-26 21:43:15 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2013-08-08 00:17:36 +02:00
|
|
|
explicit ExternalMindsManager();
|
|
|
|
|
~ExternalMindsManager();
|
2013-07-26 21:43:15 +02:00
|
|
|
|
|
|
|
|
static ExternalMindsManager * instance();
|
|
|
|
|
|
2013-08-08 00:50:29 +02:00
|
|
|
int addConnection(const ExternalMindsConnection& connection);
|
|
|
|
|
int removeConnection(const std::string& routerId);
|
2013-07-26 21:43:15 +02:00
|
|
|
|
2013-08-12 17:55:55 +02:00
|
|
|
/**
|
|
|
|
|
* Requests a possession for the supplied character.
|
|
|
|
|
*
|
|
|
|
|
* This means that we want an external AI process to take possession of the character and control its mind.
|
|
|
|
|
* The manager is responsible for finding a suitable external mind connection to ask for possession.
|
|
|
|
|
*
|
|
|
|
|
* The preferred language and script to use can be specified, but these might not be honoured, depending on
|
|
|
|
|
* the external minds client registered.
|
|
|
|
|
*
|
|
|
|
|
* @param character The character which should be possessed.
|
|
|
|
|
* @param language The preferred language to use for the mind.
|
|
|
|
|
* @param script The preferred script to use for the mind.
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
int requestPossession(Character& character, const std::string& language, const std::string& script);
|
2013-07-26 21:43:15 +02:00
|
|
|
|
|
|
|
|
private:
|
2013-08-08 00:50:29 +02:00
|
|
|
std::map<std::string, ExternalMindsConnection> m_connections;
|
2013-08-09 16:25:04 +02:00
|
|
|
std::unordered_set<Character*> m_unpossessedEntities;
|
|
|
|
|
std::unordered_set<Character*> m_possessedEntities;
|
2013-07-26 21:43:15 +02:00
|
|
|
static ExternalMindsManager * m_instance;
|
|
|
|
|
|
2013-08-09 16:25:04 +02:00
|
|
|
void entity_destroyed(Character* character);
|
|
|
|
|
void character_externalLinkChanged(Character* character);
|
|
|
|
|
|
|
|
|
|
int requestPossessionFromRegisteredClients(const std::string& character_id);
|
|
|
|
|
|
2013-08-11 23:27:13 +02:00
|
|
|
void addPossessionEntryForCharacter(Character& character);
|
|
|
|
|
|
2013-07-26 21:43:15 +02:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* EXTERNALMINDSMANAGER_H_ */
|