mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -281,7 +281,7 @@ class TilemapRenderer
|
||||
@tiles_horizontal_count.times do |i|
|
||||
@tiles[i] = []
|
||||
@tiles_vertical_count.times do |j|
|
||||
@tiles[i][j] = Array.new(3) { TileSprite.new(@viewport) }
|
||||
@tiles[i][j] = Array.new(3) { TileSprite.new(@viewport) }
|
||||
end
|
||||
end
|
||||
@current_map_id = 0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class TilemapRenderer
|
||||
module AutotileExpander
|
||||
MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024
|
||||
MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024
|
||||
|
||||
module_function
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ class TileDrawingHelper
|
||||
36, 24, 36, 24, 21, 6, 21, 4, 36, 24, 36, 24, 20, 2, 20, 0
|
||||
]
|
||||
|
||||
def self.tableNeighbors(data,x,y)
|
||||
def self.tableNeighbors(data, x, y)
|
||||
return 0 if x < 0 || x >= data.xsize
|
||||
return 0 if y < 0 || y >= data.ysize
|
||||
t = data[x,y]
|
||||
t = data[x, y]
|
||||
xp1 = [x + 1, data.xsize - 1].min
|
||||
yp1 = [y + 1, data.ysize - 1].min
|
||||
xm1 = [x - 1, 0].max
|
||||
@@ -58,12 +58,12 @@ class TileDrawingHelper
|
||||
end
|
||||
|
||||
def self.fromTileset(tileset)
|
||||
bmtileset=pbGetTileset(tileset.tileset_name)
|
||||
bmautotiles=[]
|
||||
bmtileset = pbGetTileset(tileset.tileset_name)
|
||||
bmautotiles = []
|
||||
for i in 0...7
|
||||
bmautotiles.push(pbGetAutotile(tileset.autotile_names[i]))
|
||||
end
|
||||
return self.new(bmtileset,bmautotiles)
|
||||
return self.new(bmtileset, bmautotiles)
|
||||
end
|
||||
|
||||
def initialize(tileset, autotiles)
|
||||
@@ -87,7 +87,7 @@ class TileDrawingHelper
|
||||
end
|
||||
end
|
||||
|
||||
def bltSmallAutotile(bitmap,x,y,cxTile,cyTile,id,frame)
|
||||
def bltSmallAutotile(bitmap, x, y, cxTile, cyTile, id, frame)
|
||||
return if id >= 384 || frame < 0 || !@autotiles
|
||||
autotile = @autotiles[id / 48 - 1]
|
||||
return if !autotile || autotile.disposed?
|
||||
@@ -111,14 +111,14 @@ class TileDrawingHelper
|
||||
end
|
||||
end
|
||||
|
||||
def bltSmallRegularTile(bitmap,x,y,cxTile,cyTile,id)
|
||||
def bltSmallRegularTile(bitmap, x, y, cxTile, cyTile, id)
|
||||
return if id < 384 || !@tileset || @tileset.disposed?
|
||||
rect = Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
|
||||
rect = TilemapRenderer::TilesetWrapper.getWrappedRect(rect) if @shouldWrap
|
||||
bitmap.stretch_blt(Rect.new(x, y, cxTile, cyTile), @tileset, rect)
|
||||
end
|
||||
|
||||
def bltSmallTile(bitmap,x,y,cxTile,cyTile,id,frame = 0)
|
||||
def bltSmallTile(bitmap, x, y, cxTile, cyTile, id, frame = 0)
|
||||
if id >= 384
|
||||
bltSmallRegularTile(bitmap, x, y, cxTile, cyTile, id)
|
||||
elsif id > 0
|
||||
@@ -126,15 +126,15 @@ class TileDrawingHelper
|
||||
end
|
||||
end
|
||||
|
||||
def bltAutotile(bitmap,x,y,id,frame)
|
||||
def bltAutotile(bitmap, x, y, id, frame)
|
||||
bltSmallAutotile(bitmap, x, y, 32, 32, id, frame)
|
||||
end
|
||||
|
||||
def bltRegularTile(bitmap,x,y,id)
|
||||
def bltRegularTile(bitmap, x, y, id)
|
||||
bltSmallRegularTile(bitmap, x, y, 32, 32, id)
|
||||
end
|
||||
|
||||
def bltTile(bitmap,x,y,id,frame = 0)
|
||||
def bltTile(bitmap, x, y, id, frame = 0)
|
||||
if id >= 384
|
||||
bltRegularTile(bitmap, x, y, id)
|
||||
elsif id > 0
|
||||
@@ -147,79 +147,79 @@ end
|
||||
#
|
||||
#===============================================================================
|
||||
def createMinimap(mapid)
|
||||
map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) rescue nil
|
||||
return BitmapWrapper.new(32,32) if !map
|
||||
bitmap=BitmapWrapper.new(map.width*4,map.height*4)
|
||||
black=Color.new(0,0,0)
|
||||
tilesets=$data_tilesets
|
||||
tileset=tilesets[map.tileset_id]
|
||||
map = load_data(sprintf("Data/Map%03d.rxdata", mapid)) rescue nil
|
||||
return BitmapWrapper.new(32, 32) if !map
|
||||
bitmap = BitmapWrapper.new(map.width * 4, map.height * 4)
|
||||
black = Color.new(0, 0, 0)
|
||||
tilesets = $data_tilesets
|
||||
tileset = tilesets[map.tileset_id]
|
||||
return bitmap if !tileset
|
||||
helper=TileDrawingHelper.fromTileset(tileset)
|
||||
helper = TileDrawingHelper.fromTileset(tileset)
|
||||
for y in 0...map.height
|
||||
for x in 0...map.width
|
||||
for z in 0..2
|
||||
id=map.data[x,y,z]
|
||||
id=0 if !id
|
||||
helper.bltSmallTile(bitmap,x*4,y*4,4,4,id)
|
||||
id = map.data[x, y, z]
|
||||
id = 0 if !id
|
||||
helper.bltSmallTile(bitmap, x * 4, y * 4, 4, 4, id)
|
||||
end
|
||||
end
|
||||
end
|
||||
bitmap.fill_rect(0,0,bitmap.width,1,black)
|
||||
bitmap.fill_rect(0,bitmap.height-1,bitmap.width,1,black)
|
||||
bitmap.fill_rect(0,0,1,bitmap.height,black)
|
||||
bitmap.fill_rect(bitmap.width-1,0,1,bitmap.height,black)
|
||||
bitmap.fill_rect(0, 0, bitmap.width, 1, black)
|
||||
bitmap.fill_rect(0, bitmap.height - 1, bitmap.width, 1, black)
|
||||
bitmap.fill_rect(0, 0, 1, bitmap.height, black)
|
||||
bitmap.fill_rect(bitmap.width - 1, 0, 1, bitmap.height, black)
|
||||
return bitmap
|
||||
end
|
||||
|
||||
def bltMinimapAutotile(dstBitmap,x,y,srcBitmap,id)
|
||||
return if id>=48 || !srcBitmap || srcBitmap.disposed?
|
||||
anim=0
|
||||
cxTile=3
|
||||
cyTile=3
|
||||
tiles = TileDrawingHelper::AUTOTILE_PATTERNS[id>>3][id&7]
|
||||
src=Rect.new(0,0,0,0)
|
||||
def bltMinimapAutotile(dstBitmap, x, y, srcBitmap, id)
|
||||
return if id >= 48 || !srcBitmap || srcBitmap.disposed?
|
||||
anim = 0
|
||||
cxTile = 3
|
||||
cyTile = 3
|
||||
tiles = TileDrawingHelper::AUTOTILE_PATTERNS[id >> 3][id & 7]
|
||||
src = Rect.new(0, 0, 0, 0)
|
||||
for i in 0...4
|
||||
tile_position = tiles[i] - 1
|
||||
src.set(
|
||||
tile_position % 6 * cxTile + anim,
|
||||
tile_position / 6 * cyTile, cxTile, cyTile)
|
||||
dstBitmap.blt(i%2*cxTile+x,i/2*cyTile+y, srcBitmap, src)
|
||||
dstBitmap.blt(i % 2 * cxTile + x, i / 2 * cyTile + y, srcBitmap, src)
|
||||
end
|
||||
end
|
||||
|
||||
def passable?(passages,tile_id)
|
||||
def passable?(passages, tile_id)
|
||||
return false if tile_id == nil
|
||||
passage = passages[tile_id]
|
||||
return (passage && passage<15)
|
||||
return (passage && passage < 15)
|
||||
end
|
||||
|
||||
# Unused
|
||||
def getPassabilityMinimap(mapid)
|
||||
map = load_data(sprintf("Data/Map%03d.rxdata",mapid))
|
||||
map = load_data(sprintf("Data/Map%03d.rxdata", mapid))
|
||||
tileset = $data_tilesets[map.tileset_id]
|
||||
minimap = AnimatedBitmap.new("Graphics/Pictures/minimap_tiles")
|
||||
ret = Bitmap.new(map.width*6,map.height*6)
|
||||
passtable = Table.new(map.width,map.height)
|
||||
ret = Bitmap.new(map.width * 6, map.height * 6)
|
||||
passtable = Table.new(map.width, map.height)
|
||||
passages = tileset.passages
|
||||
for i in 0...map.width
|
||||
for j in 0...map.height
|
||||
pass=true
|
||||
for z in [2,1,0]
|
||||
if !passable?(passages,map.data[i,j,z])
|
||||
pass=false
|
||||
pass = true
|
||||
for z in [2, 1, 0]
|
||||
if !passable?(passages, map.data[i, j, z])
|
||||
pass = false
|
||||
break
|
||||
end
|
||||
end
|
||||
passtable[i,j]=pass ? 1 : 0
|
||||
passtable[i, j] = pass ? 1 : 0
|
||||
end
|
||||
end
|
||||
neighbors=TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX
|
||||
neighbors = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX
|
||||
for i in 0...map.width
|
||||
for j in 0...map.height
|
||||
if passtable[i,j]==0
|
||||
nb=TileDrawingHelper.tableNeighbors(passtable,i,j)
|
||||
tile=neighbors[nb]
|
||||
bltMinimapAutotile(ret,i*6,j*6,minimap.bitmap,tile)
|
||||
if passtable[i, j] == 0
|
||||
nb = TileDrawingHelper.tableNeighbors(passtable, i, j)
|
||||
tile = neighbors[nb]
|
||||
bltMinimapAutotile(ret, i * 6, j * 6, minimap.bitmap, tile)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user