Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.cc4
-rw-r--r--src/core/entity.h6
-rw-r--r--src/core/entityprojectile.cc8
-rw-r--r--src/core/entityprojectile.h6
4 files changed, 18 insertions, 6 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 67227ca..4d8c4c7 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -955,6 +955,10 @@ void EntityDynamic::collision(Entity *other)
{
}
+void EntityDynamic::hit(Entity *other)
+{
+}
+
void EntityDynamic::serialize_server_create(std::ostream & os) const
{
Entity::serialize_server_create(os);
diff --git a/src/core/entity.h b/src/core/entity.h
index 0be81b9..df65843 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -662,6 +662,12 @@ public:
* Warning: this can be called multiple times for a single collision
* */
virtual void collision(Entity *other);
+
+ /**
+ * @brief weapon hit callback
+ * This method is called by the core-engine if the entity is hit by a weapon.
+ * */
+ virtual void hit(Entity *other);
protected:
float entity_mass;
diff --git a/src/core/entityprojectile.cc b/src/core/entityprojectile.cc
index 8c6c57b..e89c7f7 100644
--- a/src/core/entityprojectile.cc
+++ b/src/core/entityprojectile.cc
@@ -56,10 +56,12 @@ void EntityProjectile::collision(Entity *other)
{
if (state() == Entity::Destroyed) {
return;
+ } else {
+ if ((other->type() == Dynamic) || (other->type() == Controlable)) {
+ static_cast<EntityDynamic *>(other)->hit(this);
+ }
+ set_state(Entity::Destroyed);
}
-
- set_state(Entity::Destroyed);
- // this method is a bullet callback, we can not reset() here
}
void EntityProjectile::frame(const unsigned long elapsed)
diff --git a/src/core/entityprojectile.h b/src/core/entityprojectile.h
index 04070ff..6bbcdfd 100644
--- a/src/core/entityprojectile.h
+++ b/src/core/entityprojectile.h
@@ -59,7 +59,7 @@ public:
/**
* @brief id of the player who fired the projectile
* */
- inline const int ownerid() const
+ inline const unsigned int ownerid() const
{
return projectile_ownerid;
}
@@ -110,7 +110,7 @@ public:
/**
* @brief set the id of the player who fired the projectile
* */
- inline void set_ownerid(const int ownerid)
+ inline void set_ownerid(const unsigned int ownerid)
{
projectile_ownerid = ownerid;
}
@@ -137,7 +137,7 @@ private:
float projectile_damage;
- int projectile_ownerid;
+ unsigned int projectile_ownerid;
};
} // namespace game