add offsets dictionary

This commit is contained in:
Jose Luis Montañes Ojados
2026-01-06 15:29:51 +01:00
parent 9153fd763e
commit 7e598d765a
6 changed files with 42 additions and 19 deletions

View File

@@ -58,7 +58,10 @@ namespace StrategicMapPlus
if (textureLookup.ContainsKey(texName))
{
Texture2D tex = textureLookup[texName];
Texture2D roundTex = MakeTextureTransparent(tex);
Textures.IconOffset offset = null;
if (Textures.IconsOffsets.ContainsKey(logicKey)) offset = Textures.IconsOffsets[logicKey];
Texture2D roundTex = MakeTextureTransparent(tex, offset);
Sprite s = Sprite.Create(roundTex, new Rect(0, 0, roundTex.width, roundTex.height), new Vector2(0.5f, 0.5f));
SpriteCache[logicKey] = s;
loadedCount++;
@@ -177,7 +180,7 @@ namespace StrategicMapPlus
}
// Función auxiliar que podrías llamar desde tu parche de Harmony
public static Texture2D MakeTextureTransparent(Texture originalTexture)
public static Texture2D MakeTextureTransparent(Texture originalTexture, Textures.IconOffset offset = null)
{
if (originalTexture == null) return null;
@@ -207,6 +210,12 @@ namespace StrategicMapPlus
Vector2 center = new Vector2(width / 2f, height / 2f);
float radius = (Mathf.Min(width, height) / 2f); // Radio máximo
if (offset != null)
{
center += new Vector2(offset.x, offset.y);
if (offset.size > 0) radius = offset.size / 2f;
}
for (int i = 0; i < pixels.Length; i++)
{
// --- Opción A: Máscara Redonda (Matemática) ---