JNR
laTypedObject.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
30 
31 
44 
45 /*
46 rpgSheet_Fighter
47 rpgPotion
48 rpgTrap
49 
50 TODO: Use the abstract factory; only base types manually
51 But not so important;
52 
53 
54 */
55 
56 //Recognized types
57 #define M_TYPE_INVALID 0
58 #define M_TYPE_COMMENT 1
59 #define M_TYPE_BOOL 2
60 #define M_TYPE_INT 3
61 #define M_TYPE_DOUBLE 4
62 #define M_TYPE_POINT3 5
63 #define M_TYPE_COLOR 6
64 //#define M_TYPE_TRAP 7 // NOTE: not used anymore
65 #define M_TYPE_TEXT 8
66 
67 #define M_TYPE_MODEL 9
68 #define M_TYPE_FX 10
69 #define M_TYPE_ATTACK 11
70 #define M_TYPE_PLIST 12
71 #define M_TYPE_INCLUDE 13
72 
73 
74 class laTypedObject: public laLoadableObj
75 {
76 protected:
77  char _strType[64];
78  unsigned _nType; // type ID
79  void* _pdata; // data ptr
80 
81  void _type(char* strType);
82 
83 public:
84 
85  // Constructors
86  //
87  laTypedObject() { _strType[0]='\0'; _nType = M_TYPE_INVALID; _pdata=NULL; } // let load() determine the type
88  laTypedObject(char* strType) { strcpy(_strType, strType); _type(strType); _pdata=NULL; } // specify type explicitly
89  //virtual ~laTypedObject();
90 
91  // Load from file
92  virtual void load(class laFileParser *fp);
93 
94  // Free memory
95  virtual void discard();
96 
97  // Get type
98  unsigned type() { return _nType; }
99 
100  // Get a pointer of a specified type
101  //
102  // If the internal type and requested type are incompatible
103  // these functions throw an exception
104  //
105  M_BOOL *getBool();
106  int *getInt();
107  double *getDouble();
108 
109  laPoint3* getPoint();
110  laColor* getColor();
111  //rpgTrap* trap();
112 
113  char* getText();
114  class laAnimatedModel* getModel();
115  class fxParticleSystem* getFx();
116  class rpgAttack* attack();
117  class laPropertyList* getPList();
118 };
Animated 3D Model.
Interface for loadable objects.
Definition: laLoadableObj.h:43
Attack RPG Properties.
Definition: rpgAttack.h:55
File Parser.
Definition: laFileParser.h:41