Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/TSMapEditor/Models/MapTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,40 @@ public void ChangeTileIndex(int newTileIndex, byte newSubTileIndex)
SubTileIndex = newSubTileIndex;
}

public BaseNode GetBaseNode(Map map)
Comment thread
JoyfulShush marked this conversation as resolved.
Outdated
{
foreach (House house in map.Houses)
{
foreach (BaseNode baseNode in house.BaseNodes)
{
var nodeStructureType = map.Rules.BuildingTypes.Find(bt => bt.ININame == baseNode.StructureTypeName);

if (nodeStructureType == null)
continue;

if (baseNode.Position == CoordsToPoint())
{
return baseNode;
}

bool baseNodeExistsOnFoundation = false;
nodeStructureType.ArtConfig.DoForFoundationCoords(foundationOffset =>
{
Point2D foundationCellCoords = baseNode.Position + foundationOffset;
if (foundationCellCoords == CoordsToPoint())
baseNodeExistsOnFoundation = true;
});

if (baseNodeExistsOnFoundation)
{
return baseNode;
}
}
}

return null;
}

public Point2D CoordsToPoint() => new Point2D(X, Y);

public Point2D GetTileCenter() => new Point2D(Constants.CellSizeX / 2, Constants.CellSizeY / 2);
Expand Down
26 changes: 26 additions & 0 deletions src/TSMapEditor/UI/TileInfoDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(MapTile.GetBaseNode(map));
AddTerrainObjectInformation(MapTile.TerrainObject);

textRenderer.PrepareTextParts();

Expand Down Expand Up @@ -286,5 +288,29 @@ private void AddObjectInformation<T>(string objectTypeLabel, Techno<T> techno) w
textRenderer.AddTextPart(new XNATextPart(techno.AttachedTag.Name + " (" + techno.AttachedTag.ID + ")", Constants.UIBoldFont, Color.White));
}
}

private void AddBaseNodeInformation(BaseNode baseNode)
{
if (baseNode == null)
return;

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}) ({house.ININame})", Constants.UIDefaultFont, Color.White));
}

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));
}
}
}
Loading