blob: a759fef8f3dceae1dc1ee5980f4bcd4be468d8bc (
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
40
41
42
43
|
using Godot;
[GlobalClass]
public abstract partial class Actor : Sprite2D
{
private ActorDefinition definition;
private Vector2I gridPosition = Vector2I.Zero;
public MapData Map_Data { get; private set; }
public Actor(Vector2I initialPosition, MapData map, ActorDefinition definition) {
GridPosition = initialPosition;
Map_Data = map;
this.definition = definition;
Texture = definition.texture;
Centered = false;
}
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;
}
}
|