Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entity.cc @ 2624

Last change on this file since 2624 was 2190, checked in by bensch, 20 years ago

orxonox/trunk: merged and copied all files from branches/chris into trunk. it all seems to be in propper order.

File size: 5.5 KB
RevLine 
[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"
[2190]21#include "stdincl.h"
22#include "collision.h"
[2036]23
24using namespace std;
25
[2043]26/**
[2190]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.
[2043]35*/
[2190]36WorldEntity::WorldEntity (bool isFree) : bFree(isFree)
37{
38        collisioncluster = NULL;
39        owner = NULL;
40}
[2043]41
42/**
[2190]43        \brief standard destructor
[2043]44*/
[2190]45WorldEntity::~WorldEntity ()
[2036]46{
[2190]47        if( collisioncluster != NULL) delete collisioncluster;
[2036]48}
49
[2043]50/**
[2190]51        \brief get the Location of the WorldEntity
52        \return a pointer to location
[2043]53*/
[2190]54Location* WorldEntity::get_location ()
55{
56        return &loc;
57}
[2036]58
[2043]59/**
[2190]60        \brief get the Placement of the WorldEntity
61        \return a pointer to placement
[2043]62*/
[2190]63Placement* WorldEntity::get_placement ()
[2036]64{
[2190]65        return &place;
[2036]66}
67
[2043]68/**
[2190]69        \brief query whether the WorldEntity in question is free
70        \return true if the WorldEntity is free or false if it isn't
[2043]71*/
[2190]72bool WorldEntity::isFree ()
[2036]73{
[2190]74  return bFree;
[2036]75}
76
[2043]77/**
[2190]78        \brief set the WorldEntity's collision hull
79        \param newhull: a pointer to a completely assembled CollisionCluster
80       
81        Any previously assigned collision hull will be deleted on reassignment
[2043]82*/
[2190]83void WorldEntity::set_collision (CollisionCluster* newhull)
[2036]84{
[2190]85        if( newhull == NULL) return;
86        if( collisioncluster != NULL) delete collisioncluster;
87        collisioncluster = newhull;
[2036]88}
89
[2043]90/**
[2190]91        \brief this method is called every frame
92        \param time: the time in seconds that has passed since the last tick
93       
94        Handle all stuff that should update with time inside this method (movement, animation, etc.)
[2043]95*/
[2190]96void WorldEntity::tick(float time) 
[2036]97{
98}
99
[2043]100/**
[2190]101   \brief the entity is drawn onto the screen with this function
[2036]102
[2190]103   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.
[2043]104*/
[2190]105void WorldEntity::draw() 
106{
107}
[2036]108
[2043]109/**
[2190]110        \brief this function is called, when two entities collide
111        \param other: the world entity with whom it collides
112        \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
113        \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
[2043]114
[2190]115        Implement behaviour like damage application or other miscellaneous collision stuff in this function
[2043]116*/
[2190]117void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
[2036]118
[2043]119/**
120   \brief this function is called, when the ship is hit by a waepon
121   \param weapon: the laser/rocket/shoot that hits.
122   \param loc: place where it is hit
[2036]123
[2043]124   calculate the damage depending
125*/
126void WorldEntity::hit(WorldEntity* weapon, Vector loc) {}
127
128/**
[2190]129   \brief this function is called when the entity is to be destroied
[2043]130   
131   This can be called, if eg. something realy bad happens :)
132*/
133void WorldEntity::destroy() {}
134
[2190]135
[2043]136/**
[2190]137        \brief basic initialisation for bound Entities
[2043]138*/
[2190]139void WorldEntity::init( Location* spawnloc, WorldEntity* spawnowner)
140{
141        loc = *spawnloc;
142        owner = spawnowner;
143}
[2043]144
145/**
[2190]146        \brief basic initialisation for free Entities
147*/
148void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner)
149{
150        place = *spawnplc;
151        owner = spawnowner;
152}
[2043]153
[2190]154/**
155        \brief this is called immediately after the Entity has been constructed and initialized
156       
157        Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
158        DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
[2043]159*/
[2190]160void WorldEntity::post_spawn ()
161{
162}
[2043]163
164/**
[2190]165        \brief this handles incoming command messages
166        \param cmd: a pointer to the incoming Command structure
167       
168        Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
169        to send commands from one WorldEntity to another.
170*/
171void WorldEntity::command (Command* cmd)
172{
173}
[2043]174
[2190]175/**
176        \brief this is called by the local Camera to determine the point it should look at on the WorldEntity
177        \param locbuf: a pointer to the buffer to fill with a location to look at
178       
179        You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how
180        to look at the location you return with this.
[2043]181*/
[2190]182void WorldEntity::get_lookat (Location* locbuf)
183{
184}
[2043]185
186/**
[2190]187        \brief this method is called by the world if the WorldEntity leaves valid gamespace
188       
189        For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
190        place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
[2043]191*/
[2190]192void WorldEntity::left_world ()
193{
194}
Note: See TracBrowser for help on using the repository browser.