Exemplo n.º 1
0
void inventory_system::register_inventory_carried(
		item_carried_component * carried)
{
	debug_name_component * name = ECS->find_entity_component<debug_name_component>(carried->entity_id);
	position_component3d * pos = ECS->find_entity_component<position_component3d>(carried->carried_by_id);
	store_inventory(name, pos);
}
Exemplo n.º 2
0
bool StoreContent::handle_io(GameState* gs, ActionQueue& queued_actions) {
	PlayerInst* p = gs->local_player();
	StoreInventory& inv = store_inventory();
	int mx = gs->mouse_x(), my = gs->mouse_y();
	bool within_inventory = bbox.contains(mx, my);

	/* Buy an item (left click) */
	if (gs->mouse_left_click() && within_inventory) {

		int slot = get_itemslotn(inv, bbox, mx, my);
		if (slot >= 0 && slot < INVENTORY_SIZE && inv.get(slot).amount > 0) {
			if (p->gold() >= inv.get(slot).cost) {
				queued_actions.push_back(
						game_action(gs, p, GameAction::PURCHASE_FROM_STORE,
								store_object->id, NONE, NONE, slot));
			} else {
				gs->game_chat().add_message("You cannot afford it!",
						COL_PALE_RED);
			}
			return true;
		}
	}
	return false;
}
Exemplo n.º 3
0
void StoreContent::draw(GameState* gs) const {
	StoreInventory& inv = store_inventory();
	draw_store_inventory(gs, inv, bbox, 0, 40);
//	inv.
}
Exemplo n.º 4
0
void inventory_system::register_inventory_ground(position_component3d * pos)
{
	debug_name_component * name = ECS->find_entity_component<debug_name_component>(pos->entity_id);
	store_inventory(name, pos);
}
Exemplo n.º 5
0
void inventory_system::register_inventory_stored(item_storage_component * store)
{
	debug_name_component * name = ECS->find_entity_component<debug_name_component>(store->entity_id);
	position_component3d * pos = ECS->find_entity_component<position_component3d>(store->container_id);
	store_inventory(name, pos);
}