1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Manuel Leuenberger |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | #include "network_turret.h" |
---|
17 | #include "model.h" |
---|
18 | #include "world_entities/weapons/turret.h" |
---|
19 | |
---|
20 | #include "state.h" |
---|
21 | #include "playable.h" |
---|
22 | #include "player.h" |
---|
23 | |
---|
24 | |
---|
25 | #include "util/loading/factory.h" |
---|
26 | #include "network_game_manager.h" |
---|
27 | #include "util/loading/load_param.h" |
---|
28 | |
---|
29 | #include "effects/explosion.h" |
---|
30 | |
---|
31 | #include "weapons/targeting_turret.h" |
---|
32 | |
---|
33 | CREATE_FACTORY(NetworkTurret, CL_NETWORK_TURRET); |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | /** |
---|
39 | * constructs and loads a NetworkTurret from a XML-element |
---|
40 | * @param root the XML-element to load from |
---|
41 | */ |
---|
42 | NetworkTurret::NetworkTurret(const TiXmlElement* root) |
---|
43 | : NPC(root) |
---|
44 | { |
---|
45 | this->init(); |
---|
46 | if (root != NULL) |
---|
47 | this->loadParams(root); |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | /** |
---|
52 | * standard deconstructor |
---|
53 | */ |
---|
54 | NetworkTurret::~NetworkTurret () |
---|
55 | {} |
---|
56 | |
---|
57 | |
---|
58 | /** |
---|
59 | * initializes the NetworkTurret |
---|
60 | * @todo change this to what you wish |
---|
61 | */ |
---|
62 | void NetworkTurret::init() |
---|
63 | { |
---|
64 | this->setClassID(CL_NETWORK_TURRET, "NetworkTurret"); |
---|
65 | this->loadModel("models/network_turret_#.obj", 5); |
---|
66 | this->weapon = new TargetingTurret(); |
---|
67 | this->weapon->loadModel("models/guns/turret2.obj", 10); |
---|
68 | |
---|
69 | this->setHealthMax(300); |
---|
70 | this->setHealth(300); |
---|
71 | |
---|
72 | this->weaponHolder.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); |
---|
73 | |
---|
74 | this->weaponHolder.setRelCoor(0,25,0); |
---|
75 | this->weaponHolder.setParent(this); |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | /** |
---|
80 | * @brief loads a NetworkTurret from a XML-element |
---|
81 | * @param root the XML-element to load from |
---|
82 | * @todo make the class Loadable |
---|
83 | */ |
---|
84 | void NetworkTurret::loadParams(const TiXmlElement* root) |
---|
85 | { |
---|
86 | // all the clases this Entity is directly derived from must be called in this way, to load all settings. |
---|
87 | NPC::loadParams(root); |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * advances the NetworkTurret about time seconds |
---|
92 | * @param time the Time to step |
---|
93 | */ |
---|
94 | void NetworkTurret::tick(float dt) |
---|
95 | { |
---|
96 | if(this->getHealth() > 0.0f |
---|
97 | ) // HACK <--- YOU ARE THE MOTHERFUCKER |
---|
98 | { |
---|
99 | if (likely(this->weapon != NULL)) |
---|
100 | { |
---|
101 | // this->left->tickW(dt); |
---|
102 | this->weapon->requestAction(WA_SHOOT); |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * draws this worldEntity |
---|
109 | */ |
---|
110 | void NetworkTurret::draw () const |
---|
111 | { |
---|
112 | WorldEntity::draw(); |
---|
113 | |
---|
114 | if (this->weapon != NULL) |
---|
115 | this->weapon->draw(); |
---|
116 | } |
---|
117 | |
---|
118 | |
---|
119 | |
---|
120 | /** |
---|
121 | * |
---|
122 | * |
---|
123 | */ |
---|
124 | void NetworkTurret::postSpawn () |
---|
125 | {} |
---|
126 | |
---|
127 | /** |
---|
128 | * |
---|
129 | * |
---|
130 | */ |
---|
131 | void NetworkTurret::leftWorld () |
---|
132 | {} |
---|
133 | |
---|
134 | void NetworkTurret::destroy(WorldEntity* killer) |
---|
135 | { |
---|
136 | this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90); |
---|
137 | Explosion::explode(this, Vector(10,10,10)); |
---|
138 | |
---|
139 | this->toList(OM_DEAD); |
---|
140 | } |
---|