forked from Skylines-ModTools/Skylines-ModTools
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a17af43
commit 1a535ad
Showing
5 changed files
with
190 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
using System.IO; | ||
using ColossalFramework.IO; | ||
using ColossalFramework.UI; | ||
using UnityEngine; | ||
|
||
namespace ModTools.Utils | ||
{ | ||
internal static class AssetDumpUtil | ||
{ | ||
public static string DumpGenericAsset( | ||
string assetName, | ||
Mesh mesh, | ||
Material material, | ||
Mesh lodMesh = null, | ||
Material lodMaterial = null) | ||
{ | ||
assetName = assetName.Replace("_Data", string.Empty); | ||
Logger.Warning($"Dumping asset \"{assetName}\"..."); | ||
|
||
DumpUtil.DumpMeshAndTextures(assetName, mesh, material); | ||
DumpUtil.DumpMeshAndTextures($"{assetName}_lod", lodMesh, lodMaterial); | ||
Logger.Warning($"Successfully dumped asset \"{assetName}\""); | ||
return assetName; | ||
} | ||
|
||
public static string DumpBuilding(string assetName, | ||
Mesh mesh, | ||
Material material, | ||
Mesh lodMesh, | ||
Material lodMaterial, | ||
BuildingInfo.MeshInfo[] subMeshes) | ||
{ | ||
assetName = assetName.Replace("_Data", string.Empty); | ||
Logger.Warning($"Dumping asset \"{assetName}\"..."); | ||
if (mesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures(assetName, mesh, material); | ||
} | ||
|
||
if (lodMesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures(assetName + "_lod", lodMesh, lodMaterial); | ||
} | ||
|
||
if (subMeshes != null) | ||
{ | ||
for (var i = 0; i < subMeshes.Length; i++) | ||
{ | ||
var subInfo = subMeshes[i]?.m_subInfo; | ||
if (subInfo == null) | ||
{ | ||
continue; | ||
} | ||
|
||
if (subInfo.m_mesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures($"{assetName}_sub_mesh_{i}", subInfo.m_mesh, subInfo.m_material); | ||
} | ||
|
||
if (subInfo.m_lodMesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures($"{assetName}_sub_mesh_{i}_lod", subInfo.m_lodMesh, | ||
subInfo.m_lodMaterial); | ||
} | ||
} | ||
} | ||
return assetName; | ||
} | ||
|
||
public static string DumpVehicle(string assetName, | ||
Mesh mesh, Material material, | ||
Mesh lodMesh, Material lodMaterial, | ||
VehicleInfo.MeshInfo[] subMeshes) | ||
{ | ||
assetName = assetName.Replace("_Data", string.Empty); | ||
Logger.Warning($"Dumping asset \"{assetName}\"..."); | ||
|
||
if (mesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures(assetName, mesh, material); | ||
} | ||
|
||
if (lodMesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures(assetName + "_lod", lodMesh, lodMaterial); | ||
} | ||
|
||
if (subMeshes != null) | ||
{ | ||
for (var i = 0; i < subMeshes.Length; i++) | ||
{ | ||
var subInfo = subMeshes[i]?.m_subInfo; | ||
if (subInfo == null) | ||
{ | ||
continue; | ||
} | ||
|
||
if (subInfo.m_mesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures($"{assetName}_sub_mesh_{i}", subInfo.m_mesh, | ||
subInfo.m_material); | ||
} | ||
|
||
if (subInfo.m_lodMesh != null) | ||
{ | ||
DumpUtil.DumpMeshAndTextures($"{assetName}_sub_mesh_{i}_lod", subInfo.m_lodMesh, | ||
subInfo.m_lodMaterial); | ||
} | ||
} | ||
} | ||
|
||
return assetName; | ||
} | ||
|
||
public static string DumpNetwork(string assetName, NetInfo.Segment[] segments, NetInfo.Node[] nodes) | ||
{ | ||
assetName = assetName.Replace("_Data", string.Empty); | ||
Logger.Warning($"Dumping asset \"{assetName}\"..."); | ||
|
||
if (segments != null) | ||
{ | ||
for (var index = 0; index < segments.Length; index++) | ||
{ | ||
var segment = segments[index]; | ||
if (segment == null) | ||
{ | ||
continue; | ||
} | ||
|
||
DumpUtil.DumpMeshAndTextures($"{assetName}_segment_{index}", segment.m_mesh, | ||
segment.m_material); | ||
DumpUtil.DumpMeshAndTextures($"{assetName}_segment_{index}_lod", segment.m_lodMesh, | ||
segment.m_lodMaterial); | ||
} | ||
} | ||
|
||
if (nodes != null) | ||
{ | ||
for (var index = 0; index < nodes.Length; index++) | ||
{ | ||
var node = nodes[index]; | ||
if (node == null) | ||
{ | ||
continue; | ||
} | ||
|
||
DumpUtil.DumpMeshAndTextures($"{assetName}_node_{index}", node.m_mesh, node.m_material); | ||
DumpUtil.DumpMeshAndTextures($"{assetName}_node_{index}_lod", node.m_lodMesh, | ||
node.m_lodMaterial); | ||
} | ||
} | ||
|
||
return assetName; | ||
} | ||
} | ||
} |
Oops, something went wrong.