/* core/entityprojectile.h This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ #ifndef __INCLUDED_CORE_PROJECTILE_H__ #define __INCLUDED_CORE_PROJECTILE_H__ #include "core/entity.h" namespace core { class EntityProjectile : public core::EntityDynamic { public: EntityProjectile(); EntityProjectile(std::istream & is); virtual ~EntityProjectile(); virtual void upkeep(const unsigned long timestamp); virtual void collision(Entity *other); virtual void frame(const unsigned long elapsed); /* --- inspectors ------------------------------------------ */ /** * @brief core type id * */ virtual inline const unsigned int type() const { return Projectile; } inline const unsigned long timestamp() const { return projectile_timestamp; } /** * @brief the lifespan of this projectile, in milliseconds * */ inline const unsigned long lifespan() const { return projectile_lifespan; } /** * @brief the amount of damage this projectile inflicts * */ inline const float damage() const { return projectile_damage; } /** * @brief id of the player who fired the projectile * */ inline const unsigned int ownerid() const { return projectile_ownerid; } /** * @brief return the projectile modelname * */ inline const std::string & projectile_modelname() const { return projectile_modelname_str; } /*----- serializers ----------------------------------------------- */ /** * @brief serialize the entity to a stream * */ virtual void serialize_server_create(std::ostream & os) const; /*----- mutators -------------------------------------------------- */ /** * @brief receive a server-to-client create from a stream * */ virtual void receive_server_create(std::istream &is); /** * @brief reset physics state * */ virtual void reset(); /** * @brief set the amount of damage this projectile inflicts * */ inline void set_damage(const float damage) { projectile_damage = damage; } /** * @brief set the lifespan of the projectile * */ inline void set_lifespan(const unsigned long lifespan) { projectile_lifespan = lifespan; } /** * @brief set the id of the player who fired the projectile * */ inline void set_ownerid(const unsigned int ownerid) { projectile_ownerid = ownerid; } /** * @brief set the projectile timestamp * */ inline void set_timestamp(const unsigned int timestamp) { projectile_timestamp = timestamp; } /** * @brief set the projectile modelname * */ void set_projectile_modelname(const std::string modelname); private: unsigned long projectile_timestamp; unsigned long projectile_lifespan; std::string projectile_modelname_str; float projectile_damage; unsigned int projectile_ownerid; }; } // namespace game #endif // __INCLUDED_CORE_PROJECTILE_H__