blob: dc1092eeed0c4a13959ac1d0dbc1abc5c0286b5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# frozen_string_literal: true
class Systems
class Render
def self.run
Components::Renderable.data.sort_by { |v| v[1].z }.each do |key, _data|
if !(Components::Sprite.id & Entity.signatures[key]).zero?
$gtk.args.outputs.sprites << Components::Sprite.data[key].set
elsif !(Components::Label.id & Entity.signatures[key]).zero?
$gtk.args.outputs.labels << Components::Label.data[key].set
elsif !(Components::Map.id & Entity.signatures[key]).zero?
Components::Map.data[key].json['layers'].each do |layer|
layer['chunks'].each do |chunk|
chunk['data'].each_slice(chunk['width']).with_index do |row, row_index|
row.each_with_index do |tile, column_index|
next if tile.zero?
iter = 0
loop do
tile = Helper.get_tile(
json_name: Components::Map.data[key].json['tilesets'][iter]['source'].split('/').last.delete('\\').delete_suffix('.tsx'), tile_index: tile
)
break if tile.is_a?(Hash)
if (iter += 1) >= Components::Map.data[key].json['tilesets'].count
raise StandardError,
"#{Components::Map.data[key].json["json_name"]} not valid map, exceeded tile range"
end
end
next if tile.empty?
tile[:x] =
Components::Map.data[key].x + (Components::Map.data[key].tilewidth * column_index) + chunk['x']
tile[:y] =
Components::Map.data[key].y + (Components::Map.data[key].tileheight * row_index) + chunk['y']
tile[:w] = Components::Map.data[key].tilewidth
tile[:h] = Components::Map.data[key].tileheight
$gtk.args.outputs.sprites << tile
end
end
end
end
end
end
end
end
end
|