Changeset 11736 for code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc
- Timestamp:
- Feb 11, 2018, 10:31:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc
r11735 r11736 71 71 */ 72 72 73 74 #include "../../orxonox/worldentities/pawns/Pawn.h"75 #include "../../orxonox/worldentities/WorldEntity.h"76 77 73 #include "AsteroidMinable.h" 78 74 … … 82 78 #include "core/GameMode.h" 83 79 #include "core/XMLPort.h" 84 #include "core/EventIncludes.h"85 #include "network/NetworkFunction.h"86 80 #include "util/Convert.h" 87 81 #include "util/Math.h" 88 82 89 #include "../pickup/PickupSpawner.h" 90 #include "../pickup/Pickup.h" 91 92 #include "../objects/collisionshapes/SphereCollisionShape.h" 93 #include "../../orxonox/graphics/Model.h" 94 83 #include "pickup/PickupSpawner.h" 84 #include "pickup/Pickup.h" 85 86 #include "objects/collisionshapes/SphereCollisionShape.h" 87 #include "graphics/Model.h" 95 88 96 89 namespace orxonox{ … … 102 95 103 96 RegisterObject(AsteroidMinable); 104 this->context = context;105 97 106 98 // Default Values: 107 this->size = 1 0;99 this->size = 1; 108 100 this->dropStuff = true; 109 101 this->generateSmaller = true; 110 this->health_ = 15*size;111 this->maxHealth_ = this->health_;112 102 this->acceptsPickups_ = false; 113 103 … … 121 111 } 122 112 123 // @brief Use this constructor with care. Mainly used internally, arguments are passed directly. 124 AsteroidMinable::AsteroidMinable(Context* c, float size, Vector3 position, bool dropStuff) : Pawn(c){ 125 126 RegisterObject(AsteroidMinable); 113 AsteroidMinable::~AsteroidMinable(){ 114 115 } 116 117 void AsteroidMinable::setSize(int s) 118 { 119 this->size = s; 120 this->health_ = 15*size; 121 this->maxHealth_ = this->health_; 122 } 123 124 // @brief Helper method. 125 void AsteroidMinable::putStuff(){ 127 126 128 127 // The radar is able to detect whether an asteroid contains resources.... … … 136 135 } 137 136 138 this->context = c;139 this->size = size;140 this->health_ = 15*size;141 this->maxHealth_ = this->health_;142 this->acceptsPickups_ = false;143 this->generateSmaller = true;144 this->dropStuff = dropStuff;145 146 this->setPosition(position);147 //this->roll = rand()*5; //etwas Drehung. Richtige Variable?148 149 this->setCollisionType(WorldEntity::CollisionType::Dynamic);150 this->enableCollisionCallback();151 152 137 // Add Model, random one of the 6 shapes 153 Model* hull = new Model(this-> context);138 Model* hull = new Model(this->getContext()); 154 139 hull->setMeshSource("ast" + multi_cast<std::string>(1 + (int)rnd(0, 6)) + ".mesh"); 155 140 hull->setScale(this->size); … … 157 142 158 143 // Collision shape 159 SphereCollisionShape* cs = new SphereCollisionShape(this-> context);144 SphereCollisionShape* cs = new SphereCollisionShape(this->getContext()); 160 145 cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien. 161 146 this->attachCollisionShape(cs); 162 147 163 this->registerVariables();164 165 148 this->initialised=true; 166 167 }168 169 AsteroidMinable::~AsteroidMinable(){170 171 }172 173 // @brief Helper method.174 void AsteroidMinable::putStuff(){175 176 AsteroidMinable* reborn = new AsteroidMinable(this->context, this->size, this->getPosition(), this->dropStuff);177 reborn->setVelocity(this->getVelocity());178 // reborn->setAngularVelocity(this->getAngularVelocity()); // Add all other stuff, too?179 180 this->bAlive_ = false;181 this->destroyLater();182 183 149 } 184 150 … … 188 154 189 155 XMLPortParam(AsteroidMinable, "size", setSize, getSize, xmlelement, mode); 190 XMLPortParam(AsteroidMinable, "generateSmaller", toggleShattering, doesShatter, xmlelement, mode); 191 XMLPortParam(AsteroidMinable, "dropStuff", toggleDropStuff, doesDropStuff, xmlelement, mode); 192 193 } 194 195 void AsteroidMinable::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){ 196 197 SUPER(AsteroidMinable, XMLEventPort, xmlelement, mode); 156 XMLPortParam(AsteroidMinable, "generateSmaller", setShattering, doesShatter, xmlelement, mode); 157 XMLPortParam(AsteroidMinable, "dropStuff", setDropStuff, doesDropStuff, xmlelement, mode); 198 158 199 159 } … … 228 188 // Pickups which can be harvested. It's munition at the moment, could be changed/extended. 229 189 if(dropStuff){ 230 PickupSpawner* thingy = new PickupSpawner(this-> context);190 PickupSpawner* thingy = new PickupSpawner(this->getContext()); 231 191 232 192 std::string tname; … … 366 326 } 367 327 368 AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + pos, this->dropStuff); 328 AsteroidMinable* child = new AsteroidMinable(this->getContext()); 329 child->setSize(masses[fisch]); 330 child->setPosition(this->getPosition() + pos); 369 331 child->setVelocity(this->getVelocity()); 370 332 child->setDropStuff(this->dropStuff); 371 333 } 372 334 // orxout() << "Leaving spawnChildren() method. " << endl;
Note: See TracChangeset
for help on using the changeset viewer.