41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using PashaBibko.Pacore.Attributes;
|
|
using JetBrains.Annotations;
|
|
using UnityEngine.Scripting;
|
|
using Fruitomation.Global;
|
|
using UnityEngine;
|
|
|
|
namespace Fruitomation.Game
|
|
{
|
|
public class Building : MonoBehaviour
|
|
{
|
|
[Header("Building Properties")]
|
|
[SerializeField] private Sprite BuildingSprite;
|
|
[field: SerializeField] public Vector2Int SizeOnGrid { get; private set; }
|
|
|
|
private BuildingManager Manager;
|
|
|
|
public Vector2Int GridPosition { get; private set; }
|
|
public Vector2Int Position { get; private set; }
|
|
public bool IsFlipped { get; private set; }
|
|
|
|
public void Init(BuildingManager manager, Vector2Int gridPosition, Vector2Int position, bool isFlipped)
|
|
{
|
|
GridPosition = gridPosition;
|
|
IsFlipped = isFlipped;
|
|
Position = position;
|
|
Manager = manager;
|
|
}
|
|
|
|
[UsedImplicitly, Preserve, InspectorCallable("Click Building")] public void OnBuildingClicked()
|
|
{
|
|
if (GameStateController.Is(GameState.Editing))
|
|
{
|
|
Manager.RemoveBuilding(this);
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public Sprite Sprite => BuildingSprite;
|
|
}
|
|
}
|