1 /*
2 Copyright (C) 2007, 2012 - Bit-Blot
3 
4 This file is part of Aquaria.
5 
6 Aquaria is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 
15 See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21 #ifndef SCRIPTOBJECT_H
22 #define SCRIPTOBJECT_H
23 
24 enum ScriptObjectType
25 {
26 	SCO_NONE              = 0x0000,
27 
28 	// If you change this enum, do not forget to adjust the string array in the cpp,
29 	// and to add additional compile time assertions to ScriptInterface.cpp as necessary!
30 	SCO_RENDEROBJECT      = 0x0001,
31 	SCO_ENTITY            = 0x0002,
32 	SCO_INGREDIENT        = 0x0004,
33 	SCO_COLLIDE_ENTITY    = 0x0008,
34 	SCO_SCRIPTED_ENTITY   = 0x0010,
35 	SCO_BEAM              = 0x0020,
36 	SCO_SHOT              = 0x0040,
37 	SCO_WEB               = 0x0080,
38 	SCO_BONE              = 0x0100,
39 	SCO_PATH              = 0x0200,
40 	SCO_QUAD              = 0x0400,
41 	SCO_TEXT              = 0x0800,
42 	SCO_PAUSEQUAD         = 0x1000,
43 	SCO_SHADER            = 0x2000,
44 	SCO_PARTICLE_EFFECT   = 0x4000,
45 
46 	SCO_FORCE_32BIT = 0xFFFFFFFF
47 };
48 
49 
50 class ScriptObject
51 {
52 public:
53 
ScriptObject()54 	ScriptObject()
55 		: _objtype(SCO_NONE)
56 	{
57 	}
58 
~ScriptObject()59 	virtual ~ScriptObject() {}
60 
addType(ScriptObjectType ty)61 	inline void addType(ScriptObjectType ty)
62 	{
63 		_objtype  = ScriptObjectType(int(ty) | int(_objtype)); // prevent the compiler from crying
64 	}
65 
isType(ScriptObjectType bt)66 	inline bool isType(ScriptObjectType bt) const
67 	{
68 		return (_objtype & bt) == bt;
69 	}
70 
isExactType(ScriptObjectType bt)71 	inline bool isExactType(ScriptObjectType bt) const
72 	{
73 		return _objtype  == bt;
74 	}
75 
getTypeString()76 	inline std::string getTypeString() const
77 	{
78 		return getTypeString(_objtype);
79 	}
80 
81 	static std::string getTypeString(unsigned int ty);
82 
83 	// public to allow the static compile check in ScriptInterface.cpp to work
84 	ScriptObjectType _objtype;
85 };
86 
87 #endif
88