Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/world_entity.cc @ 3672

Last change on this file since 3672 was 3672, checked in by bensch, 19 years ago

orxonox/trunk: ResourceManager not totally static anymore, list-iterators, and so on

File size: 5.5 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program 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, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer: Christian Meyer
16*/
17
18#include <iostream>
19
20#include "world_entity.h"
21#include "objModel.h"
22#include "list.h"
23
24//#include "stdincl.h"
25//#include "collision.h"
26
27using namespace std;
28
29/**
30   \brief standard constructor
31   
32   Every derived contructor HAS to call the previous one supplying the isFree parameter. This is necessary to distunguish
33   between free and bound entities. The difference between them is simply the fact that the movement of a free entity is
34   not bound to the track of a world. Use this to implement projectile or effect classes that do not have to travel along the track.
35   To specify an entity to be free or bound set the default parameter in the declaration of the constructor.
36   Theoretically you should never have to call the constructor of an Entity directly, for it is called by the spawn() function of the World
37   class. So if you want to create a new entity at any time, call World::spawn(). It will handle everything that is necessary.
38*/
39WorldEntity::WorldEntity (bool isFree) : bFree(isFree)
40{
41  this->setClassName ("WorldEntity");
42  this->bDraw = true;
43  this->model = NULL;
44  //  collisioncluster = NULL;
45}
46
47/**
48   \brief standard destructor
49*/
50WorldEntity::~WorldEntity ()
51{
52  // if( collisioncluster != NULL) delete collisioncluster;
53  if (this->model)
54    ResourceManager::getInstance()->unload(this->model);
55}
56
57/**
58   \brief sets the character attributes of a worldentity
59   \param character attributes
60
61   these attributes don't have to be set, only use them, if you need them
62*/
63void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
64{}
65
66
67/**
68   \brief gets the Character attributes of this worldentity
69   \returns character attributes
70*/
71CharacterAttributes* WorldEntity::getCharacterAttributes()
72{}
73
74
75/**
76   \brief query whether the WorldEntity in question is free
77   \return true if the WorldEntity is free or false if it isn't
78*/
79bool WorldEntity::isFree ()
80{
81  return bFree;
82}
83
84/**
85   \brief set the WorldEntity's collision hull
86   \param newhull: a pointer to a completely assembled CollisionCluster
87   
88   Any previously assigned collision hull will be deleted on reassignment
89*/
90/*
91void WorldEntity::setCollision (CollisionCluster* newhull)
92{
93  if( newhull == NULL) return;
94  if( collisioncluster != NULL) delete collisioncluster;
95  collisioncluster = newhull;
96}
97*/
98
99
100/**
101    \brief process draw function
102*/
103void WorldEntity::processDraw ()
104{
105  this->draw ();
106  PNode* pn = this->children->enumerate ();
107  while( pn != NULL) 
108    { 
109      ((WorldEntity*)pn)->processDraw ();
110      pn = this->children->nextElement();
111    } 
112}
113
114/**
115   \brief sets the drawable state of this entity.
116   \param bDraw TRUE if draweable, FALSE otherwise
117*/
118void WorldEntity::setDrawable (bool bDraw)
119{
120  this->bDraw = bDraw;
121}
122
123
124/**
125   \brief this function is called, when two entities collide
126   \param other: the world entity with whom it collides
127   \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
128   \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
129
130   Implement behaviour like damage application or other miscellaneous collision stuff in this function
131*/
132void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
133
134
135/**
136   \brief this function is called, when the ship is hit by a waepon
137   \param weapon: the laser/rocket/shoot that hits.
138   \param loc: place where it is hit
139
140   calculate the damage depending
141*/
142void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
143
144
145/**
146   \brief this is called immediately after the Entity has been constructed and initialized
147   
148   Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
149   DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
150*/
151void WorldEntity::postSpawn ()
152{
153}
154
155
156/**
157   \brief this method is called by the world if the WorldEntity leaves valid gamespace
158   
159   For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
160   place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
161*/
162void WorldEntity::leftWorld ()
163{
164}
165
166
167/**
168   \brief this method is called every frame
169   \param time: the time in seconds that has passed since the last tick
170   
171   Handle all stuff that should update with time inside this method (movement, animation, etc.)
172*/
173inline void WorldEntity::tick(float time) 
174{
175}
176
177
178/**
179   \brief the entity is drawn onto the screen with this function
180   
181   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
182*/
183inline void WorldEntity::draw() 
184{}
185
186
187/**
188   \brief this handles incoming command messages
189   \param cmd: a pointer to the incoming Command structure
190   
191   Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
192   to send commands from one WorldEntity to another.
193*/
194void WorldEntity::command (Command* cmd)
195{
196}
Note: See TracBrowser for help on using the repository browser.