-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic -- -- GNU General Public Licence (version 3 or later) with core, ui, effect, attribute, faction; package body unit is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ view_width : constant integer := 48; view_height : constant integer := 64; sprite : array (enumeration) of core.sprite; icon_sprite : array (enumeration) of core.sprite; view_sprite : array (enumeration) of core.sprite; ------------------------------------------------------------------------------------------ procedure configure is begin core.echo (core.comment, "Configuring unit components..."); -- for index in enumeration loop declare folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind)); file : constant string := core.lowercase (enumeration'image (index)); begin sprite (index) := core.import_sprite ("./sprite/unit/" & folder & "/" & file & ".png", 4, 6); icon_sprite (index) := core.import_sprite ("./sprite/unit/icon/" & file & ".png", 1, 1); view_sprite (index) := core.import_sprite ("./sprite/unit/view/" & file & ".png", 1, 1); end; end loop; end configure; ------------------------------------------------------------------------------------------ procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is begin core.draw (sprite (index), x, y, state => core.animation'pos (state)); end draw; ------------------------------------------------------------------------------------------ procedure icon (index : in enumeration; x, y : in integer) is begin ui.draw_overicon (icon_sprite (index), trait (index).text, x, y); end icon; ------------------------------------------------------------------------------------------ procedure view (index : in enumeration; x, y : in integer) is offset : constant integer := 4; begin core.draw (view_sprite (index), x + offset, y + offset); ui.draw_icon_menu (x, y, view_width + 2 * offset, view_height + 2 * offset); end view; ------------------------------------------------------------------------------------------ procedure full_draw (data : in value; x, y : in integer) is begin draw (data.kind, data.state, x, y); -- for index in item.slot loop if data.items (index).allow then item.draw (data.items (index).index, data.state, x, y); end if; end loop; end full_draw; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end unit;