diff --git a/src/TSMapEditor/Models/Map.cs b/src/TSMapEditor/Models/Map.cs index e03d106ab..de02a084e 100644 --- a/src/TSMapEditor/Models/Map.cs +++ b/src/TSMapEditor/Models/Map.cs @@ -2096,5 +2096,39 @@ public void Clear() Tubes = null; GraphicalBaseNodes = null; } + + public List GetBaseNodes(Point2D cellCoords) + { + List baseNodes = []; + + foreach (var graphicalBaseNode in GraphicalBaseNodes) + { + var nodeBuildingType = graphicalBaseNode.BuildingType; + + if (nodeBuildingType == null) + continue; + + if (graphicalBaseNode.BaseNode.Position == cellCoords) + { + baseNodes.Add(graphicalBaseNode.BaseNode); + continue; + } + + bool baseNodeExistsOnFoundation = false; + nodeBuildingType.ArtConfig.DoForFoundationCoords(foundationOffset => + { + Point2D foundationCellCoords = graphicalBaseNode.BaseNode.Position + foundationOffset; + if (foundationCellCoords == cellCoords) + baseNodeExistsOnFoundation = true; + }); + + if (baseNodeExistsOnFoundation) + { + baseNodes.Add(graphicalBaseNode.BaseNode); + } + } + + return baseNodes; + } } } diff --git a/src/TSMapEditor/UI/TileInfoDisplay.cs b/src/TSMapEditor/UI/TileInfoDisplay.cs index 4b52f461f..6dfe5a6cc 100644 --- a/src/TSMapEditor/UI/TileInfoDisplay.cs +++ b/src/TSMapEditor/UI/TileInfoDisplay.cs @@ -133,6 +133,8 @@ private void RefreshInfo() MapTile.DoForAllBuildings(structure => AddObjectInformation("Structure: ", structure)); MapTile.DoForAllInfantry(inf => AddObjectInformation("Infantry: ", inf)); MapTile.DoForAllWaypoints(waypoint => AddWaypointInfo(waypoint)); + AddBaseNodeInformation(map.GetBaseNodes(MapTile.CoordsToPoint())); + AddTerrainObjectInformation(MapTile.TerrainObject); textRenderer.PrepareTextParts(); @@ -286,5 +288,30 @@ private void AddObjectInformation(string objectTypeLabel, Techno techno) w textRenderer.AddTextPart(new XNATextPart(techno.AttachedTag.Name + " (" + techno.AttachedTag.ID + ")", Constants.UIBoldFont, Color.White)); } } + + private void AddBaseNodeInformation(List baseNodes) + { + foreach (var baseNode in baseNodes) + { + var nodeBuildingType = map.Rules.BuildingTypes.Find(bt => bt.ININame == baseNode.StructureTypeName); + var house = map.Houses.Find(house => house.BaseNodes.Contains(baseNode)); + + if (nodeBuildingType == null || house == null) + return; + + textRenderer.AddTextLine(new XNATextPart("Base Node: ", Constants.UIDefaultFont, Color.Gray)); + textRenderer.AddTextPart(new XNATextPart($"{nodeBuildingType.Name} ({nodeBuildingType.ININame}), Owner:", Constants.UIDefaultFont, Color.White)); + textRenderer.AddTextPart(new XNATextPart(house.ININame, Constants.UIBoldFont, house.XNAColor)); + } + } + + private void AddTerrainObjectInformation(TerrainObject terrainObject) + { + if (terrainObject == null) + return; + + textRenderer.AddTextLine(new XNATextPart("Terrain Object: ", Constants.UIDefaultFont, Color.Gray)); + textRenderer.AddTextPart(new XNATextPart($"{terrainObject.TerrainType.Name} (${terrainObject.TerrainType.ININame})", Constants.UIDefaultFont, Color.White)); + } } }