Skip to content

Commit 12069d0

Browse files
Add missing docstrings
1 parent 27e4c2b commit 12069d0

4 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/Json/JsonMerger.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
using Newtonsoft.Json.Linq;
33

44
namespace PolyMod.Json;
5+
6+
/// <summary>
7+
/// Provides functionality to merge JSON objects, with special handling for arrays.
8+
/// </summary>
59
public static class JsonMerger
610
{
11+
/// <summary>
12+
/// Merges a patch JObject into an original JObject.
13+
/// </summary>
14+
/// <param name="original">The original JObject.</param>
15+
/// <param name="patch">The patch JObject to merge.</param>
16+
/// <returns>The merged JObject.</returns>
717
public static JObject Merge(JObject original, JObject patch)
818
{
919
foreach (var property in patch.Properties().ToArray().ToList())
@@ -44,6 +54,13 @@ public static JObject Merge(JObject original, JObject patch)
4454
return original;
4555
}
4656

57+
/// <summary>
58+
/// Merges two JArrays, with special handling for adding and removing elements.
59+
/// </summary>
60+
/// <param name="original">The original JArray.</param>
61+
/// <param name="patch">The patch JArray to merge.</param>
62+
/// <param name="isSkins">A flag to indicate if the array is a 'skins' array, which has special merging logic.</param>
63+
/// <returns>The merged JArray.</returns>
4764
private static JArray MergeArrays(JArray original, JArray patch, bool isSkins)
4865
{
4966
var result = new JArray(original);

src/Loader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,11 @@ public static void LoadAssetBundle(Mod mod, Mod.File file)
759759
);
760760
}
761761

762+
/// <summary>
763+
/// Processes the merged game logic data after all mods have been loaded and patched.
764+
/// </summary>
765+
/// <param name="gameLogicData">The game logic data object to populate.</param>
766+
/// <param name="rootObject">The root JObject of the merged game logic data.</param>
762767
internal static void ProcessGameLogicData(GameLogicData gameLogicData, JObject rootObject)
763768
{
764769
try

src/Managers/Main.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ internal static void Init()
385385
/// Loads all mod content.
386386
/// </summary>
387387
/// <param name="gameLogicdata">The game logic data to patch.</param>
388+
/// <param name="json">The JSON object representing the game logic data.</param>
388389
internal static void Load(GameLogicData gameLogicData, JObject json)
389390
{
390391
stopwatch.Start();

src/Managers/Visual.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,16 @@ private static void UpdateVisualPart(SkinVisualsReference.VisualPart visualPart,
643643
{
644644
if (visualPart.outlineRenderer.spriteRenderer != null)
645645
visualPart.outlineRenderer.spriteRenderer.sprite = outlineSprite;
646-
else if (visualpart.outlineRenderer.polytopiaSpriteRenderer != null)
646+
else if (visualPart.outlineRenderer.polytopiaSpriteRenderer != null)
647647
visualPart.outlineRenderer.polytopiaSpriteRenderer.sprite = outlineSprite;
648648
}
649649
}
650650

651651
/// <summary>Builds a sprite from raw byte data.</summary>
652+
/// <param name="data">The raw byte data of the image.</param>
653+
/// <param name="pivot">The pivot point of the sprite.</param>
654+
/// <param name="pixelsPerUnit">The number of pixels per unit for the sprite.</param>
655+
/// <returns>The created sprite.</returns>
652656
public static Sprite BuildSprite(byte[] data, Vector2? pivot = null, float pixelsPerUnit = 2112f)
653657
{
654658
Texture2D texture = new(1, 1, TextureFormat.RGBA32, true);
@@ -665,6 +669,10 @@ public static Sprite BuildSprite(byte[] data, Vector2? pivot = null, float pixel
665669
}
666670

667671
/// <summary>Builds a sprite from a texture.</summary>
672+
/// <param name="texture">The texture to create the sprite from.</param>
673+
/// <param name="pivot">The pivot point of the sprite.</param>
674+
/// <param name="pixelsPerUnit">The number of pixels per unit for the sprite.</param>
675+
/// <returns>The created sprite.</returns>
668676
public static Sprite BuildSpriteWithTexture(Texture2D texture, Vector2? pivot = null, float? pixelsPerUnit = 2112f)
669677
{
670678
return Sprite.Create(

0 commit comments

Comments
 (0)