summaryrefslogtreecommitdiff
path: root/scripts/map/Tile.cs
blob: e050701dbd5bf7d8a14912adbe466673cfffc010 (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
44
45
46
47
using Godot;
using System;

public partial class Tile : Sprite2D
{
	private TileDefinition definition;

	public bool IsWalkable { get; private set; }
	public bool IsTransparent { get; private set; }

	private bool isExplored = false;
	public bool IsExplored {
		get => this.isExplored;
		set {
			isExplored = value;
			if (IsExplored && !Visible) {
				Visible = true;
			}
		}
	}

	private bool isInView = false;
	public bool IsInView {
		get => this.isInView;
		set {
			this.isInView = value;
			if (IsInView && !IsExplored) {
				IsExplored = true;
			}
		}
	}

	public Tile(Vector2I pos, TileDefinition definition)
	{
		Centered = false;
		Visible = false;
		Position = Grid.GridToWorld(pos);
		SetDefinition(definition);
	}

	public void SetDefinition(TileDefinition definition) {
		this.definition = definition;
		Texture = definition.Texture;
		IsWalkable = definition.IsWalkable;
		IsTransparent = definition.IsTransparent;
	}
}