/* $Id: bonushealth.cpp,v 1.7 2005/10/05 14:46:44 chfreund Exp $ */ #include "bonushealth.hpp" #include "avatar.hpp" /**********************************************************/ #define HEALTHBONUS_HEALING_IMPACT 500000 #define HEALTHBONUS_HEALTH 300000 /**********************************************************/ BonusHealth::BonusHealth( World* wp ) : m_healingImpact(HEALTHBONUS_HEALING_IMPACT) { m_worldPointer = wp; // set health for the health bonus m_health = HEALTHBONUS_HEALTH; // for mass and collission rectangle take the // default values from base class Bonus // THIS CALL MUST BE PART OF EACH CONSTRUCTOR // OF BONI, DERIVED FROM ITS BASE CLASS Bonus registerAtManager(); } /**********************************************************/ BonusHealth::~BonusHealth() { // THIS CALL MUST BE PART OF EACH DENSTRUCTOR // OF BONI, DERIVED FROM ITS BASE CLASS Bonus unregisterAtManager(); } /**********************************************************/ bool BonusHealth::canBePickedUpByAvatar( const Avatar* const avatar ) { return avatar->getHealth() < avatar->getMaxHealth(); } /**********************************************************/ void BonusHealth::apply( Avatar *const avatar ) { avatar->heal( m_healingImpact ); } /**********************************************************/ Uint32 BonusHealth::getSerializeBufferSize() const { return Bonus::getSerializeBufferSize() + Serialize::sizeOf( m_healingImpact ) // adds additional size for debugging (see serialize.hpp), // but only, if the tags are used PLUS_TAG_SIZE( 1 ); } /**********************************************************/ void BonusHealth::serialize( Uint8*& bufferPointer ) const { // expands to a check of the buffer movement START_OBJECT_SERIALIZED_SIZE_CHECK( bufferPointer ); Bonus::serialize( bufferPointer ); Serialize::serialize( m_healingImpact, bufferPointer ); // expands to tag serialization SERIALIZE_OBJECT_TAG( bufferPointer ); // expands to a check of the buffer movement END_OBJECT_SERIALIZED_SIZE_CHECK( bufferPointer, BonusHealth ); } /**********************************************************/ void BonusHealth::deserialize( Uint8*& bufferPointer ) { Bonus::deserialize( bufferPointer ); Serialize::deserialize( bufferPointer, m_healingImpact ); // expands to tag deserialization DESERIALIZE_OBJECT_TAG( bufferPointer ); } /**********************************************************/