Refactored equpiments...

This commit is contained in:
Ognjen Milan Robovic 2024-06-10 04:25:10 -04:00
parent 363dd45d78
commit d5e8dd3dc8
4 changed files with 43 additions and 33 deletions

View File

@ -52,7 +52,14 @@ package equipment is
evoke : effect.information := effect.none;
end record;
type equip_array is array (kind) of enumeration;
type information is record
index : enumeration;
x : integer;
y : integer;
end record;
type informations is array (natural range <>) of information;
type equip_array is array (kind) of enumeration;
------------------------------------------------------------------------------------------
@ -213,9 +220,9 @@ package equipment is
staff_of_dark => (new string'("Staff of Dark"), off_hand, (1, 0, 2, 0, 0, 9), faction.goblin, effect.none)
);
sprite : array (enumeration) of core.sprite;
icon : array (enumeration) of core.sprite;
slot : array (kind) of core.sprite;
game : array (enumeration) of core.sprite;
icon : array (enumeration) of core.sprite;
slot : array (kind) of core.sprite;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -315,8 +315,8 @@ begin
declare folder : constant string := core.lowercase (equipment.kind'image (equipment.description (index).slot));
file : constant string := core.lowercase (equipment.enumeration'image (index));
begin
equipment.sprite (index) := core.import_sprite (core.folder & "/game/equipment/" & folder & "/" & file & ".png", 4, 6);
equipment.icon (index) := core.import_sprite (core.folder & "/icon/equipment/" & folder & "/" & file & ".png", 1, 1);
equipment.game (index) := core.import_sprite (core.folder & "/game/equipment/" & folder & "/" & file & ".png", 4, 6);
equipment.icon (index) := core.import_sprite (core.folder & "/icon/equipment/" & folder & "/" & file & ".png", 1, 1);
end;
end loop;
--

View File

@ -143,7 +143,7 @@ package body world is
map.landmarks := new landmark.informations (1 .. landmark_limit);
map.locations := new location.informations (1 .. location_limit);
map.constructions := new construction.informations (1 .. construction_limit);
map.equipments := new entity_array (1 .. equipment_limit);
map.equipments := new equipment.informations (1 .. equipment_limit);
map.units := new entity_array (1 .. unit_limit);
map.chads := new chad.informations (1 .. map.chad_limit);
--
@ -240,11 +240,10 @@ package body world is
end loop;
--
for index in 1 .. equipment_limit loop
map.equipments (index).index := core.random (0, equipment.count - 1);
map.equipments (index).state := 0;
map.equipments (index).index := equipment.enumeration'val (core.random (0, equipment.count - 1));
<<repeat_equipment_generation>>
map.equipments (index).x := core.random (0, map.width - 1);
map.equipments (index).y := core.random (0, map.height - 1);
map.equipments (index).x := core.random (0, map.width - 1);
map.equipments (index).y := core.random (0, map.height - 1);
--
if map.clips (map.equipments (index).x, map.equipments (index).y) then
goto repeat_equipment_generation;
@ -297,9 +296,10 @@ package body world is
end loop;
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 .. location_limit loop core.io.write (file, location.enumeration'pos (map.locations (index).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 .. 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 .. location_limit loop core.io.write (file, boolean'pos (map.locations (index).used)); end loop;
--
@ -309,8 +309,8 @@ 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 .. 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 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;
--
core.io.write (file, chad.enumeration'pos (map.chads (1).index));
@ -386,16 +386,19 @@ package body world is
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 .. 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 .. location_limit loop core.io.read (file, this); map.locations (index).used := 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;
for index in 1 .. location_limit loop core.io.read (file, map.locations (index).x); end loop;
for index in 1 .. location_limit loop core.io.read (file, map.locations (index).y); 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 core.io.read (file, map.locations (index).x); end loop;
for index in 1 .. location_limit loop core.io.read (file, map.locations (index).y); end loop;
for index in 1 .. construction_limit loop core.io.read (file, map.constructions (index).x); end loop;
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 .. 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 .. unit_limit loop load_entity (file, map.units (index)); end loop;
--
core.io.read (file, this); map.chads (1).index := chad.enumeration'val (this);
@ -560,13 +563,13 @@ package body world is
end loop;
--
for index in 1 .. equipment_limit loop
core.render_image (data => equipment.sprite (equipment.enumeration'val (map.equipments (index).index)),
core.render_image (data => equipment.game (map.equipments (index).index),
x => map.equipments (index).x * core.base,
y => map.equipments (index).y * core.base,
u => 0,
v => 0,
width => equipment.sprite (equipment.enumeration'val (map.equipments (index).index)).width,
height => equipment.sprite (equipment.enumeration'val (map.equipments (index).index)).height);
width => equipment.game (map.equipments (index).index).width,
height => equipment.game (map.equipments (index).index).height);
end loop;
--
core.export_image (file_path);
@ -1010,11 +1013,11 @@ package body world is
and map.equipments (index).y > view_from.y and map.equipments (index).y < view_from.y + view_to.y then
x := offset.x + (map.equipments (index).x - core.camera.x) * core.base * core.zoom;
y := offset.y + (map.equipments (index).y - core.camera.y) * core.base * core.zoom;
this := equipment.enumeration'val (map.equipments (index).index);
this := map.equipments (index).index;
--
core.draw (equipment.sprite (this), x, y, state => core.idle);
core.draw (equipment.game (this), x, y, state => core.idle);
--
if core.cursor_inside (x, y, equipment.sprite (this).width, equipment.sprite (this).height)
if core.cursor_inside (x, y, equipment.game (this).width, equipment.game (this).height)
and core.cursor_mode = core.cursor_middle
and equipment_valid (this)
and not ui.prioritize then
@ -1027,12 +1030,12 @@ package body world is
if map.equipments (index).x = core.camera.x
and map.equipments (index).y = core.camera.y
and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) then
if map.chads (1).item_count < chad.item_limit and equipment_valid (equipment.enumeration'val (map.equipments (index).index)) then
map.chads (1).items (map.chads (1).item_count) := equipment.enumeration'val (map.equipments (index).index);
if map.chads (1).item_count < chad.item_limit and equipment_valid (map.equipments (index).index) then
map.chads (1).items (map.chads (1).item_count) := map.equipments (index).index;
--
core.increment (map.chads (1).item_count);
--
map.equipments (index).index := equipment.enumeration'pos (equipment.none);
map.equipments (index).index := equipment.none;
end if;
end if;
end loop;
@ -1047,7 +1050,7 @@ package body world is
core.draw (unit.base (unit.description (data).kind), x, y, state => state, factor => factor);
--
for kind in equipment.kind loop
core.draw (equipment.sprite (unit.description (data).equipments (kind)), x, y, state => state, factor => factor);
core.draw (equipment.game (unit.description (data).equipments (kind)), x, y, state => state, factor => factor);
end loop;
end draw_unit;
@ -1126,7 +1129,7 @@ package body world is
state => map.chads (index).state);
--
for kind in equipment.kind loop
core.draw (data => equipment.sprite (map.chads (index).equipments (kind)),
core.draw (data => equipment.game (map.chads (index).equipments (kind)),
x => offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom,
state => map.chads (index).state);

View File

@ -34,7 +34,7 @@ package world is
landmarks : access landmark.informations;
locations : access location.informations;
constructions : access construction.informations;
equipments : access entity_array;
equipments : access equipment.informations;
units : access entity_array;
chads : access chad.informations;
end record;