Skip to content

Commit b487f2d

Browse files
committed
Support multiple base nodes info per tile
Changed Map.GetBaseNode to GetBaseNodes to return a list of base nodes for a given cell coordinate. Updated TileInfoDisplay to handle and display information for multiple base nodes on a tile.
1 parent 3eb6c97 commit b487f2d

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

src/TSMapEditor/Models/Map.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,8 +2097,10 @@ public void Clear()
20972097
GraphicalBaseNodes = null;
20982098
}
20992099

2100-
public BaseNode GetBaseNode(Point2D cellCoords)
2100+
public List<BaseNode> GetBaseNodes(Point2D cellCoords)
21012101
{
2102+
List<BaseNode> baseNodes = [];
2103+
21022104
foreach (var graphicalBaseNode in GraphicalBaseNodes)
21032105
{
21042106
var nodeBuildingType = graphicalBaseNode.BuildingType;
@@ -2108,7 +2110,8 @@ public BaseNode GetBaseNode(Point2D cellCoords)
21082110

21092111
if (graphicalBaseNode.BaseNode.Position == cellCoords)
21102112
{
2111-
return graphicalBaseNode.BaseNode;
2113+
baseNodes.Add(graphicalBaseNode.BaseNode);
2114+
continue;
21122115
}
21132116

21142117
bool baseNodeExistsOnFoundation = false;
@@ -2121,11 +2124,11 @@ public BaseNode GetBaseNode(Point2D cellCoords)
21212124

21222125
if (baseNodeExistsOnFoundation)
21232126
{
2124-
return graphicalBaseNode.BaseNode;
2127+
baseNodes.Add(graphicalBaseNode.BaseNode);
21252128
}
21262129
}
21272130

2128-
return null;
2131+
return baseNodes;
21292132
}
21302133
}
21312134
}

src/TSMapEditor/UI/TileInfoDisplay.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private void RefreshInfo()
134134
MapTile.DoForAllBuildings(structure => AddObjectInformation("Structure: ", structure));
135135
MapTile.DoForAllInfantry(inf => AddObjectInformation("Infantry: ", inf));
136136
MapTile.DoForAllWaypoints(waypoint => AddWaypointInfo(waypoint));
137-
AddBaseNodeInformation(map.GetBaseNode(MapTile.CoordsToPoint()));
137+
AddBaseNodeInformation(map.GetBaseNodes(MapTile.CoordsToPoint()));
138138
AddTerrainObjectInformation(MapTile.TerrainObject);
139139

140140
textRenderer.PrepareTextParts();
@@ -290,20 +290,20 @@ private void AddObjectInformation<T>(string objectTypeLabel, Techno<T> techno) w
290290
}
291291
}
292292

293-
private void AddBaseNodeInformation(BaseNode baseNode)
293+
private void AddBaseNodeInformation(List<BaseNode> baseNodes)
294294
{
295-
if (baseNode == null)
296-
return;
297-
298-
var nodeBuildingType = map.Rules.BuildingTypes.Find(bt => bt.ININame == baseNode.StructureTypeName);
299-
var house = map.Houses.Find(house => house.BaseNodes.Contains(baseNode));
295+
foreach (var baseNode in baseNodes)
296+
{
297+
var nodeBuildingType = map.Rules.BuildingTypes.Find(bt => bt.ININame == baseNode.StructureTypeName);
298+
var house = map.Houses.Find(house => house.BaseNodes.Contains(baseNode));
300299

301-
if (nodeBuildingType == null || house == null)
302-
return;
300+
if (nodeBuildingType == null || house == null)
301+
return;
303302

304-
textRenderer.AddTextLine(new XNATextPart("Base Node: ", Constants.UIDefaultFont, Color.Gray));
305-
textRenderer.AddTextPart(new XNATextPart($"{nodeBuildingType.Name} ({nodeBuildingType.ININame}), Owner:", Constants.UIDefaultFont, Color.White));
306-
textRenderer.AddTextPart(new XNATextPart(house.ININame, Constants.UIBoldFont, house.XNAColor));
303+
textRenderer.AddTextLine(new XNATextPart("Base Node: ", Constants.UIDefaultFont, Color.Gray));
304+
textRenderer.AddTextPart(new XNATextPart($"{nodeBuildingType.Name} ({nodeBuildingType.ININame}), Owner:", Constants.UIDefaultFont, Color.White));
305+
textRenderer.AddTextPart(new XNATextPart(house.ININame, Constants.UIBoldFont, house.XNAColor));
306+
}
307307
}
308308

309309
private void AddTerrainObjectInformation(TerrainObject terrainObject)

0 commit comments

Comments
 (0)