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: |
---|
16 | */ |
---|
17 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
18 | |
---|
19 | |
---|
20 | #include "util/loading/factory.h" |
---|
21 | #include "util/loading/load_param.h" |
---|
22 | |
---|
23 | #include "interactive_model.h" |
---|
24 | |
---|
25 | |
---|
26 | #include "repair_station.h" |
---|
27 | #include "class_list.h" |
---|
28 | |
---|
29 | |
---|
30 | using namespace std; |
---|
31 | |
---|
32 | |
---|
33 | CREATE_FACTORY(RepairStation, CL_DOOR); |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | //! list of all different animations a std md2model supports |
---|
38 | // sAnim RepairStation::animationList[2] = |
---|
39 | // { |
---|
40 | // // begin, end, fps, interruptable |
---|
41 | // { 0, 10, 30, 0 }, //!< OPEN |
---|
42 | // { 10, 20, 30, 0 } //!< CLOSE |
---|
43 | // }; |
---|
44 | |
---|
45 | |
---|
46 | sAnim RepairStation::animationList[8] = |
---|
47 | { |
---|
48 | // begin, end, fps, interruptable |
---|
49 | { 0, 12, 30, 0 }, //!< CYCLE01 |
---|
50 | { 12, 24, 30, 0 }, //!< CYCLE02 |
---|
51 | { 24, 40, 30, 0 }, //!< CYCLE03 |
---|
52 | { 40, 55, 30, 0 }, //!< CYCLE04 |
---|
53 | { 55, 68, 30, 0 }, //!< CYCLE05 |
---|
54 | { 68, 81, 30, 0 }, //!< CYCLE06 |
---|
55 | { 81, 89, 30, 0 }, //!< CYCLE07 |
---|
56 | { 89, 99, 30, 0 } //!< CYCLE08 |
---|
57 | }; |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | RepairStation::RepairStation () |
---|
62 | { |
---|
63 | this->init(); |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | RepairStation::RepairStation(const TiXmlElement* root) |
---|
68 | { |
---|
69 | |
---|
70 | this->setClassID(CL_DOOR, "RepairStation"); |
---|
71 | this->scale = 1.0f; |
---|
72 | |
---|
73 | if( root != NULL) |
---|
74 | this->loadParams(root); |
---|
75 | |
---|
76 | this->toList(OM_COMMON); |
---|
77 | this->bLocked = false; |
---|
78 | |
---|
79 | this->loadMD2Texture("maps/doors.jpg"); |
---|
80 | this->loadModel("models/creatures/doors.md2", this->scale); |
---|
81 | |
---|
82 | this->setAnimation(DOOR_CLOSE, MD2_ANIM_ONCE); |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | RepairStation::~RepairStation () |
---|
87 | {} |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | /** |
---|
92 | * loads the Settings of a MD2Creature from an XML-element. |
---|
93 | * @param root the XML-element to load the MD2Creature's properties from |
---|
94 | */ |
---|
95 | void RepairStation::loadParams(const TiXmlElement* root) |
---|
96 | { |
---|
97 | WorldEntity::loadParams(root); |
---|
98 | |
---|
99 | LoadParam(root, "action-radius", this, RepairStation, setActionRadius) |
---|
100 | .describe("sets the action radius of the door") |
---|
101 | .defaultValues(3.0); |
---|
102 | LoadParam(root, "scale", this, RepairStation, setScale) |
---|
103 | .describe("sets the scale of the door") |
---|
104 | .defaultValues(1.0); |
---|
105 | } |
---|
106 | |
---|
107 | |
---|
108 | /** |
---|
109 | * sets the animatin of this entity |
---|
110 | */ |
---|
111 | void RepairStation::setAnimation(int animNum, int playbackMode) |
---|
112 | { |
---|
113 | if( likely(this->getModel(0) != NULL)) |
---|
114 | ((InteractiveModel*)this->getModel(0))->setAnimation(animationList[animNum].firstFrame, |
---|
115 | animationList[animNum].lastFrame, |
---|
116 | animationList[animNum].fps, |
---|
117 | animationList[animNum].bStoppable, |
---|
118 | playbackMode); |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | /** |
---|
123 | * ticks the door |
---|
124 | * @param time: time since last tick |
---|
125 | */ |
---|
126 | void RepairStation::tick (float time) |
---|
127 | { |
---|
128 | if( likely(this->getModel(0) != NULL)) |
---|
129 | ((InteractiveModel*)this->getModel(0))->tick(time); |
---|
130 | |
---|
131 | if( !this->bOpen) |
---|
132 | { |
---|
133 | if( this->checkOpen()) |
---|
134 | { |
---|
135 | this->open(); |
---|
136 | } |
---|
137 | } |
---|
138 | else |
---|
139 | { |
---|
140 | if( !this->checkOpen()) |
---|
141 | { |
---|
142 | this->close(); |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | |
---|