Tilemap layer being removed after calling force_update

I am attempting to set_custom_data for every tile a building touches on my tilemap. when I call force_update(0) in my runtime update func, it removes the layer completely. I am simplying modulating the tiles for debug purposes, the goal is to create a dictionary of tiles with the has_building custom data

GameManager.gd

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>func create_warren(location : Vector2):
var local_pos = tile_map.local_to_map(location)
var tileset_source_id = 6
var atlas_coords = Vector2i(0, 0)
var buildings_layer = 5
# add building to tilemap
tile_map.set_cell(buildings_layer, local_pos, tileset_source_id, atlas_coords)
var ground_layer = 0
var tile_data : TileData = tile_map.get_cell_tile_data(ground_layer, local_pos)
# set has_building for every tile the building touches
var i = -5
while i < 5:
var l = local_pos
l.x += i
print(str(l))
var next_tile_data : TileData = tile_map.get_cell_tile_data(ground_layer, l)
if next_tile_data:
tile_map.add_modulated_cell(l)
# trigger TileMap._tile_data_runtime_update
next_tile_data.set_custom_data(tile_has_building, true)
i += 1
</code>
<code>func create_warren(location : Vector2): var local_pos = tile_map.local_to_map(location) var tileset_source_id = 6 var atlas_coords = Vector2i(0, 0) var buildings_layer = 5 # add building to tilemap tile_map.set_cell(buildings_layer, local_pos, tileset_source_id, atlas_coords) var ground_layer = 0 var tile_data : TileData = tile_map.get_cell_tile_data(ground_layer, local_pos) # set has_building for every tile the building touches var i = -5 while i < 5: var l = local_pos l.x += i print(str(l)) var next_tile_data : TileData = tile_map.get_cell_tile_data(ground_layer, l) if next_tile_data: tile_map.add_modulated_cell(l) # trigger TileMap._tile_data_runtime_update next_tile_data.set_custom_data(tile_has_building, true) i += 1 </code>
func create_warren(location : Vector2):
    var local_pos = tile_map.local_to_map(location)
    var tileset_source_id = 6
    var atlas_coords = Vector2i(0, 0)
    var buildings_layer = 5
    
  # add building to tilemap
    tile_map.set_cell(buildings_layer, local_pos, tileset_source_id, atlas_coords)
    
    var ground_layer = 0
    var tile_data : TileData = tile_map.get_cell_tile_data(ground_layer, local_pos)

    # set has_building for every tile the building touches
    var i = -5
    while i < 5:
        var l = local_pos
        l.x += i
        print(str(l))
        var next_tile_data : TileData = tile_map.get_cell_tile_data(ground_layer, l)
        if next_tile_data:
            tile_map.add_modulated_cell(l)
            # trigger TileMap._tile_data_runtime_update
            next_tile_data.set_custom_data(tile_has_building, true)
        i += 1

TileMap.gd

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>extends TileMap
var modulated_cells : Dictionary
func add_modulated_cell(v : Vector2i):
modulated_cells[v] = Color.DARK_RED
func _ready():
pass
func _use_tile_data_runtime_update(layer, coords):
var r = modulated_cells.has(coords)
return r
func _tile_data_runtime_update(layer, coords, tile_data):
if layer == 1:
var color = modulated_cells.get(coords)
tile_data.modulate = color
force_update(0) # removes my layer 0 while also modulating somehow
print_debug(str(tile_data.get_custom_data("has_building"))) # returns false somehow
</code>
<code>extends TileMap var modulated_cells : Dictionary func add_modulated_cell(v : Vector2i): modulated_cells[v] = Color.DARK_RED func _ready(): pass func _use_tile_data_runtime_update(layer, coords): var r = modulated_cells.has(coords) return r func _tile_data_runtime_update(layer, coords, tile_data): if layer == 1: var color = modulated_cells.get(coords) tile_data.modulate = color force_update(0) # removes my layer 0 while also modulating somehow print_debug(str(tile_data.get_custom_data("has_building"))) # returns false somehow </code>
extends TileMap

var modulated_cells : Dictionary

func add_modulated_cell(v : Vector2i):
    modulated_cells[v] = Color.DARK_RED

func _ready():
    pass
    
func _use_tile_data_runtime_update(layer, coords):
    var r = modulated_cells.has(coords)
    return r
    

func _tile_data_runtime_update(layer, coords, tile_data):
    if layer == 1:
        var color = modulated_cells.get(coords)
        tile_data.modulate = color
        force_update(0) # removes my layer 0 while also modulating somehow
        print_debug(str(tile_data.get_custom_data("has_building"))) # returns false somehow

after I call force_update my layer index 0 is removed completely revealing the tileset layers below.

calling force_update() removes every layer

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật