EscortDisplay::Icon::Icon(const Ship &ship, bool isHere) : sprite(ship.GetSprite().GetSprite()), isHere(isHere && !ship.IsDisabled()), stackSize(1), cost(ship.Cost()), system((!isHere && ship.GetSystem()) ? ship.GetSystem()->Name() : ""), low{ship.Shields(), ship.Hull(), ship.Energy(), ship.Heat(), ship.Fuel()}, high(low) { }
// Check if this projectile collides with the given step, with the animation // frame for the given step. double Projectile::CheckCollision(const Ship &ship, int step) const { const Mask &mask = ship.GetSprite().GetMask(step); Point offset = position - ship.Position(); double radius = weapon->TriggerRadius(); if(radius > 0. && mask.WithinRange(offset, angle, radius)) return 0.; return mask.Collide(offset, velocity, ship.Facing()); }
void ShopPanel::DrawShip(const Ship &ship, const Point ¢er, bool isSelected) const { const Sprite *sprite = ship.GetSprite().GetSprite(); const Sprite *back = SpriteSet::Get( isSelected ? "ui/shipyard selected" : "ui/shipyard unselected"); SpriteShader::Draw(back, center); // Make sure the ship sprite leaves 10 pixels padding all around. float zoomSize = SHIP_SIZE - 60.f; // Draw the ship name. const string &name = ship.Name().empty() ? ship.ModelName() : ship.Name(); const Font &font = FontSet::Get(14); Point offset(-.5f * font.Width(name), -.5f * SHIP_SIZE + 10.f); font.Draw(name, center + offset, *GameData::Colors().Get("bright")); float zoom = min(1.f, zoomSize / max(sprite->Width(), sprite->Height())); int swizzle = GameData::PlayerGovernment()->GetSwizzle(); SpriteShader::Draw(sprite, center, zoom, swizzle); }
// Check if the given ship is within this projectile's blast radius. (The // projectile will not explode unless it is also within the trigger radius.) bool Projectile::InBlastRadius(const Ship &ship, int step) const { const Mask &mask = ship.GetSprite().GetMask(step); return mask.WithinRange(position - ship.Position(), ship.Facing(), weapon->BlastRadius()); }