Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: resource manager working, player uses it.

File size: 5.4 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  ResourceManager::unload(this->model);
54}
55
56/**
57   \brief sets the character attributes of a worldentity
58   \param character attributes
59
60   these attributes don't have to be set, only use them, if you need them
61*/
62void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
63{}
64
65
66/**
67   \brief gets the Character attributes of this worldentity
68   \returns character attributes
69*/
70CharacterAttributes* WorldEntity::getCharacterAttributes()
71{}
72
73
74/**
75   \brief query whether the WorldEntity in question is free
76   \return true if the WorldEntity is free or false if it isn't
77*/
78bool WorldEntity::isFree ()
79{
80  return bFree;
81}
82
83/**
84   \brief set the WorldEntity's collision hull
85   \param newhull: a pointer to a completely assembled CollisionCluster
86   
87   Any previously assigned collision hull will be deleted on reassignment
88*/
89/*
90void WorldEntity::setCollision (CollisionCluster* newhull)
91{
92  if( newhull == NULL) return;
93  if( collisioncluster != NULL) delete collisioncluster;
94  collisioncluster = newhull;
95}
96*/
97
98
99/**
100    \brief process draw function
101*/
102void WorldEntity::processDraw ()
103{
104  this->draw ();
105  PNode* pn = this->children->enumerate ();
106  while( pn != NULL) 
107    { 
108      ((WorldEntity*)pn)->processDraw ();
109      pn = this->children->nextElement();
110    } 
111}
112
113/**
114   \brief sets the drawable state of this entity.
115   \param bDraw TRUE if draweable, FALSE otherwise
116*/
117void WorldEntity::setDrawable (bool bDraw)
118{
119  this->bDraw = bDraw;
120}
121
122
123/**
124   \brief this function is called, when two entities collide
125   \param other: the world entity with whom it collides
126   \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
127   \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
128
129   Implement behaviour like damage application or other miscellaneous collision stuff in this function
130*/
131void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
132
133
134/**
135   \brief this function is called, when the ship is hit by a waepon
136   \param weapon: the laser/rocket/shoot that hits.
137   \param loc: place where it is hit
138
139   calculate the damage depending
140*/
141void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
142
143
144/**
145   \brief this is called immediately after the Entity has been constructed and initialized
146   
147   Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
148   DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
149*/
150void WorldEntity::postSpawn ()
151{
152}
153
154
155/**
156   \brief this method is called by the world if the WorldEntity leaves valid gamespace
157   
158   For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
159   place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
160*/
161void WorldEntity::leftWorld ()
162{
163}
164
165
166/**
167   \brief this method is called every frame
168   \param time: the time in seconds that has passed since the last tick
169   
170   Handle all stuff that should update with time inside this method (movement, animation, etc.)
171*/
172inline void WorldEntity::tick(float time) 
173{
174}
175
176
177/**
178   \brief the entity is drawn onto the screen with this function
179   
180   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.
181*/
182inline void WorldEntity::draw() 
183{}
184
185
186/**
187   \brief this handles incoming command messages
188   \param cmd: a pointer to the incoming Command structure
189   
190   Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
191   to send commands from one WorldEntity to another.
192*/
193void WorldEntity::command (Command* cmd)
194{
195}
Note: See TracBrowser for help on using the repository browser.