diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/game/items/StarCodexItem.cpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/game/items/StarCodexItem.cpp')
-rw-r--r-- | source/game/items/StarCodexItem.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/game/items/StarCodexItem.cpp b/source/game/items/StarCodexItem.cpp new file mode 100644 index 0000000..aaaca3b --- /dev/null +++ b/source/game/items/StarCodexItem.cpp @@ -0,0 +1,49 @@ +#include "StarCodexItem.hpp" +#include "StarRoot.hpp" +#include "StarJsonExtra.hpp" +#include "StarPlayer.hpp" +#include "StarAssets.hpp" +#include "StarClientContext.hpp" +#include "StarCodex.hpp" + +namespace Star { + +CodexItem::CodexItem(Json const& config, String const& directory, Json const& data) + : Item(config, directory, data), SwingableItem(config) { + setWindupTime(0.2f); + setCooldownTime(0.5f); + m_requireEdgeTrigger = true; + m_codexId = instanceValue("codexId").toString(); + String iconPath = instanceValue("codexIcon").toString(); + m_iconDrawables = {Drawable::makeImage(iconPath, 1.0f, true, Vec2F())}; + m_worldDrawables = {Drawable::makeImage(iconPath, 1.0f / TilePixels, true, Vec2F())}; +} + +ItemPtr CodexItem::clone() const { + return make_shared<CodexItem>(*this); +} + +List<Drawable> CodexItem::drawables() const { + return m_worldDrawables; +} + +void CodexItem::fireTriggered() { + if (auto player = as<Player>(owner())) { + auto codexLearned = player->codexes()->learnCodex(m_codexId); + if (codexLearned) { + player->queueUIMessage(Root::singleton().assets()->json("/codex.config:messages.learned").toString()); + } else { + player->queueUIMessage(Root::singleton().assets()->json("/codex.config:messages.alreadyKnown").toString()); + } + } +} + +List<Drawable> CodexItem::iconDrawables() const { + return m_iconDrawables; +} + +List<Drawable> CodexItem::dropDrawables() const { + return m_worldDrawables; +} + +} |