summaryrefslogtreecommitdiff
path: root/scripts/actors/actions/MovementAction.cs
blob: f29e2e83ffc83207ed550e07f7fa4bb177759ab7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Godot;
using System;

public partial class MovementAction : Action
{
	public Vector2I Offset { get; private set; }
	public MovementAction(Vector2I offset)
	{
		Offset = offset;
	}

	public override void Perform(Game game, Actor actor)
	{
		Vector2I finalDestination = actor.GridPosition + Offset;

		TileData tile = game.Dungeon.GetCellTileData(finalDestination);

		if (tile == null || !(bool) tile.GetCustomData("isWalkable")) return;

		actor.Walk(Offset);
	}
}