Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3583 was 3583, checked in by patrick, 19 years ago

orxonox/trunk: some changes in the character_attributes, projectile and weapon.

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