diff options
author | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:25:40 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:25:40 +0000 |
commit | 3318b29475ffc5f462e2926f9b1141beca8305ae (patch) | |
tree | 15558ef704cf0aa8951618e52f7cd01769258bcc /src/core/entityprojectile.h | |
parent | 438283d0029a6d82e1669b218a2481c5c4ea2dbd (diff) |
Added core::Entity::Projectile.
Diffstat (limited to 'src/core/entityprojectile.h')
-rw-r--r-- | src/core/entityprojectile.h | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/src/core/entityprojectile.h b/src/core/entityprojectile.h new file mode 100644 index 0000000..04070ff --- /dev/null +++ b/src/core/entityprojectile.h @@ -0,0 +1,146 @@ +/* + 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 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 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; + + int projectile_ownerid; +}; + +} // namespace game + +#endif // __INCLUDED_CORE_PROJECTILE_H__ + |