v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
54
source/game/items/StarBlueprintItem.cpp
Normal file
54
source/game/items/StarBlueprintItem.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "StarBlueprintItem.hpp"
|
||||
#include "StarJsonExtra.hpp"
|
||||
#include "StarRoot.hpp"
|
||||
#include "StarPlayer.hpp"
|
||||
#include "StarAssets.hpp"
|
||||
#include "StarPlayerBlueprints.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
BlueprintItem::BlueprintItem(Json const& config, String const& directory, Json const& data)
|
||||
: Item(config, directory, data), SwingableItem(config) {
|
||||
setWindupTime(0.2f);
|
||||
setCooldownTime(0.1f);
|
||||
setMaxStack(1);
|
||||
m_requireEdgeTrigger = true;
|
||||
m_recipe = ItemDescriptor(instanceValue("recipe"));
|
||||
|
||||
m_recipeIconUnderlay = Drawable(Root::singleton().assets()->json("/blueprint.config:iconUnderlay"));
|
||||
m_inHandDrawable = {Drawable::makeImage(
|
||||
Root::singleton().assets()->json("/blueprint.config:inHandImage").toString(),
|
||||
1.0f / TilePixels,
|
||||
true,
|
||||
Vec2F())};
|
||||
|
||||
setPrice(int(price() * Root::singleton().assets()->json("/items/defaultParameters.config:blueprintPriceFactor").toFloat()));
|
||||
}
|
||||
|
||||
ItemPtr BlueprintItem::clone() const {
|
||||
return make_shared<BlueprintItem>(*this);
|
||||
}
|
||||
|
||||
List<Drawable> BlueprintItem::drawables() const {
|
||||
return m_inHandDrawable;
|
||||
}
|
||||
|
||||
void BlueprintItem::fireTriggered() {
|
||||
if (count())
|
||||
if (auto player = as<Player>(owner()))
|
||||
if (player->addBlueprint(m_recipe, true))
|
||||
setCount(count() - 1);
|
||||
}
|
||||
|
||||
List<Drawable> BlueprintItem::iconDrawables() const {
|
||||
List<Drawable> result;
|
||||
result.append(m_recipeIconUnderlay);
|
||||
result.appendAll(Item::iconDrawables());
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Drawable> BlueprintItem::dropDrawables() const {
|
||||
return m_inHandDrawable;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue