Обновлено перемещение npc

This commit is contained in:
2024-12-08 15:05:33 +04:00
parent 62cf438b0d
commit d9aff4fdc4
8 changed files with 54 additions and 9 deletions

View File

@@ -22,13 +22,7 @@ func _ready() -> void:
func set_npc_target(npc: NPC, target: Vector2i):
var id_path = $"../TileMap".astar_grid.get_id_path(
$"../TileMap/ground".local_to_map(npc.global_position+$"../TileMap/ground".global_position),
target
).slice(1)
if not id_path.is_empty():
npc.id_path = id_path
npc.set_target(target)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:

View File

@@ -244,3 +244,9 @@ func weight(pos: Vector2i) -> int:
func update_astar_tile(pos: Vector2i):
astar_grid.set_point_solid(pos, not is_walkable(pos))
astar_grid.set_point_weight_scale(pos, weight(pos))
func check_indoors(pos: Vector2i) -> bool:
var layer = get_toplayer(pos)
var tiledata: TileData = layer.get_cell_tile_data(pos)
if tiledata != null: return tiledata.get_custom_data("indoors")
else: return false

View File

@@ -20,6 +20,7 @@ var lmb: bool
var rmb: bool
func _ready():
Engine.physics_ticks_per_second = 60
selection = SELECTION_SCENE.instantiate()
selection2 = SELECTION_SCENE.instantiate()
add_child(selection)

View File

@@ -852,14 +852,17 @@ texture = ExtResource("4_xeinu")
1:1/0/custom_data_3 = Vector2i(1, 1)
1:1/0/custom_data_4 = true
1:1/0/custom_data_5 = 1
1:1/0/custom_data_6 = true
2:1/0 = 0
2:1/0/custom_data_3 = Vector2i(0, 1)
2:1/0/custom_data_4 = true
2:1/0/custom_data_5 = 1
2:1/0/custom_data_6 = true
3:1/0 = 0
3:1/0/custom_data_3 = Vector2i(-1, 1)
3:1/0/custom_data_4 = true
3:1/0/custom_data_5 = 1
3:1/0/custom_data_6 = true
4:1/0 = 0
4:1/0/custom_data_3 = Vector2i(-1, 1)
4:1/0/custom_data_5 = 255
@@ -871,16 +874,19 @@ texture = ExtResource("4_xeinu")
1:2/0/custom_data_3 = Vector2i(1, 0)
1:2/0/custom_data_4 = true
1:2/0/custom_data_5 = 1
1:2/0/custom_data_6 = true
2:2/0 = 0
2:2/0/custom_data_0 = true
2:2/0/custom_data_1 = Vector2i(5, 5)
2:2/0/custom_data_2 = "EMPTY_ROOM"
2:2/0/custom_data_4 = true
2:2/0/custom_data_5 = 1
2:2/0/custom_data_6 = true
3:2/0 = 0
3:2/0/custom_data_3 = Vector2i(-1, 0)
3:2/0/custom_data_4 = true
3:2/0/custom_data_5 = 1
3:2/0/custom_data_6 = true
4:2/0 = 0
4:2/0/custom_data_3 = Vector2i(-1, 0)
4:2/0/custom_data_4 = true
@@ -892,14 +898,17 @@ texture = ExtResource("4_xeinu")
1:3/0/custom_data_3 = Vector2i(1, -1)
1:3/0/custom_data_4 = true
1:3/0/custom_data_5 = 1
1:3/0/custom_data_6 = true
2:3/0 = 0
2:3/0/custom_data_3 = Vector2i(0, -1)
2:3/0/custom_data_4 = true
2:3/0/custom_data_5 = 1
2:3/0/custom_data_6 = true
3:3/0 = 0
3:3/0/custom_data_3 = Vector2i(-1, -1)
3:3/0/custom_data_4 = true
3:3/0/custom_data_5 = 1
3:3/0/custom_data_6 = true
4:3/0 = 0
4:3/0/custom_data_3 = Vector2i(-1, -1)
4:3/0/custom_data_5 = 255
@@ -925,6 +934,7 @@ texture = ExtResource("4_xeinu")
1:5/0/custom_data_3 = Vector2i(0, 1)
1:5/0/custom_data_4 = true
1:5/0/custom_data_5 = 1
1:5/0/custom_data_6 = true
2:5/0 = 0
2:5/0/custom_data_3 = Vector2i(-1, 1)
2:5/0/custom_data_5 = 255
@@ -937,6 +947,7 @@ texture = ExtResource("4_xeinu")
1:6/0/custom_data_2 = "V_WAY"
1:6/0/custom_data_4 = true
1:6/0/custom_data_5 = 1
1:6/0/custom_data_6 = true
2:6/0 = 0
2:6/0/custom_data_3 = Vector2i(-1, 0)
2:6/0/custom_data_5 = 255
@@ -946,12 +957,14 @@ texture = ExtResource("4_xeinu")
3:6/0/custom_data_3 = Vector2i(1, 0)
3:6/0/custom_data_4 = true
3:6/0/custom_data_5 = 1
3:6/0/custom_data_6 = true
1:7/0 = 0
1:7/0/custom_data_0 = true
1:7/0/custom_data_1 = Vector2i(3, 1)
1:7/0/custom_data_3 = Vector2i(0, -1)
1:7/0/custom_data_4 = true
1:7/0/custom_data_5 = 1
1:7/0/custom_data_6 = true
2:7/0 = 0
2:7/0/custom_data_3 = Vector2i(-1, -1)
2:7/0/custom_data_5 = 255
@@ -976,6 +989,7 @@ texture = ExtResource("4_xeinu")
4:6/0/custom_data_2 = "H_WAY"
4:6/0/custom_data_4 = true
4:6/0/custom_data_5 = 1
4:6/0/custom_data_6 = true
4:5/0 = 0
4:5/0/custom_data_3 = Vector2i(0, 1)
4:5/0/custom_data_5 = 255
@@ -988,6 +1002,7 @@ texture = ExtResource("4_xeinu")
5:6/0/custom_data_3 = Vector2i(-1, 0)
5:6/0/custom_data_4 = true
5:6/0/custom_data_5 = 1
5:6/0/custom_data_6 = true
5:7/0 = 0
5:7/0/custom_data_3 = Vector2i(-1, -1)
5:7/0/custom_data_5 = 255
@@ -1012,6 +1027,8 @@ custom_data_layer_4/name = "walkable"
custom_data_layer_4/type = 1
custom_data_layer_5/name = "astar_weight"
custom_data_layer_5/type = 2
custom_data_layer_6/name = "indoors"
custom_data_layer_6/type = 1
sources/0 = SubResource("TileSetAtlasSource_fyh4j")
sources/1 = SubResource("TileSetAtlasSource_mv7cw")