28 |
using namespace enigma; |
using namespace enigma; |
29 |
using namespace stones; |
using namespace stones; |
30 |
|
|
|
namespace stones |
|
|
{ |
|
|
player::Inventory * |
|
|
get_inventory(const Actor *a) |
|
|
{ |
|
|
if (const Value *v = a->get_attrib("player")) |
|
|
return player::GetInventory(to_int(*v)); |
|
|
return 0; |
|
|
} |
|
|
|
|
|
Item *wielded_item (Actor *a) { |
|
|
if (player::Inventory *inv = get_inventory(a)) |
|
|
return inv->get_item(0); |
|
|
return 0; |
|
|
} |
|
|
|
|
|
bool wielded_item_is(Actor *a, const string &kind) |
|
|
{ |
|
|
if (player::Inventory *inv = get_inventory(a)) |
|
|
if (Item *it = inv->get_item(0)) |
|
|
return it->get_kind() == kind; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
31 |
// ******************************************************************************* |
// ******************************************************************************* |
32 |
// Stones under development : |
// Stones under development : |
33 |
|
|
44 |
{} |
{} |
45 |
|
|
46 |
void actor_hit (const StoneContact &sc) { |
void actor_hit (const StoneContact &sc) { |
47 |
if (player::Inventory *inv = get_inventory(sc.actor)) { |
if (player::Inventory *inv = player::GetInventory(sc.actor)) { |
48 |
GridPos p = find_pipe_endpoint(); |
if (Item *it = inv->get_item(0)) { |
49 |
Item *it = inv->get_item(0); |
GridPos p = find_pipe_endpoint(); |
50 |
|
|
51 |
if (it->is_kind("it-brake")) { |
if (it->is_kind("it-brake")) { |
52 |
if (!GetStone(p)) { |
if (!GetStone(p)) { |
53 |
it = inv->yield_first(); |
it = inv->yield_first(); |
54 |
world::SetItemAsStone(p, it); |
world::SetItemAsStone(p, it); |
55 |
|
} |
56 |
} |
} |
57 |
} |
else { |
58 |
else { |
if (!GetItem (p)) { |
59 |
if (!GetItem (p)) { |
it = inv->yield_first(); |
60 |
it = inv->yield_first(); |
world::SetItem(p, it); |
61 |
world::SetItem(p, it); |
it->on_drop(sc.actor); |
62 |
it->on_drop(sc.actor); |
} |
63 |
} |
} |
64 |
} |
} |
65 |
} |
} |