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

public partial class MovementAction : DirectionalAction
{
	public MovementAction(Actor actor, Vector2I offset) : base(actor, offset)
	{
	}

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

		if (!Map.IsTileWalkable(finalDestination)) return;

		if (GetBlockingActorAtPosition(finalDestination) != null) return;

		actor.Walk(Offset);
	}
}