Fixed building issues when placing over destroyed buildings

This commit is contained in:
2026-04-22 00:21:40 +01:00
parent 6ed8a1fe85
commit b94d4463fd
2 changed files with 16 additions and 7 deletions

View File

@@ -2540,7 +2540,7 @@ RectTransform:
m_GameObject: {fileID: 2048015617}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0.25, y: 0.25, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2112507919}
@@ -2548,7 +2548,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -1100, y: 0}
m_SizeDelta: {x: 1600, y: 150}
m_SizeDelta: {x: 6400, y: 600}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2048015619
MonoBehaviour:
@@ -2571,17 +2571,17 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 75
m_Font: {fileID: 12800000, guid: 25598a8975ed29243bb850b56f191920, type: 3}
m_FontSize: 300
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 75
m_MaxSize: 300
m_Alignment: 3
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: 'Current Money: $0'
--- !u!222 &2048015620

View File

@@ -130,7 +130,16 @@ namespace Fruitomation.Game
File.WriteAllText(Filepath, json);
}
public void RemoveBuilding(Building building) => Buildings.Remove(building);
public void RemoveBuilding(Building building)
{
Buildings.Remove(building);
for (int x = building.GridPosition.x; x < building.GridPosition.x + building.SizeOnGrid.x; x++)
for (int y = building.GridPosition.y; y < building.GridPosition.y + building.SizeOnGrid.y; y++)
{
InhabitedCells[x, y] = false;
}
}
public bool AddBuildingAt(Vector2Int position, BuildingRegistry.BuildingInfo building, bool isFlipped)
{