Skip to content

Commit

Permalink
docs: added Mesh page
Browse files Browse the repository at this point in the history
  • Loading branch information
MSchmoecker committed Apr 13, 2024
1 parent d3b9d9e commit ca20262
Show file tree
Hide file tree
Showing 7 changed files with 1,758 additions and 1 deletion.
51 changes: 51 additions & 0 deletions JotunnDoc/Docs/MeshDoc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Jotunn.Managers;
using SoftReferenceableAssets;
using UnityEngine;

namespace JotunnDoc.Docs
{
public class MeshDoc : Doc
{
public MeshDoc() : base("prefabs/mesh-list.md")
{
PrefabManager.OnVanillaPrefabsAvailable += DocMeshes;
}

void DocMeshes()
{
if (Generated)
{
return;
}

Jotunn.Logger.LogInfo("Documenting meshes");

AddHeader(1, "Mesh list");
AddText("All the meshes currently in the game.");
AddText("Use the SoftReference system to load the meshes, the internal object name is only for reference.");
AddText($"This file is automatically generated from Valheim {Version.GetVersionString(true)} using the JotunnDoc mod found on our GitHub.");

AddTableHeader("SoftReference Name", "Asset ID", "Internal Object Name");

foreach (var pair in AssetManager.Instance.MapNameToAssetID[typeof(Mesh)])
{
if (!pair.Value.IsValid)
{
continue;
}

var softReferenceName = pair.Key;
var assetID = pair.Value;
SoftReference<GameObject> asset = new SoftReference<GameObject>(assetID);
asset.Load();

if (!PrefabManager.TryFindAssetInSelfOrChildComponents(asset.Asset, typeof(Mesh), out Object meshAsset))
{
continue;
}

AddTableRow(softReferenceName, assetID.ToString(), meshAsset.name);
}
}
}
}
1 change: 1 addition & 0 deletions JotunnDoc/JotunnDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private void Awake()
new StatusEffectDoc(),
new VegetationDoc(),
new EventDoc(),
new MeshDoc(),
};

Debug.Log("Initialized JotunnDoc");
Expand Down
1 change: 1 addition & 0 deletions JotunnDoc/JotunnDoc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<ItemGroup>
<Compile Include="Doc.cs" />
<Compile Include="Docs\EventDoc.cs" />
<Compile Include="Docs\MeshDoc.cs" />
<Compile Include="Docs\VegetationDoc.cs" />
<Compile Include="Docs\LanguageDoc.cs" />
<Compile Include="Docs\LocationDoc.cs" />
Expand Down
1,701 changes: 1,701 additions & 0 deletions JotunnLib/Documentation/data/prefabs/mesh-list.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions JotunnLib/Documentation/data/prefabs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
href: material-list.md
- name: Shader list
href: shader-list.md
- name: Mesh list
href: mesh-list.md
- name: Character list
href: character-list.md
2 changes: 1 addition & 1 deletion JotunnLib/Managers/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AssetManager : IManager
private Dictionary<AssetID, AssetRef> assets = new Dictionary<AssetID, AssetRef>();

private Dictionary<Type, Dictionary<string, AssetID>> mapNameToAssetID;
private Dictionary<Type, Dictionary<string, AssetID>> MapNameToAssetID => mapNameToAssetID ??= CreateNameToAssetID();
internal Dictionary<Type, Dictionary<string, AssetID>> MapNameToAssetID => mapNameToAssetID ??= CreateNameToAssetID();

/// <summary>
/// Hide .ctor
Expand Down
1 change: 1 addition & 0 deletions JotunnLib/Properties/IgnoreAccessModifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
#pragma warning disable CS0618 // Type or member is obsolete
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: InternalsVisibleTo("JotunnTests")]
[assembly: InternalsVisibleTo("JotunnDoc")]

0 comments on commit ca20262

Please sign in to comment.