commit 71157931
Can now spawn different items
Changed files
| M | src/saland/Game.cpp before |
| M | src/saland/model/spells.hpp before |
diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp
index e9ff5c0..fef7ae4 100644
--- a/src/saland/Game.cpp
+++ b/src/saland/Game.cpp
@@ -300,6 +300,11 @@ Game::Game() {
Spell& slot5 = data->slot_spell.at(5);
slot5.icon = "item_food_potato";
slot5.name = "spell_spawn_item";
+ slot5.item_name = "food_potato";
+ Spell& slot6 = data->slot_spell.at(6);
+ slot6.icon = "item_barrel";
+ slot6.name = "spell_spawn_item";
+ slot6.item_name = "barrel";
Spell& slot9 = data->slot_spell.at(9);
slot9.icon = "icon_trash_can";
slot9.name = "spell_clear_block";
@@ -685,10 +690,11 @@ void Game::Update() {
data->gameRegion.placeables.push_back(projectile);
}
}
+ const Spell& selectedSpell = data->slot_spell.at(data->slot_selected);
if (data->slot_spell.at(data->slot_selected).name == "spell_spawn_item") {
if (data->human->castTimeRemaining == 0) {
data->human->castTimeRemaining = data->human->castTime;
- const ItemDef& potatoDef = getItem("food_potato");
+ const ItemDef& potatoDef = getItem(selectedSpell.item_name);
data->gameRegion.SpawnItem(potatoDef, data->world_mouse_x, data->world_mouse_y);
//spawn item
}
diff --git a/src/saland/model/spells.hpp b/src/saland/model/spells.hpp
index a6abe98..5cbf9de 100644
--- a/src/saland/model/spells.hpp
+++ b/src/saland/model/spells.hpp
@@ -31,6 +31,7 @@ enum class SpellCursorType { dot = 0, tile=1, shpere = 2 };
struct Spell {
std::string name;
std::string icon;
+ std::string item_name;
int tile = 0; //Number reference to a tile, we might also need a tileset at some point
SpellCursorType type = SpellCursorType::dot;
};