blob: cdafdca6a721d4adde4fc5c535167a44a8db3b1f (
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
|
using Godot;
using System;
public partial class DungeonLevel : Node2D
{
public Player player;
private TileMapLayer buildingLayer;
[Export]
public Godot.Collections.Array<Actor> Actors { get; private set; } = [];
private Node2D actorsNode;
public override void _Ready()
{
base._Ready();
buildingLayer = GetNode<TileMapLayer>("Dungeon");
actorsNode = GetNode<Node2D>("Actors");
player = actorsNode.GetNode<Player>("Player");
}
public bool IsTileWalkable(Vector2I pos) {
TileData tile = buildingLayer.GetCellTileData(pos);
if (tile == null) return false;
return (bool)tile.GetCustomData("isWalkable");
}
public Actor GetBlockingActorAtPosition(Vector2I pos) {
foreach (Actor actor in Actors) {
if (actor.GridPosition == pos && actor.BlocksMovement) {
return actor;
}
}
return null;
}
}
|