summaryrefslogtreecommitdiff
path: root/scripts/Actor.cs
blob: fc69edfa2452f382292d3bf3d28f597dc0a9ae3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using Godot;

public partial class Actor : Node2D {
	[Export]
	public TileMapLayer Map { get; set; }

	protected void Walk(Vector2I offset) {
		Vector2I toMovePos = Map.LocalToMap(Position);
		toMovePos += offset;
		
		TileData tile = Map.GetCellTileData(toMovePos);

		if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) {
			GD.Print(toMovePos);
			Position = Map.MapToLocal(toMovePos);
		}
	}
}