Oct 2025 update - building blocks can't be removed?Suggestion

I seem to be able to remove other objects just fine, but in a building that I own the TC, I cannot remove any building blocks.

"Can't remove: No valid entity targeted"

When remover tool is active, i notice that i get a lot of errors in the console depending on what I am looking at:

(16:26:34) | KeyNotFoundException: The given key 'assets/prefabs/building core/wall/wall.prefab' was not present in the dictionary.
(16:26:37) | KeyNotFoundException: The given key 'assets/prefabs/building core/foundation/foundation.prefab' was not present in the dictionary.

I'm getting the same issue here as well. Im running this on Carbon prod.

I fixed it. Full file here: https://pastebin.com/TvMRshKR

Merged post

Or update these two functions:

private Dictionary<string, CurrencyInfo> GetPrice(BaseEntity targetEntity, RemovableEntityInfo? info)
{
    if (info.HasValue)
    {
        return info.Value.Price.ValueName2Currency;
    }
    var buildingBlock = targetEntity as BuildingBlock;
    if (buildingBlock != null)
    {
        string entityName;
        
        // Try case-sensitive lookup first
        if (!_prefabNameToStructure.TryGetValue(buildingBlock.PrefabName, out entityName))
        {
            // If case-sensitive fails, try case-insensitive lookup
            var kvp = _prefabNameToStructure.FirstOrDefault(x => string.Equals(x.Key, buildingBlock.PrefabName, StringComparison.OrdinalIgnoreCase));
            if (!string.IsNullOrEmpty(kvp.Key))
            {
                entityName = kvp.Value;
            }
            else
            {
                return null;
            }
        }

        BuildingBlocksSettings buildingBlockSettings;
        if (_configData.remove.buildingBlock.TryGetValue(entityName, out buildingBlockSettings))
        {
            BuildingGradeSettings buildingGradeSettings;
            if (buildingBlockSettings.buildingGrade.TryGetValue(buildingBlock.grade, out buildingGradeSettings))
            {
                if (buildingGradeSettings.priceDict != null)
                {
                    return buildingGradeSettings.priceDict;
                }
                if (buildingGradeSettings.pricePercentage > 0f)
                {
                    var currentGrade = buildingBlock.currentGrade;
                    if (currentGrade != null)
                    {
                        var price = new Dictionary<string, CurrencyInfo>();
                        var costToBuild = buildingBlock.blockDefinition.GetGrade(buildingBlock.grade, buildingBlock.skinID).CostToBuild();
                        foreach (var itemAmount in costToBuild)
                        {
                            var amount = Mathf.RoundToInt(itemAmount.amount * buildingGradeSettings.pricePercentage / 100);
                            if (amount <= 0)
                            {
                                continue;
                            }
                            price.Add(itemAmount.itemDef.shortname, new CurrencyInfo(amount));
                        }

                        return price;
                    }
                }
                else if (buildingGradeSettings.pricePercentage < 0f)
                {
                    var currentGrade = buildingBlock.currentGrade;
                    if (currentGrade != null)
                    {
                        return buildingBlock.blockDefinition.GetGrade(buildingBlock.grade, buildingBlock.skinID).CostToBuild().ToDictionary(x => x.itemDef.shortname, y => new CurrencyInfo(Mathf.RoundToInt(y.amount)));
                    }
                }
            }
        }
    }
    else
    {
        EntitySettings entitySettings;
        if (_configData.remove.entity.TryGetValue(targetEntity.ShortPrefabName, out entitySettings))
        {
            return entitySettings.priceDict;
        }
    }
    return null;
}​

and

private Dictionary<string, CurrencyInfo> GetRefund(BaseEntity targetEntity, RemovableEntityInfo? info)
{
    if (info.HasValue)
    {
        return info.Value.Refund.ValueName2Currency;
    }
    var buildingBlock = targetEntity.GetComponent<BuildingBlock>();
    if (buildingBlock != null)
    {
        string entityName;
        
        // Try case-sensitive lookup first
        if (!_prefabNameToStructure.TryGetValue(buildingBlock.PrefabName, out entityName))
        {
            // If case-sensitive fails, try case-insensitive lookup
            var kvp = _prefabNameToStructure.FirstOrDefault(x => string.Equals(x.Key, buildingBlock.PrefabName, StringComparison.OrdinalIgnoreCase));
            if (!string.IsNullOrEmpty(kvp.Key))
            {
                entityName = kvp.Value;
            }
            else
            {
                return null;
            }
        }

        BuildingBlocksSettings buildingBlockSettings;
        if (_configData.remove.buildingBlock.TryGetValue(entityName, out buildingBlockSettings))
        {
            BuildingGradeSettings buildingGradeSettings;
            if (buildingBlockSettings.buildingGrade.TryGetValue(buildingBlock.grade, out buildingGradeSettings))
            {
                if (buildingGradeSettings.refundDict != null)
                {
                    return buildingGradeSettings.refundDict;
                }
                if (buildingGradeSettings.refundPercentage > 0f)
                {
                    var currentGrade = buildingBlock.currentGrade;
                    if (currentGrade != null)
                    {
                        var refund = new Dictionary<string, CurrencyInfo>();
                        var costToBuild = buildingBlock.blockDefinition.GetGrade(buildingBlock.grade, buildingBlock.skinID).CostToBuild();
                        foreach (var itemAmount in costToBuild)
                        {
                            var amount = Mathf.RoundToInt(itemAmount.amount * buildingGradeSettings.refundPercentage / 100);
                            if (amount <= 0)
                            {
                                continue;
                            }
                            refund.Add(itemAmount.itemDef.shortname, new CurrencyInfo(amount));
                        }
                        return refund;
                    }
                }
                else if (buildingGradeSettings.refundPercentage < 0f)
                {
                    var currentGrade = buildingBlock.currentGrade;
                    if (currentGrade != null)
                    {
                        return buildingBlock.blockDefinition.GetGrade(buildingBlock.grade, buildingBlock.skinID).CostToBuild().ToDictionary(x => x.itemDef.shortname, y => new CurrencyInfo(Mathf.RoundToInt(y.amount)));
                    }
                }
            }
        }
    }
    else
    {
        EntitySettings entitySettings;
        if (_configData.remove.entity.TryGetValue(targetEntity.ShortPrefabName, out entitySettings))
        {
            if (_configData.remove.refundSlot)
            {
                var slots = GetSlots(targetEntity);
                if (slots.Any())
                {
                    var refund = new Dictionary<string, CurrencyInfo>(entitySettings.refundDict);
                    foreach (var slotName in slots)
                    {
                        if (!refund.ContainsKey(slotName))
                        {
                            refund.Add(slotName, new CurrencyInfo(0));
                        }
                        refund[slotName] = new CurrencyInfo(refund[slotName].Amount + 1, refund[slotName].SkinId);
                    }
                    return refund;
                }
            }
            return entitySettings.refundDict;
        }
    }
    return null;
}

Still cant remove

Same, still getting Cannot remove, no valid entity target.

GKThux4BoojRRPC.jpg slate0

i might have copy/pasted the wrong file. try this one:  https://pastebin.com/G5w5Xhgu

Thank you for the fix! This made the error spam go away, and made it so foundation and building blocks can be recognized and removed again!