git repos / saland

commit 71157931

Poul Sander · 2021-08-09 15:37
71157931502657c917b41b4816ce10242484afc2 patch · browse files
parent 4651597ffc33fd657094a7269e07b84999cd75a7

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;
};