Pyrogenesis
13997
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
source
simulation2
system
IComponent.h
Go to the documentation of this file.
1
/* Copyright (C) 2010 Wildfire Games.
2
* This file is part of 0 A.D.
3
*
4
* 0 A.D. is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 2 of the License, or
7
* (at your option) any later version.
8
*
9
* 0 A.D. is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef INCLUDED_ICOMPONENT
19
#define INCLUDED_ICOMPONENT
20
21
#include "
Components.h
"
22
#include "
Message.h
"
23
#include "
Entity.h
"
24
#include "
SimContext.h
"
25
26
#include "
scriptinterface/ScriptTypes.h
"
27
28
class
CParamNode
;
29
class
CMessage
;
30
class
ISerializer
;
31
class
IDeserializer
;
32
33
class
IComponent
34
{
35
public
:
36
virtual
~IComponent
();
37
38
static
std::string
GetSchema
();
39
40
virtual
void
Init
(
const
CParamNode
& paramNode) = 0;
41
virtual
void
Deinit
() = 0;
42
43
virtual
void
HandleMessage
(
const
CMessage
& msg,
bool
global);
44
45
CEntityHandle
GetEntityHandle
()
const
{
return
m_EntityHandle
; }
46
void
SetEntityHandle
(
CEntityHandle
ent) {
m_EntityHandle
= ent; }
47
48
entity_id_t
GetEntityId
()
const
{
return
m_EntityHandle
.
GetId
(); }
49
50
CEntityHandle
GetSystemEntity
()
const
{
return
m_SimContext
->
GetSystemEntity
(); }
51
52
const
CSimContext
&
GetSimContext
()
const
{
return
*
m_SimContext
; }
53
void
SetSimContext
(
const
CSimContext
& context) {
m_SimContext
= &context; }
54
55
static
u8
GetSerializationVersion
() {
return
0; }
56
virtual
void
Serialize
(
ISerializer
& serialize) = 0;
57
virtual
void
Deserialize
(
const
CParamNode
& paramNode,
IDeserializer
& deserialize) = 0;
58
59
virtual
JSClass*
GetJSClass
()
const
;
60
virtual
jsval
GetJSInstance
()
const
;
61
62
private
:
63
CEntityHandle
m_EntityHandle
;
64
const
CSimContext
*
m_SimContext
;
65
};
66
67
#endif // INCLUDED_ICOMPONENT
CParamNode
An entity initialisation parameter node.
Definition:
ParamNode.h:112
ScriptTypes.h
IComponent
Definition:
IComponent.h:33
u8
#define u8
Definition:
types.h:39
IComponent::m_SimContext
const CSimContext * m_SimContext
Definition:
IComponent.h:64
Entity.h
IComponent::GetJSInstance
virtual jsval GetJSInstance() const
Definition:
IComponent.cpp:41
Message.h
IComponent::Serialize
virtual void Serialize(ISerializer &serialize)=0
ISerializer
Serialization interface; see serialization overview.
Definition:
ISerializer.h:120
IComponent::Init
virtual void Init(const CParamNode ¶mNode)=0
CEntityHandle
Object wrapping an entity_id_t, with a SEntityComponentCache to support fast QueryInterface() / CmpPt...
Definition:
Entity.h:80
Components.h
CSimContext::GetSystemEntity
CEntityHandle GetSystemEntity() const
Definition:
SimContext.h:49
CSimContext
Contains pointers to various 'global' objects that are needed by the simulation code, to allow easy access without using real (evil) global variables.
Definition:
SimContext.h:32
IComponent::GetEntityHandle
CEntityHandle GetEntityHandle() const
Definition:
IComponent.h:45
SimContext.h
IComponent::GetEntityId
entity_id_t GetEntityId() const
Definition:
IComponent.h:48
IComponent::GetJSClass
virtual JSClass * GetJSClass() const
Definition:
IComponent.cpp:36
IComponent::GetSerializationVersion
static u8 GetSerializationVersion()
Definition:
IComponent.h:55
CEntityHandle::GetId
entity_id_t GetId() const
Definition:
Entity.h:89
IComponent::GetSimContext
const CSimContext & GetSimContext() const
Definition:
IComponent.h:52
IComponent::SetEntityHandle
void SetEntityHandle(CEntityHandle ent)
Definition:
IComponent.h:46
IComponent::~IComponent
virtual ~IComponent()
Definition:
IComponent.cpp:22
IComponent::GetSystemEntity
CEntityHandle GetSystemEntity() const
Definition:
IComponent.h:50
IComponent::Deserialize
virtual void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize)=0
IComponent::HandleMessage
virtual void HandleMessage(const CMessage &msg, bool global)
Definition:
IComponent.cpp:32
IComponent::Deinit
virtual void Deinit()=0
IComponent::GetSchema
static std::string GetSchema()
Definition:
IComponent.cpp:26
entity_id_t
u32 entity_id_t
Entity ID type.
Definition:
Entity.h:24
IComponent::SetSimContext
void SetSimContext(const CSimContext &context)
Definition:
IComponent.h:53
IComponent::m_EntityHandle
CEntityHandle m_EntityHandle
Definition:
IComponent.h:63
IDeserializer
Deserialization interface; see serialization overview.
Definition:
IDeserializer.h:34
CMessage
Definition:
Message.h:24
Generated on Mon Oct 14 2013 00:58:09 for Pyrogenesis by
1.8.5