Refactored landmarks...
This commit is contained in:
parent
a8fe5c2333
commit
1e75a583e4
@ -25,6 +25,14 @@ package landmark is
|
|||||||
frames : integer;
|
frames : integer;
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
|
type information is record
|
||||||
|
index : enumeration;
|
||||||
|
x : integer;
|
||||||
|
y : integer;
|
||||||
|
end record;
|
||||||
|
|
||||||
|
type informations is array (natural range <>) of information;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
count : constant natural := enumeration'pos (enumeration'last) + 1;
|
count : constant natural := enumeration'pos (enumeration'last) + 1;
|
||||||
|
@ -137,15 +137,15 @@ package body world is
|
|||||||
map.chad_limit := chad_limit;
|
map.chad_limit := chad_limit;
|
||||||
map.chad_count := 0;
|
map.chad_count := 0;
|
||||||
--
|
--
|
||||||
map.tiles := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
map.tiles := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||||
map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||||
map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||||
map.landmarks := new entity_array (1 .. landmark_limit);
|
map.landmarks := new landmark.informations (1 .. landmark_limit);
|
||||||
map.locations := new entity_array (1 .. location_limit);
|
map.locations := new entity_array (1 .. location_limit);
|
||||||
map.constructions := new entity_array (1 .. construction_limit);
|
map.constructions := new entity_array (1 .. construction_limit);
|
||||||
map.equipments := new entity_array (1 .. equipment_limit);
|
map.equipments := new entity_array (1 .. equipment_limit);
|
||||||
map.units := new entity_array (1 .. unit_limit);
|
map.units := new entity_array (1 .. unit_limit);
|
||||||
map.chads := new chad.informations (1 .. map.chad_limit);
|
map.chads := new chad.informations (1 .. map.chad_limit);
|
||||||
--
|
--
|
||||||
for x in 0 .. width - 1 loop
|
for x in 0 .. width - 1 loop
|
||||||
for y in 0 .. height - 1 loop
|
for y in 0 .. height - 1 loop
|
||||||
@ -172,8 +172,7 @@ package body world is
|
|||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
for index in 1 .. landmark_limit loop
|
for index in 1 .. landmark_limit loop
|
||||||
map.landmarks (index).index := core.random (0, landmark.count - 1);
|
map.landmarks (index).index := landmark.enumeration'val (core.random (0, landmark.count - 1));
|
||||||
map.landmarks (index).state := 0;
|
|
||||||
<<repeat_landmark_generation>>
|
<<repeat_landmark_generation>>
|
||||||
map.landmarks (index).x := core.random (6, map.width - 6);
|
map.landmarks (index).x := core.random (6, map.width - 6);
|
||||||
map.landmarks (index).y := core.random (6, map.height - 6);
|
map.landmarks (index).y := core.random (6, map.height - 6);
|
||||||
@ -182,9 +181,9 @@ package body world is
|
|||||||
goto repeat_landmark_generation;
|
goto repeat_landmark_generation;
|
||||||
end if;
|
end if;
|
||||||
--
|
--
|
||||||
if landmark.description (landmark.enumeration'val (map.landmarks (index).index)).clip then
|
if landmark.description (map.landmarks (index).index).clip then
|
||||||
declare reach_x : constant natural := landmark.game (landmark.enumeration'val (map.landmarks (index).index)).width / core.base;
|
declare reach_x : constant natural := landmark.game (map.landmarks (index).index).width / core.base;
|
||||||
reach_y : constant natural := landmark.game (landmark.enumeration'val (map.landmarks (index).index)).height / core.base;
|
reach_y : constant natural := landmark.game (map.landmarks (index).index).height / core.base;
|
||||||
begin
|
begin
|
||||||
for x in 0 .. reach_x - 1 loop
|
for x in 0 .. reach_x - 1 loop
|
||||||
for y in 0 .. reach_y - 1 loop
|
for y in 0 .. reach_y - 1 loop
|
||||||
@ -273,7 +272,7 @@ package body world is
|
|||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure save (file_name : in string) is
|
procedure save (file_name : in string) is
|
||||||
procedure save_entity (here : in core.io.file_type; data : in entity_description) is
|
procedure save_entity (here : in core.io.file_type; data : in entity) is
|
||||||
begin
|
begin
|
||||||
core.io.write (here, data.index);
|
core.io.write (here, data.index);
|
||||||
core.io.write (here, data.state);
|
core.io.write (here, data.state);
|
||||||
@ -299,7 +298,9 @@ package body world is
|
|||||||
end loop;
|
end loop;
|
||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
for index in 1 .. landmark_limit loop save_entity (file, map.landmarks (index)); end loop;
|
for index in 1 .. landmark_limit loop core.io.write (file, landmark.enumeration'pos (map.landmarks (index).index)); 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;
|
||||||
for index in 1 .. location_limit loop save_entity (file, map.locations (index)); end loop;
|
for index in 1 .. location_limit loop save_entity (file, map.locations (index)); end loop;
|
||||||
for index in 1 .. construction_limit loop save_entity (file, map.constructions (index)); end loop;
|
for index in 1 .. construction_limit loop save_entity (file, map.constructions (index)); end loop;
|
||||||
for index in 1 .. equipment_limit loop save_entity (file, map.equipments (index)); end loop;
|
for index in 1 .. equipment_limit loop save_entity (file, map.equipments (index)); end loop;
|
||||||
@ -348,7 +349,7 @@ package body world is
|
|||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure load (file_name : in string) is
|
procedure load (file_name : in string) is
|
||||||
procedure load_entity (here : in core.io.file_type; data : out entity_description) is
|
procedure load_entity (here : in core.io.file_type; data : out entity) is
|
||||||
begin
|
begin
|
||||||
core.io.read (here, data.index);
|
core.io.read (here, data.index);
|
||||||
core.io.read (here, data.state);
|
core.io.read (here, data.state);
|
||||||
@ -375,7 +376,9 @@ package body world is
|
|||||||
end loop;
|
end loop;
|
||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
for index in 1 .. landmark_limit loop load_entity (file, map.landmarks (index)); end loop;
|
for index in 1 .. landmark_limit loop core.io.read (file, this); map.landmarks (index).index := landmark.enumeration'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;
|
||||||
for index in 1 .. location_limit loop load_entity (file, map.locations (index)); end loop;
|
for index in 1 .. location_limit loop load_entity (file, map.locations (index)); end loop;
|
||||||
for index in 1 .. construction_limit loop load_entity (file, map.constructions (index)); end loop;
|
for index in 1 .. construction_limit loop load_entity (file, map.constructions (index)); end loop;
|
||||||
for index in 1 .. equipment_limit loop load_entity (file, map.equipments (index)); end loop;
|
for index in 1 .. equipment_limit loop load_entity (file, map.equipments (index)); end loop;
|
||||||
@ -513,13 +516,13 @@ package body world is
|
|||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
for index in 1 .. landmark_limit loop
|
for index in 1 .. landmark_limit loop
|
||||||
core.render_image (data => landmark.game (landmark.enumeration'val (map.landmarks (index).index)),
|
core.render_image (data => landmark.game (map.landmarks (index).index),
|
||||||
x => map.landmarks (index).x * core.base,
|
x => map.landmarks (index).x * core.base,
|
||||||
y => map.landmarks (index).y * core.base,
|
y => map.landmarks (index).y * core.base,
|
||||||
u => 0,
|
u => 0,
|
||||||
v => 0,
|
v => 0,
|
||||||
width => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).width,
|
width => landmark.game (map.landmarks (index).index).width,
|
||||||
height => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).height);
|
height => landmark.game (map.landmarks (index).index).height);
|
||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
for index in 1 .. location_limit loop
|
for index in 1 .. location_limit loop
|
||||||
@ -846,7 +849,7 @@ package body world is
|
|||||||
if map.views (map.landmarks (index).x, map.landmarks (index).y)
|
if map.views (map.landmarks (index).x, map.landmarks (index).y)
|
||||||
and map.landmarks (index).x > view_from.x and map.landmarks (index).x < view_from.x + view_to.x
|
and map.landmarks (index).x > view_from.x and map.landmarks (index).x < view_from.x + view_to.x
|
||||||
and map.landmarks (index).y > view_from.y and map.landmarks (index).y < view_from.y + view_to.y then
|
and map.landmarks (index).y > view_from.y and map.landmarks (index).y < view_from.y + view_to.y then
|
||||||
core.draw (data => landmark.game (landmark.enumeration'val (map.landmarks (index).index)),
|
core.draw (data => landmark.game (map.landmarks (index).index),
|
||||||
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
||||||
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
|
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
|
||||||
--
|
--
|
||||||
@ -854,11 +857,11 @@ package body world is
|
|||||||
--
|
--
|
||||||
if core.cursor_inside (x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
if core.cursor_inside (x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
||||||
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom,
|
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom,
|
||||||
width => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).width,
|
width => landmark.game (map.landmarks (index).index).width,
|
||||||
height => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).height)
|
height => landmark.game (map.landmarks (index).index).height)
|
||||||
and core.cursor_mode = core.cursor_middle
|
and core.cursor_mode = core.cursor_middle
|
||||||
and not ui.prioritize then
|
and not ui.prioritize then
|
||||||
core.write_text_box (landmark.description (landmark.enumeration'val (map.landmarks (index).index)).name.all);
|
core.write_text_box (landmark.description (map.landmarks (index).index).name.all);
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end loop;
|
end loop;
|
||||||
|
@ -12,7 +12,7 @@ package world is
|
|||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
type entity_description is record
|
type entity is record
|
||||||
index : natural;
|
index : natural;
|
||||||
state : natural;
|
state : natural;
|
||||||
x, y : integer;
|
x, y : integer;
|
||||||
@ -20,7 +20,7 @@ package world is
|
|||||||
|
|
||||||
type integer_matrix is array (natural range <>, natural range <>) of integer;
|
type integer_matrix is array (natural range <>, natural range <>) of integer;
|
||||||
type boolean_matrix is array (natural range <>, natural range <>) of boolean;
|
type boolean_matrix is array (natural range <>, natural range <>) of boolean;
|
||||||
type entity_array is array (natural range <>) of entity_description;
|
type entity_array is array (natural range <>) of entity;
|
||||||
|
|
||||||
type definition is record
|
type definition is record
|
||||||
kind : biome.enumeration;
|
kind : biome.enumeration;
|
||||||
@ -31,7 +31,7 @@ package world is
|
|||||||
tiles : access integer_matrix;
|
tiles : access integer_matrix;
|
||||||
clips : access boolean_matrix;
|
clips : access boolean_matrix;
|
||||||
views : access boolean_matrix;
|
views : access boolean_matrix;
|
||||||
landmarks : access entity_array;
|
landmarks : access landmark.informations;
|
||||||
locations : access entity_array;
|
locations : access entity_array;
|
||||||
constructions : access entity_array;
|
constructions : access entity_array;
|
||||||
equipments : access entity_array;
|
equipments : access entity_array;
|
||||||
|
Loading…
Reference in New Issue
Block a user