blob: da1d20eb3cc69d8e6912985254bb1311f9044599 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#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);
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;
}
}
|