[2036] | 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 |
---|
[2190] | 15 | co-programmer: Christian Meyer |
---|
[2036] | 16 | */ |
---|
| 17 | |
---|
| 18 | #include <iostream> |
---|
| 19 | |
---|
| 20 | #include "world_entity.h" |
---|
[3608] | 21 | #include "objModel.h" |
---|
| 22 | #include "list.h" |
---|
| 23 | |
---|
| 24 | //#include "stdincl.h" |
---|
[3474] | 25 | //#include "collision.h" |
---|
[2036] | 26 | |
---|
| 27 | using namespace std; |
---|
| 28 | |
---|
[2043] | 29 | /** |
---|
[2190] | 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. |
---|
[2043] | 38 | */ |
---|
[2190] | 39 | WorldEntity::WorldEntity (bool isFree) : bFree(isFree) |
---|
| 40 | { |
---|
[3365] | 41 | this->setClassName ("WorldEntity"); |
---|
[2822] | 42 | this->bDraw = true; |
---|
[3564] | 43 | this->model = NULL; |
---|
[3474] | 44 | // collisioncluster = NULL; |
---|
[2190] | 45 | } |
---|
[2043] | 46 | |
---|
| 47 | /** |
---|
[3245] | 48 | \brief standard destructor |
---|
[2043] | 49 | */ |
---|
[2190] | 50 | WorldEntity::~WorldEntity () |
---|
[2036] | 51 | { |
---|
[3474] | 52 | // if( collisioncluster != NULL) delete collisioncluster; |
---|
[3658] | 53 | ResourceManager::unload(this->model); |
---|
[3531] | 54 | } |
---|
| 55 | |
---|
| 56 | /** |
---|
[3583] | 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 |
---|
[2043] | 61 | */ |
---|
[3583] | 62 | void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr) |
---|
| 63 | {} |
---|
[2036] | 64 | |
---|
[3583] | 65 | |
---|
[2043] | 66 | /** |
---|
[3583] | 67 | \brief gets the Character attributes of this worldentity |
---|
| 68 | \returns character attributes |
---|
[2043] | 69 | */ |
---|
[3583] | 70 | CharacterAttributes* WorldEntity::getCharacterAttributes() |
---|
| 71 | {} |
---|
| 72 | |
---|
| 73 | |
---|
[2043] | 74 | /** |
---|
[2822] | 75 | \brief query whether the WorldEntity in question is free |
---|
| 76 | \return true if the WorldEntity is free or false if it isn't |
---|
[2043] | 77 | */ |
---|
[2190] | 78 | bool WorldEntity::isFree () |
---|
[2036] | 79 | { |
---|
[2190] | 80 | return bFree; |
---|
[2036] | 81 | } |
---|
| 82 | |
---|
[2043] | 83 | /** |
---|
[2822] | 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 |
---|
[2043] | 88 | */ |
---|
[3474] | 89 | /* |
---|
[3229] | 90 | void WorldEntity::setCollision (CollisionCluster* newhull) |
---|
[2036] | 91 | { |
---|
[2822] | 92 | if( newhull == NULL) return; |
---|
| 93 | if( collisioncluster != NULL) delete collisioncluster; |
---|
| 94 | collisioncluster = newhull; |
---|
[2036] | 95 | } |
---|
[3474] | 96 | */ |
---|
[2036] | 97 | |
---|
| 98 | |
---|
[3365] | 99 | /** |
---|
| 100 | \brief process draw function |
---|
| 101 | */ |
---|
| 102 | void 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 | |
---|
[3449] | 113 | /** |
---|
| 114 | \brief sets the drawable state of this entity. |
---|
| 115 | \param bDraw TRUE if draweable, FALSE otherwise |
---|
| 116 | */ |
---|
[3365] | 117 | void WorldEntity::setDrawable (bool bDraw) |
---|
| 118 | { |
---|
| 119 | this->bDraw = bDraw; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | |
---|
[2043] | 123 | /** |
---|
[2822] | 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 |
---|
[2043] | 128 | |
---|
[2822] | 129 | Implement behaviour like damage application or other miscellaneous collision stuff in this function |
---|
[2043] | 130 | */ |
---|
[2190] | 131 | void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {} |
---|
[2036] | 132 | |
---|
[3583] | 133 | |
---|
[2043] | 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 |
---|
[2036] | 138 | |
---|
[2043] | 139 | calculate the damage depending |
---|
| 140 | */ |
---|
[3578] | 141 | void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {} |
---|
[2043] | 142 | |
---|
| 143 | |
---|
| 144 | /** |
---|
[2822] | 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. |
---|
[2043] | 149 | */ |
---|
[3229] | 150 | void WorldEntity::postSpawn () |
---|
[2190] | 151 | { |
---|
| 152 | } |
---|
[2043] | 153 | |
---|
[3583] | 154 | |
---|
[2043] | 155 | /** |
---|
[3583] | 156 | \brief this method is called by the world if the WorldEntity leaves valid gamespace |
---|
[2822] | 157 | |
---|
[3583] | 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). |
---|
[2190] | 160 | */ |
---|
[3583] | 161 | void WorldEntity::leftWorld () |
---|
[2190] | 162 | { |
---|
| 163 | } |
---|
[2043] | 164 | |
---|
[3583] | 165 | |
---|
[2190] | 166 | /** |
---|
[3583] | 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.) |
---|
[2043] | 171 | */ |
---|
[3649] | 172 | inline void WorldEntity::tick(float time) |
---|
[2190] | 173 | { |
---|
| 174 | } |
---|
[3583] | 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. |
---|
[3365] | 181 | */ |
---|
[3649] | 182 | inline void WorldEntity::draw() |
---|
[3583] | 183 | {} |
---|
[2043] | 184 | |
---|
[3583] | 185 | |
---|
[2043] | 186 | /** |
---|
[3583] | 187 | \brief this handles incoming command messages |
---|
| 188 | \param cmd: a pointer to the incoming Command structure |
---|
[2822] | 189 | |
---|
[3583] | 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. |
---|
[2043] | 192 | */ |
---|
[3583] | 193 | void WorldEntity::command (Command* cmd) |
---|
[2190] | 194 | { |
---|
| 195 | } |
---|