| [4245] | 1 | |
|---|
| 2 | |
|---|
| [4679] | 3 | /* |
|---|
| [4245] | 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 |
|---|
| [4679] | 15 | co-programmer: |
|---|
| [4245] | 16 | */ |
|---|
| [5357] | 17 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
|---|
| [4245] | 18 | |
|---|
| 19 | |
|---|
| [6222] | 20 | #include "executor/executor.h" |
|---|
| 21 | #include "factory.h" |
|---|
| 22 | #include "load_param.h" |
|---|
| 23 | |
|---|
| [4245] | 24 | #include "test_entity.h" |
|---|
| 25 | #include "stdincl.h" |
|---|
| 26 | #include "model.h" |
|---|
| 27 | #include "md2Model.h" |
|---|
| [4682] | 28 | #include "obb_tree.h" |
|---|
| [5087] | 29 | #include "state.h" |
|---|
| [4245] | 30 | |
|---|
| 31 | using namespace std; |
|---|
| 32 | |
|---|
| 33 | |
|---|
| [6222] | 34 | CREATE_FACTORY(TestEntity, CL_TEST_ENTITY); |
|---|
| [4245] | 35 | |
|---|
| [6222] | 36 | |
|---|
| [4762] | 37 | TestEntity::TestEntity () |
|---|
| [4679] | 38 | { |
|---|
| [6222] | 39 | this->init(); |
|---|
| 40 | } |
|---|
| [4245] | 41 | |
|---|
| [4714] | 42 | |
|---|
| [5994] | 43 | |
|---|
| [6222] | 44 | TestEntity::TestEntity(const TiXmlElement* root) |
|---|
| 45 | { |
|---|
| 46 | this->init(); |
|---|
| 47 | if (root != NULL) |
|---|
| 48 | this->loadParams(root); |
|---|
| [4245] | 49 | } |
|---|
| 50 | |
|---|
| 51 | |
|---|
| [4679] | 52 | TestEntity::~TestEntity () |
|---|
| [6222] | 53 | {} |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | void TestEntity::init() |
|---|
| [4462] | 58 | { |
|---|
| [6222] | 59 | this->setClassID(CL_TEST_ENTITY, "TestEntity"); |
|---|
| [7078] | 60 | this->toList(OM_GROUP_00); |
|---|
| [4462] | 61 | } |
|---|
| [4245] | 62 | |
|---|
| [6222] | 63 | /** |
|---|
| 64 | * loads the Settings of a MD2Creature from an XML-element. |
|---|
| 65 | * @param root the XML-element to load the MD2Creature's properties from |
|---|
| 66 | */ |
|---|
| 67 | void TestEntity::loadParams(const TiXmlElement* root) |
|---|
| 68 | { |
|---|
| [6512] | 69 | WorldEntity::loadParams(root); |
|---|
| [4245] | 70 | |
|---|
| [6222] | 71 | LoadParam(root, "md2animation", this, TestEntity, setAnim) |
|---|
| 72 | .describe("sets the animation of the md2 model") |
|---|
| 73 | .defaultValues(1, 1); |
|---|
| 74 | |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | |
|---|
| [7071] | 78 | void TestEntity::setAnim(int animationIndex, int animPlaybackMode) |
|---|
| [4488] | 79 | { |
|---|
| [6222] | 80 | if( likely(this->getModel(0) != NULL)) |
|---|
| [7071] | 81 | ((MD2Model*)this->getModel(0))->setAnim(animationIndex, animPlaybackMode); |
|---|
| [4488] | 82 | } |
|---|
| 83 | |
|---|
| 84 | |
|---|
| [4679] | 85 | void TestEntity::tick (float time) |
|---|
| [4245] | 86 | { |
|---|
| [6222] | 87 | if( likely(this->getModel(0) != NULL)) |
|---|
| 88 | ((MD2Model*)this->getModel(0))->tick(time); |
|---|
| 89 | |
|---|
| [4245] | 90 | } |
|---|
| 91 | |
|---|
| 92 | |
|---|
| [5087] | 93 | void TestEntity::collidesWith(WorldEntity* entity, const Vector& location) |
|---|
| [7071] | 94 | { |
|---|
| 95 | if( this->lastCollided != entity) |
|---|
| 96 | { |
|---|
| 97 | this->dieHard(); |
|---|
| 98 | this->lastCollided = entity; |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| [5087] | 101 | |
|---|
| [4245] | 102 | |
|---|
| [7071] | 103 | |
|---|
| 104 | void TestEntity::dieHard() |
|---|
| 105 | { |
|---|
| 106 | this->setAnim(DEATH_FALLBACK, MD2_ANIM_ONCE); |
|---|
| 107 | } |
|---|
| 108 | |
|---|