Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tactics3DEvent.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2012 Dylan Blair
3 //
4 // email: dblair@alumni.cs.utexas.edu
5 //
6 // This file is part of Tactics3D.
7 //
8 // Tactics3D is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Tactics3D is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 #ifndef TACTICS3DEVENT_H
24 #define TACTICS3DEVENT_H
25 
26 #include "../Libs/Utils_LIB/UTypes.h"
27 
28 #include <vector>
29 #include <list>
30 
31 namespace Tactics3D {
32  class Event {
33  struct FunctionOrMethod {
34  void (*_func)(void*,std::vector<OpenSkyNet::Utils::TaggedUnion>);
35  void* _instance;
36  FunctionOrMethod(void (*func_)(void*,std::vector<OpenSkyNet::Utils::TaggedUnion>), void* instance_=0) : _func(func_), _instance(instance_) {}
37  inline bool operator==(const FunctionOrMethod& rhs_) const {
38  if ((_func != rhs_._func) || (_instance != rhs_._instance))
39  return false;
40  return true;
41  }
42  };
43  std::list<FunctionOrMethod> _handlers;
44  public:
45  inline void fire(std::vector<OpenSkyNet::Utils::TaggedUnion> params_) {
46  for (std::list<FunctionOrMethod>::iterator i = _handlers.begin(); i != _handlers.end(); i++)
47  i->_func(i->_instance,params_);
48  }
49 
50  inline void registerHandler(void (*func_)(void*,std::vector<OpenSkyNet::Utils::TaggedUnion>), void* instance_=0) {
51  _handlers.push_back(FunctionOrMethod(func_,instance_));
52  }
53 
54  inline void unregisterHandler(void (*func_)(void*,std::vector<OpenSkyNet::Utils::TaggedUnion>), void* instance_=0) {
55  _handlers.remove(FunctionOrMethod(func_,instance_));
56  }
57 
58  inline void unregisterAllHandlers() {
59  _handlers.clear();
60  }
61  };
62 
63  extern const std::vector<OpenSkyNet::Utils::TaggedUnion> g_emptyEventParams;
64 
67  extern Event g_currCamJustBecameFree;
68  extern Event g_beginRound;
69  extern Event g_initiativeRolled;
70  extern Event g_allInitiativesRolled;
71  extern Event g_preGetWarriorActions;
72  extern Event g_getWarriorActions;
73  extern Event g_postGetWarriorActions;
74  extern Event g_postGetAllWarriorsActions;
75  extern Event g_preWarriorPerform;
76  extern Event g_postWarriorPerform;
77  extern Event g_postWarriorPerformAll;
78  extern Event g_warriorAttacked;
79  extern Event g_warriorDead;
81 
84  extern Event g_recvPCAttributes;
86 
89  extern Event g_lockCore;
90  extern Event g_unlockCore;
92 }
93 
94 #endif //TACTICS3DEVENT_H
Event g_preGetWarriorActions
Definition: Tactics3DEvent.cpp:10
const std::vector< OpenSkyNet::Utils::TaggedUnion > g_emptyEventParams
Definition: Tactics3DEvent.cpp:4
Event g_initiativeRolled
Definition: Tactics3DEvent.cpp:8
void unregisterHandler(void(*func_)(void *, std::vector< OpenSkyNet::Utils::TaggedUnion >), void *instance_=0)
Definition: Tactics3DEvent.h:54
void fire(std::vector< OpenSkyNet::Utils::TaggedUnion > params_)
Definition: Tactics3DEvent.h:45
Event g_postWarriorPerform
Definition: Tactics3DEvent.cpp:15
Event g_recvPCAttributes
Definition: Tactics3DEvent.cpp:19
Event g_getWarriorActions
Definition: Tactics3DEvent.cpp:11
Event g_lockCore
Definition: Tactics3DEvent.cpp:20
Event g_postGetWarriorActions
Definition: Tactics3DEvent.cpp:12
Event g_warriorAttacked
Definition: Tactics3DEvent.cpp:17
void registerHandler(void(*func_)(void *, std::vector< OpenSkyNet::Utils::TaggedUnion >), void *instance_=0)
Definition: Tactics3DEvent.h:50
bool operator==(const Point< T > &lhs_, const Point< U > &rhs_)
Definition: MPoint.h:221
Event g_postWarriorPerformAll
Definition: Tactics3DEvent.cpp:16
Event g_postGetAllWarriorsActions
Definition: Tactics3DEvent.cpp:13
Event g_currCamJustBecameFree
Definition: Tactics3DEvent.cpp:6
Event g_allInitiativesRolled
Definition: Tactics3DEvent.cpp:9
Event g_unlockCore
Definition: Tactics3DEvent.cpp:21
Event g_preWarriorPerform
Definition: Tactics3DEvent.cpp:14
void unregisterAllHandlers()
Definition: Tactics3DEvent.h:58
Event g_warriorDead
Definition: Tactics3DEvent.cpp:18
Event g_beginRound
Definition: Tactics3DEvent.cpp:7
typedef void(__attribute__((stdcall))*ObjectPickedCallback)(const char *name_
Definition: Tactics3DEvent.h:32