Planeshift

actionmanager.h

Go to the documentation of this file.
00001 /*
00002 * actionmanager.h
00003 *
00004 * Copyright (C) 2005 Atomic Blue ([email protected], http://www.atomicblue.org)
00005 *
00006 * Credits :
00007 *                  Michael Cummings <[email protected]>
00008 *
00009 * This program is free software; you can redistribute it and/or
00010 * modify it under the terms of the GNU General Public License
00011 * as published by the Free Software Foundation (version 2
00012 * of the License).
00013 * This program is distributed in the hope that it will be useful,
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016 * GNU General Public License for more details.
00017 * You should have received a copy of the GNU General Public License
00018 * along with this program; if not, write to the Free Software
00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 *
00021 * Creation Date: 1/20/2005
00022 * Description : server manager for clickable map object actions
00023 *
00024 */
00025 #ifndef __ACTIONMANAGER_H__
00026 #define __ACTIONMANAGER_H__
00027 
00028 //=============================================================================
00029 // Crystal Space Includes
00030 //=============================================================================
00031 #include <csutil/ref.h>
00032 
00033 //=============================================================================
00034 // Project Includes
00035 //=============================================================================
00036 #include "util/gameevent.h"
00037 
00038 //=============================================================================
00039 // Local Includes
00040 //=============================================================================
00041 #include "msgmanager.h"             // Parent class
00042 #include "scripting.h"
00043 
00044 
00045 class psDatabase;
00046 class SpawnManager;
00047 class psServer;
00048 class psDatabase;
00049 class ClientConnectionSet;
00050 class psActionLocation;
00051 class ActionManager;
00052 class psSectorInfo;
00053 class Client;
00054 class gemActionLocation;
00055 class gemActor;
00056 
00064 class psActionTimeoutGameEvent : public psGameEvent
00065 {
00066 public:
00074     psActionTimeoutGameEvent(ActionManager* mgr, const psActionLocation* actionLocation, EID actorEID);
00075 
00079     ~psActionTimeoutGameEvent();
00080 
00084     virtual void Trigger();
00085     virtual bool IsValid()
00086     {
00087         return valid;
00088     }
00089 
00090 protected:
00091     ActionManager*           actionManager;  
00092     bool                     valid;          
00093 
00094     EID                      actorEID;       
00095     const  psActionLocation* actionLocation; 
00096 };
00097 
00098 
00099 //----------------------------------------------------------------------------
00100 
00107 class ActionManager : public MessageManager<ActionManager>
00108 {
00109 public:
00110 
00114     ActionManager(psDatabase* db);
00115 
00119     virtual ~ActionManager();
00120 
00126     bool RepopulateActionLocations(psSectorInfo* sectorinfo = 0);
00127 
00133     bool CacheActionLocation(psActionLocation* action);
00134 
00141     void HandleMapAction(MsgEntry* msg, Client* client);
00142 
00147     bool HandleUse(gemActionLocation* actionlocation, Client* client);
00148 
00155     void RemoveActiveTrigger(EID actorEID, const psActionLocation* actionLocation);
00156 
00163     bool HasActiveTrigger(EID actorEID, const psActionLocation* actionLocation);
00164 
00171     void AddActiveTrigger(EID actorEID, const psActionLocation* actionLocation);
00172 
00178     psActionLocation* FindAction(EID id);
00179 
00185     psActionLocation* FindActionByID(uint32 id);
00186 
00192     psActionLocation* FindAvailableEntrances(csString entranceSector);
00193 
00197     void NotifyProximity(gemActor* actor, gemActionLocation* actionLocationObject, float range);
00198 
00199 protected:
00200 
00201     // Message Handlers
00202 
00209     void HandleQueryMessage(csString xml, Client* client);
00210 
00211     void LoadXML(iDocumentNode* topNode);
00212     bool HandleSelectQuery(iDocumentNode* topNode, Client* client);
00213     bool ProcessMatches(csArray<psActionLocation*> matches, Client* client);
00214 
00221     void HandleSaveMessage(csString xml, Client* client);
00222 
00229     void HandleListMessage(csString xml, Client* client);
00230 
00237     void HandleDeleteMessage(csString xml, Client* client);
00238 
00244     void HandleReloadMessage(Client* client);
00245 
00246     // Operation Handlers
00247 
00254     void HandleExamineOperation(psActionLocation* action, Client* client);
00255 
00262     void HandleScriptOperation(psActionLocation* action, gemActor* actor);
00263 
00264     // Current action location data
00265     csString triggerType;
00266     csString sectorName;
00267     csString meshName;
00268     csVector3 position;
00269 
00270 
00271     psDatabase*              database;
00272     csHash<psActionLocation*> actionLocationList;
00273     csHash<psActionLocation*> actionLocation_by_name;
00274     csHash<psActionLocation*> actionLocation_by_sector;
00275     csHash<psActionLocation*, uint32> actionLocation_by_id;
00276     csHash<const psActionLocation*> activeTriggers;
00277 
00278 };
00279 
00280 #endif