1010
1111namespace PolyMod . Managers ;
1212
13+ /// <summary>
14+ /// Manages visual aspects of the game, including sprites, UI elements, and in-game object appearances.
15+ /// </summary>
1316public static class Visual
1417{
18+ /// <summary>
19+ /// Represents a single tile in a tribe's world preview.
20+ /// </summary>
1521 public class PreviewTile
1622 {
23+ /// <summary>The X-coordinate of the tile.</summary>
1724 [ JsonInclude ]
1825 public int ? x = null ;
26+ /// <summary>The Y-coordinate of the tile.</summary>
1927 [ JsonInclude ]
2028 public int ? y = null ;
29+ /// <summary>The type of terrain on the tile.</summary>
2130 [ JsonInclude ]
2231 [ JsonConverter ( typeof ( EnumCacheJson < Polytopia . Data . TerrainData . Type > ) ) ]
2332 public Polytopia . Data . TerrainData . Type terrainType = Polytopia . Data . TerrainData . Type . Ocean ;
33+ /// <summary>The type of resource on the tile.</summary>
2434 [ JsonInclude ]
2535 [ JsonConverter ( typeof ( EnumCacheJson < ResourceData . Type > ) ) ]
2636 public ResourceData . Type resourceType = ResourceData . Type . None ;
37+ /// <summary>The type of unit on the tile.</summary>
2738 [ JsonInclude ]
2839 [ JsonConverter ( typeof ( EnumCacheJson < UnitData . Type > ) ) ]
2940 public UnitData . Type unitType = UnitData . Type . None ;
41+ /// <summary>The type of improvement on the tile.</summary>
3042 [ JsonInclude ]
3143 [ JsonConverter ( typeof ( EnumCacheJson < ImprovementData . Type > ) ) ]
3244 public ImprovementData . Type improvementType = ImprovementData . Type . None ;
3345 }
46+
47+ /// <summary>
48+ /// Holds information for creating a custom sprite.
49+ /// </summary>
50+ /// <param name="pixelsPerUnit">The number of pixels per unit for the sprite.</param>
51+ /// <param name="pivot">The pivot point of the sprite.</param>
3452 public record SpriteInfo ( float ? pixelsPerUnit , Vector2 ? pivot ) ;
53+
54+ /// <summary>
55+ /// Holds information about a custom skin.
56+ /// </summary>
57+ /// <param name="idx">The index of the skin.</param>
58+ /// <param name="id">The unique identifier for the skin.</param>
59+ /// <param name="skinData">The data associated with the skin.</param>
3560 public record SkinInfo ( int idx , string id , SkinData ? skinData ) ;
61+
62+ /// <summary>
63+ /// A dictionary mapping BasicPopup instance IDs to their custom widths.
64+ /// </summary>
3665 public static Dictionary < int , int > basicPopupWidths = new ( ) ;
3766 private static bool firstTimeOpeningPreview = true ;
3867 private static UnitData . Type currentUnitTypeUI = UnitData . Type . None ;
3968 private static TribeData . Type attackerTribe = TribeData . Type . None ;
69+
70+ /// <summary>
71+ /// Defines the types of prefabs that can be customized.
72+ /// </summary>
4073 public enum PrefabType
4174 {
75+ /// <summary>A unit prefab.</summary>
4276 Unit ,
77+ /// <summary>An improvement prefab.</summary>
4378 Improvement ,
79+ /// <summary>A resource prefab.</summary>
4480 Resource
4581 }
82+
83+ /// <summary>
84+ /// Holds information for a custom prefab.
85+ /// </summary>
86+ /// <param name="type">The type of the prefab.</param>
87+ /// <param name="name">The name of the prefab.</param>
88+ /// <param name="visualParts">A list of visual parts that make up the prefab.</param>
4689 public record PrefabInfo ( PrefabType type , string name , List < VisualPartInfo > visualParts ) ;
90+
91+ /// <summary>
92+ /// Represents a visual part of a custom prefab.
93+ /// </summary>
94+ /// <param name="gameObjectName">The name of the GameObject for this visual part.</param>
95+ /// <param name="baseName">The base name for sprite lookups.</param>
96+ /// <param name="rotation">The rotation of the visual part.</param>
97+ /// <param name="coordinates">The local position of the visual part.</param>
98+ /// <param name="scale">The local scale of the visual part.</param>
99+ /// <param name="tintable">Whether the visual part can be tinted.</param>
47100 public record VisualPartInfo (
48101 string gameObjectName ,
49102 string baseName ,
@@ -257,7 +310,7 @@ private static void TerrainRenderer_UpdateGraphics(TerrainRenderer __instance, T
257310 if ( tile . data . terrain is Polytopia . Data . TerrainData . Type . Forest or Polytopia . Data . TerrainData . Type . Mountain )
258311 {
259312 string propertyName = terrain . ToLower ( ) ;
260- terrain = "field" ;
313+ terrain = "field" ;
261314
262315 PropertyInfo ? rendererProperty = tile . GetType ( ) . GetProperty ( propertyName + "Renderer" ,
263316 BindingFlags . Public | BindingFlags . Instance ) ;
@@ -565,6 +618,11 @@ private static void PopupBase_Hide(PopupBase __instance)
565618 basicPopupWidths . Remove ( __instance . GetInstanceID ( ) ) ;
566619 }
567620
621+ /// <summary>
622+ /// Shows a BasicPopup and sets its width.
623+ /// </summary>
624+ /// <param name="self">The BasicPopup instance.</param>
625+ /// <param name="width">The desired width of the popup.</param>
568626 public static void ShowSetWidth ( this BasicPopup self , int width )
569627 {
570628 basicPopupWidths . Add ( self . GetInstanceID ( ) , width ) ;
@@ -594,6 +652,13 @@ private static void UpdateVisualPart(SkinVisualsReference.VisualPart visualPart,
594652 }
595653 }
596654
655+ /// <summary>
656+ /// Creates a <see cref="Sprite"/> from raw image data.
657+ /// </summary>
658+ /// <param name="data">The byte array containing the image data.</param>
659+ /// <param name="pivot">The pivot point for the sprite. Defaults to the center.</param>
660+ /// <param name="pixelsPerUnit">The number of pixels per unit for the sprite.</param>
661+ /// <returns>A new <see cref="Sprite"/> instance.</returns>
597662 public static Sprite BuildSprite ( byte [ ] data , Vector2 ? pivot = null , float pixelsPerUnit = 2112f )
598663 {
599664 Texture2D texture = new ( 1 , 1 , TextureFormat . RGBA32 , true ) ;
@@ -609,6 +674,13 @@ public static Sprite BuildSprite(byte[] data, Vector2? pivot = null, float pixel
609674 return BuildSpriteWithTexture ( texture , pivot , pixelsPerUnit ) ;
610675 }
611676
677+ /// <summary>
678+ /// Creates a <see cref="Sprite"/> from an existing <see cref="Texture2D"/>.
679+ /// </summary>
680+ /// <param name="texture">The texture to create the sprite from.</param>
681+ /// <param name="pivot">The pivot point for the sprite. Defaults to the center.</param>
682+ /// <param name="pixelsPerUnit">The number of pixels per unit for the sprite.</param>
683+ /// <returns>A new <see cref="Sprite"/> instance.</returns>
612684 public static Sprite BuildSpriteWithTexture ( Texture2D texture , Vector2 ? pivot = null , float ? pixelsPerUnit = 2112f )
613685 {
614686 return Sprite . Create (
0 commit comments