v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
49
source/game/items/StarCodexItem.cpp
Normal file
49
source/game/items/StarCodexItem.cpp
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue