✨ Miner tile
This commit is contained in:
@@ -9,12 +9,15 @@ namespace AceFieldNewHorizon.Scripts.Tiles;
|
||||
public partial class BaseTile : Node2D
|
||||
{
|
||||
[Export] public string TileId { get; set; }
|
||||
[Export] public GridManager Grid { get; set; }
|
||||
|
||||
private CollisionShape2D _collisionShape;
|
||||
private Sprite2D _sprite;
|
||||
private ColorRect _progressOverlay;
|
||||
private Action _onConstructionComplete;
|
||||
private bool _isConstructing = false;
|
||||
|
||||
public bool IsConstructing;
|
||||
public bool IsConstructed;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -28,7 +31,7 @@ public partial class BaseTile : Node2D
|
||||
public void SetGhostMode(bool canPlace)
|
||||
{
|
||||
// Don't modify collision for constructing buildings
|
||||
if (_isConstructing) return;
|
||||
if (IsConstructing) return;
|
||||
|
||||
if (_collisionShape != null)
|
||||
_collisionShape.Disabled = true;
|
||||
@@ -50,13 +53,13 @@ public partial class BaseTile : Node2D
|
||||
// Building progress visualization
|
||||
public void StartConstruction(float buildTime, Action onComplete = null)
|
||||
{
|
||||
_isConstructing = true;
|
||||
IsConstructing = true;
|
||||
if (_collisionShape != null)
|
||||
_collisionShape.Disabled = true;
|
||||
|
||||
if (_progressOverlay == null || _sprite?.Texture == null)
|
||||
{
|
||||
_isConstructing = false;
|
||||
IsConstructing = false;
|
||||
onComplete?.Invoke();
|
||||
return;
|
||||
}
|
||||
@@ -97,11 +100,12 @@ public partial class BaseTile : Node2D
|
||||
if (_sprite != null)
|
||||
_sprite.Modulate = Colors.White;
|
||||
|
||||
_isConstructing = false;
|
||||
IsConstructing = false;
|
||||
if (_collisionShape != null)
|
||||
_collisionShape.Disabled = false;
|
||||
|
||||
_onConstructionComplete?.Invoke();
|
||||
IsConstructed = true;
|
||||
}
|
||||
|
||||
RunProgress();
|
||||
|
Reference in New Issue
Block a user