Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-01-01 15:20:14 +0000
committerStijn Buys <ingar@osirion.org>2013-01-01 15:20:14 +0000
commit614ce1267772d67825a32fb7495a049cd6498fe5 (patch)
tree20374ef083b62524e831bce2a8a89fcc70a63f42 /src/core
parent18969b1c444597741547598d35e8f0f97acd39dc (diff)
Initial support for turret-style weapons.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/slot.cc12
-rw-r--r--src/core/slot.h43
-rw-r--r--src/core/slots.cc3
3 files changed, 56 insertions, 2 deletions
diff --git a/src/core/slot.cc b/src/core/slot.cc
index e842f78..58ab155 100644
--- a/src/core/slot.cc
+++ b/src/core/slot.cc
@@ -17,6 +17,8 @@ Slot::Slot()
slot_flags = 0;
slot_timestamp = 0;
slot_last_fired = 0;
+ slot_cone = 0;
+ slot_type = model::Weapon::Cannon;
}
Slot::~Slot()
@@ -41,4 +43,14 @@ void Slot::set_item(Item *item)
set_timestamp(game() ? game()->timestamp() : 1);
}
+void Slot::load(const model::Weapon * weapon_tag)
+{
+ if (weapon_tag) {
+ set_type(weapon_tag->type());
+ set_cone(weapon_tag->cone());
+ set_location(weapon_tag->location());
+ set_axis(weapon_tag->axis());
+ }
+}
+
} // namespace core
diff --git a/src/core/slot.h b/src/core/slot.h
index eef640a..596244b 100644
--- a/src/core/slot.h
+++ b/src/core/slot.h
@@ -11,6 +11,7 @@
#include "math/axis.h"
#include "core/item.h"
+#include "model/tags.h"
#include <string>
@@ -83,6 +84,22 @@ public:
{
return slot_last_fired;
}
+
+ /**
+ * @brief slot fire cone, in degrees
+ * */
+ inline float cone() const
+ {
+ return slot_cone;
+ }
+
+ /**
+ * @brief weapon slot type
+ * */
+ inline const model::Weapon::Type type() const
+ {
+ return slot_type;
+ }
/* --- mutators -------------------------------------------- */
@@ -134,7 +151,29 @@ public:
* @brief set the item this slot is holding
* */
void set_item(Item *item);
+
+ /**
+ * @brief set slot fire cone, in degrees
+ * */
+ inline void set_cone(const float cone)
+ {
+ slot_cone = cone;
+ }
+
+ /**
+ * @brief set slot type
+ * */
+ void set_type(const model::Weapon::Type type)
+ {
+ slot_type = type;
+ }
+ /**
+ * @brief load slot parameters from a model weapon tag
+ * */
+ void load(const model::Weapon *weapon_tag);
+
+
private:
math::Vector3f slot_location;
@@ -152,6 +191,10 @@ private:
// item mounted in this slot
Item *slot_item;
+
+ model::Weapon::Type slot_type;
+
+ float slot_cone;
};
} // namespace core
diff --git a/src/core/slots.cc b/src/core/slots.cc
index 12f6208..6d6096a 100644
--- a/src/core/slots.cc
+++ b/src/core/slots.cc
@@ -23,8 +23,7 @@ void Slots::load(model::Model *model)
{
for (model::Model::Weapons::iterator it = model->weapons().begin(); it != model->weapons().end(); ++it) {
Slot *slot = new Slot();
- slot->set_location((*it)->location());
- slot->set_axis((*it)->axis());
+ slot->load((*it));
slots_container.push_back(slot);
}
//con_debug << " loaded " << slots_container.size() << " entity slots" << std::endl;