void buildatlas_armour(std::vector<Armour>& atlas) { // Armour(Name, Description, Defense, Armour Class Boost, Health Boost, Slot) atlas.push_back(Armour("Leather Cuirass", "Torso armour made of tanned hide", 4, 1, 5, Armour::Slot::TORSO)); atlas.push_back(Armour("Steel Cuirass", "Torso armour made of steel", 4, 1, 10, Armour::Slot::TORSO)); atlas.push_back(Armour("Leather Helmet", "Head armour made of tanned hide", 4, 1, 1, Armour::Slot::HEAD)); return; }
void HudItemDesc::onDraw(Renderer2D &out) const { HudLayer::onDraw(out); FRect rect = this->rect(); if(!m_item.isDummy()) { float ypos = topOffset() + rect.y(); FRect uv_rect; auto texture = m_item.guiImage(false, uv_rect); float2 size(texture->width() * uv_rect.width(), texture->height() * uv_rect.height()); float2 pos = (float2)(int2)(float2(rect.center().x - size.x * 0.5f, ypos)); out.addFilledRect(FRect(pos, pos + size), uv_rect, {texture, mulAlpha(ColorId::white, alpha())}); ypos += size.y + 10.0f; FRect desc_rect(rect.x() + 5.0f, ypos, rect.ex() - 5.0f, rect.ey() - 5.0f); // TODO: fix drawing of text that does not fit string params_desc; if(m_item.type() == ItemType::weapon) params_desc = Weapon(m_item).paramDesc(); else if(m_item.type() == ItemType::ammo) params_desc = Ammo(m_item).paramDesc(); else if(m_item.type() == ItemType::armour) params_desc = Armour(m_item).paramDesc(); m_font->draw(out, float2(rect.x() + 5.0f, ypos), {titleColor(), titleShadowColor()}, params_desc); } }
void ActorInventory::load(Stream &sr) { Inventory::load(sr); u8 flags; sr >> flags; m_weapon = flags & 1? Weapon(Item(sr)) : m_dummy_weapon; m_armour = flags & 2? Armour(Item(sr)) : Item::dummyArmour(); m_ammo.item = flags & 4? Item(sr) : Item::dummyAmmo(); m_ammo.count = flags & 4? decodeInt(sr) : 0; }
void Equipment::deequip_armour() { if (has_armour()) { inventory.add(armour.as_item(), 1); armour = Armour(NONE); } }