diff --git a/source/main.adb b/source/main.adb index df9d3a3..dcab674 100644 --- a/source/main.adb +++ b/source/main.adb @@ -426,7 +426,7 @@ begin --~core.cursor_mode := core.cursor_none; - --~world.load ("heyo"); + world.load ("heyo"); ui.active := ui.style'val (faction.enumeration'pos (chad.description (player.index).kind) + 1); diff --git a/source/unit.ads b/source/unit.ads index 243a479..78294b6 100644 --- a/source/unit.ads +++ b/source/unit.ads @@ -31,6 +31,16 @@ package unit is equipments : equipment.equip_array := equipment.default; end record; + type information is record + index : enumeration; + count : natural; + enemy : boolean; + x : integer; + y : integer; + end record; + + type informations is array (natural range <>) of information; + type point is record index : enumeration := none; value : natural := 0; diff --git a/source/world.adb b/source/world.adb index e06248a..f530964 100644 --- a/source/world.adb +++ b/source/world.adb @@ -144,7 +144,7 @@ package body world is map.locations := new location.informations (1 .. location_limit); map.constructions := new construction.informations (1 .. construction_limit); map.equipments := new equipment.informations (1 .. equipment_limit); - map.units := new entity_array (1 .. unit_limit); + map.units := new unit.informations (1 .. unit_limit); map.chads := new chad.informations (1 .. map.chad_limit); -- for x in 0 .. width - 1 loop @@ -251,11 +251,12 @@ package body world is end loop; -- for index in 1 .. unit_limit loop - map.units (index).index := core.random (1, unit.count - 1); - map.units (index).state := 0; + map.units (index).index := unit.enumeration'val (core.random (1, unit.count - 1)); -- none + map.units (index).count := core.random (1, 10); + map.units (index).enemy := true; <> - map.units (index).x := core.random (0, map.width - 1); - map.units (index).y := core.random (0, map.height - 1); + map.units (index).x := core.random (0, map.width - 1); + map.units (index).y := core.random (0, map.height - 1); -- if map.clips (map.units (index).x, map.units (index).y) then goto repeat_unit_generation; @@ -270,14 +271,6 @@ package body world is ------------------------------------------------------------------------------------------ procedure save (file_name : in string) is - procedure save_entity (here : in core.io.file_type; data : in entity) is - begin - core.io.write (here, data.index); - core.io.write (here, data.state); - core.io.write (here, data.x); - core.io.write (here, data.y); - end save_entity; - -- file : core.io.file_type; begin core.io.create (file, core.io.out_file, core.folder & "/map/" & file_name); @@ -300,8 +293,11 @@ package body world is for index in 1 .. location_limit loop core.io.write (file, location.enumeration'pos (map.locations (index).index)); end loop; for index in 1 .. construction_limit loop core.io.write (file, construction.enumeration'pos (map.constructions (index).index)); end loop; for index in 1 .. equipment_limit loop core.io.write (file, equipment.enumeration'pos (map.equipments (index).index)); end loop; + for index in 1 .. unit_limit loop core.io.write (file, unit.enumeration'pos (map.units (index).index)); end loop; -- - for index in 1 .. location_limit loop core.io.write (file, boolean'pos (map.locations (index).used)); end loop; + for index in 1 .. location_limit loop core.io.write (file, boolean'pos (map.locations (index).used)); end loop; + for index in 1 .. unit_limit loop core.io.write (file, map.units (index).count); end loop; + for index in 1 .. unit_limit loop core.io.write (file, boolean'pos (map.units (index).enemy)); end loop; -- for index in 1 .. landmark_limit loop core.io.write (file, map.landmarks (index).x); end loop; for index in 1 .. landmark_limit loop core.io.write (file, map.landmarks (index).y); end loop; @@ -309,9 +305,10 @@ package body world is for index in 1 .. location_limit loop core.io.write (file, map.locations (index).y); end loop; for index in 1 .. construction_limit loop core.io.write (file, map.constructions (index).x); end loop; for index in 1 .. construction_limit loop core.io.write (file, map.constructions (index).y); end loop; - for index in 1 .. equipment_limit loop core.io.write (file, map.equipments (index).x); end loop; - for index in 1 .. equipment_limit loop core.io.write (file, map.equipments (index).y); end loop; - for index in 1 .. unit_limit loop save_entity (file, map.units (index)); end loop; + for index in 1 .. equipment_limit loop core.io.write (file, map.equipments (index).x); end loop; + for index in 1 .. equipment_limit loop core.io.write (file, map.equipments (index).y); end loop; + for index in 1 .. unit_limit loop core.io.write (file, map.units (index).x); end loop; + for index in 1 .. unit_limit loop core.io.write (file, map.units (index).y); end loop; -- core.io.write (file, chad.enumeration'pos (map.chads (1).index)); core.io.write (file, core.animation'pos (map.chads (1).state)); @@ -356,14 +353,6 @@ package body world is ------------------------------------------------------------------------------------------ procedure load (file_name : in string) is - procedure load_entity (here : in core.io.file_type; data : out entity) is - begin - core.io.read (here, data.index); - core.io.read (here, data.state); - core.io.read (here, data.x); - core.io.read (here, data.y); - end load_entity; - -- file : core.io.file_type; this : integer; begin @@ -387,8 +376,11 @@ package body world is for index in 1 .. location_limit loop core.io.read (file, this); map.locations (index).index := location.enumeration'val (this); end loop; for index in 1 .. construction_limit loop core.io.read (file, this); map.constructions (index).index := construction.enumeration'val (this); end loop; for index in 1 .. equipment_limit loop core.io.read (file, this); map.equipments (index).index := equipment.enumeration'val (this); end loop; + for index in 1 .. unit_limit loop core.io.read (file, this); map.units (index).index := unit.enumeration'val (this); end loop; -- - for index in 1 .. location_limit loop core.io.read (file, this); map.locations (index).used := boolean'val (this); end loop; + for index in 1 .. location_limit loop core.io.read (file, this); map.locations (index).used := boolean'val (this); end loop; + for index in 1 .. unit_limit loop core.io.read (file, this); map.units (index).count := this; end loop; + for index in 1 .. unit_limit loop core.io.read (file, this); map.units (index).enemy := boolean'val (this); end loop; -- for index in 1 .. landmark_limit loop core.io.read (file, map.landmarks (index).x); end loop; for index in 1 .. landmark_limit loop core.io.read (file, map.landmarks (index).y); end loop; @@ -398,8 +390,8 @@ package body world is for index in 1 .. construction_limit loop core.io.read (file, map.constructions (index).y); end loop; for index in 1 .. equipment_limit loop core.io.read (file, map.equipments (index).x); end loop; for index in 1 .. equipment_limit loop core.io.read (file, map.equipments (index).y); end loop; - -- - for index in 1 .. unit_limit loop load_entity (file, map.units (index)); end loop; + for index in 1 .. unit_limit loop core.io.read (file, map.units (index).x); end loop; + for index in 1 .. unit_limit loop core.io.read (file, map.units (index).y); end loop; -- core.io.read (file, this); map.chads (1).index := chad.enumeration'val (this); core.io.read (file, this); map.chads (1).state := core.animation'val (this); @@ -1111,8 +1103,8 @@ 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 - draw_unit (data => unit.enumeration'val (map.units (index).index), - state => core.animation'val (map.units (index).state), + draw_unit (data => map.units (index).index, + state => core.idle, 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, factor => core.zoom); diff --git a/source/world.ads b/source/world.ads index a8d757f..b4589d6 100644 --- a/source/world.ads +++ b/source/world.ads @@ -12,15 +12,8 @@ package world is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - type entity is record - index : natural; - state : natural; - x, y : integer; - end record; - type integer_matrix is array (natural range <>, natural range <>) of integer; type boolean_matrix is array (natural range <>, natural range <>) of boolean; - type entity_array is array (natural range <>) of entity; type definition is record kind : biome.enumeration; @@ -35,7 +28,7 @@ package world is locations : access location.informations; constructions : access construction.informations; equipments : access equipment.informations; - units : access entity_array; + units : access unit.informations; chads : access chad.informations; end record;