summaryrefslogtreecommitdiff
path: root/scripts/actors/Actor.cs
blob: f429eadabb28cb9d33ba3a361425189b17220b58 (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
using Godot;

[GlobalClass]
public abstract partial class Actor : Sprite2D
{
	[Export]
	private ActorDefinition definition;
	private Vector2I gridPosition = Vector2I.Zero;
	[Export]
	public DungeonLevel Map { get; private set; }
	public Vector2I GridPosition {
		set {
			gridPosition = value;
			Position = Grid.GridToWorld(value);
		}
		get => gridPosition;
	}

	public bool BlocksMovement {
		get => definition.blocksMovement;
	}

	public string ActorName {
		get => definition.name;
	}

	public override void _Ready()
	{
		base._Ready();
		GridPosition = Grid.WorldToGrid(Position);
	}

	public void Walk(Vector2I offset) {
		GridPosition += offset;
	}
}