From eab5faa357a5930baf9275e4ccc0b0b81886647e Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 3 Jun 2024 13:49:22 -0400 Subject: [PATCH] Refactored Unit package... --- source/main.adb | 6 +++++- source/unit.adb | 58 -------------------------------------------------------- source/unit.ads | 11 +++-------- source/world.adb | 15 +++++++++++---- 4 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 source/unit.adb diff --git a/source/main.adb b/source/main.adb index e1960f5..7800190 100644 --- a/source/main.adb +++ b/source/main.adb @@ -241,7 +241,11 @@ begin end; end loop; - unit.configure; + core.echo (core.comment, "Configuring" & unit.count'image & " unit components..."); + -- + for index in faction.fairy .. faction.imp loop + unit.base (index) := core.import_sprite (core.folder & "/game/unit/" & core.lowercase (faction.enumeration'image (index)) & "/base.png", 4, 6); + end loop; core.echo (core.comment, "Configuring" & deity.count'image & " deity components..."); -- diff --git a/source/unit.adb b/source/unit.adb deleted file mode 100644 index ef2e185..0000000 --- a/source/unit.adb +++ /dev/null @@ -1,58 +0,0 @@ --- 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; - - base : array (faction.fairy .. faction.imp) of core.sprite; - --~icon : array (enumeration) of core.sprite; - --~view : array (enumeration) of core.sprite; - - ------------------------------------------------------------------------------------------ - - procedure configure is - begin - core.echo (core.comment, "Configuring unit components..."); - -- - for index in faction.fairy .. faction.imp loop - base (index) := core.import_sprite (core.folder & "/game/unit/" & core.lowercase (faction.enumeration'image (index)) & "/base.png", 4, 6); - end loop; - end configure; - - ------------------------------------------------------------------------------------------ - - procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is - begin - core.draw (base (description (index).kind), x, y, state => state); - -- - for slot in equipment.slot loop - core.draw (equipment.sprite (description (index).equipments (slot)), x, y, state => state); - end loop; - end draw; - - ------------------------------------------------------------------------------------------ - - --~procedure draw_icon (index : in enumeration; x, y : in integer) is - --~begin - --~ui.draw_overicon (icon (index), description (index).text, x, y); - --~end draw_icon; - - ------------------------------------------------------------------------------------------ - - --~procedure draw_view (index : in enumeration; x, y : in integer) is - --~offset : constant integer := 4; - --~begin - --~core.draw (view (index), x + offset, y + offset); - --~ui.draw_icon_menu (x, y, view_width + 2 * offset, view_height + 2 * offset); - --~end draw_view; - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -end unit; diff --git a/source/unit.ads b/source/unit.ads index 9aeaa93..2bade59 100644 --- a/source/unit.ads +++ b/source/unit.ads @@ -68,14 +68,9 @@ package unit is equipment.steel_greaves, equipment.none, equipment.mithril_axe, equipment.steel_shield)) ); - ------------------------------------------------------------------------------------------ - - procedure configure; - - procedure draw (index : in enumeration; state : in core.animation; x, y : in integer); - - --~procedure draw_icon (index : in enumeration; x, y : in integer); - --~procedure draw_view (index : in enumeration; x, y : in integer); + base : array (faction.fairy .. faction.imp) of core.sprite; + --~icon : array (faction.fairy .. faction.imp) of core.sprite; + --~view : array (faction.fairy .. faction.imp) of core.sprite; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index 233bd16..4d3eb89 100644 --- a/source/world.adb +++ b/source/world.adb @@ -383,10 +383,17 @@ package body world is if map.views (map.units (index).x, map.units (index).y) and map.units (index).x > view_from.x and map.units (index).x < view_from.x + view_to.x and map.units (index).y > view_from.y and map.units (index).y < view_from.y + view_to.y then - unit.draw (unit.enumeration'val (map.units (index).index), - core.animation'val (map.units (index).state), - offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, - offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom); + core.draw (data => unit.base (unit.description (unit.enumeration'val (map.units (index).index)).kind), + x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, + y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom, + state => core.animation'val (map.units (index).state)); + -- + for slot in equipment.slot loop + core.draw (data => equipment.sprite (unit.description (unit.enumeration'val (map.units (index).index)).equipments (slot)), + x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, + y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom, + state => core.animation'val (map.units (index).state)); + end loop; -- core.increment (drawn_units); end if;