public static HashSet <StatDef> TerrainMovementDisallowedPathCostStat(this TerrainDef terrain) { HashSet <StatDef> disallowedPathCostStat = new HashSet <StatDef>(); if (terrain.modExtensions != null) { foreach (DefModExtension ext in terrain.modExtensions) { TerrainMovementTerrainRestrictions restrictions = terrain.LoadTerrainMovementTerrainRestrictionsExtension(ext); if (restrictions != null) { StatDef restrictionDef; // There's no actual StatDef for pathCost, so map it to MoveSpeed if (restrictions.disallowedPathCostStat == null || restrictions.disallowedPathCostStat == "pathCost") { restrictionDef = StatDefOf.MoveSpeed; } else { restrictionDef = StatDef.Named(restrictions.disallowedPathCostStat); } disallowedPathCostStat.Add(restrictionDef); } } } return(disallowedPathCostStat); }