示例#1
0
        internal static void GenerateSpriteSheet()
        {
            GadgetCoreAPI.spriteSheetSize = MathUtils.SmallestPerfectSquare(GadgetCoreAPI.spriteSheetSprites.Count + 16);
            int spritesOnAxis          = (int)Mathf.Sqrt(GadgetCoreAPI.spriteSheetSize);
            int spritesOnFirstFourRows = spritesOnAxis - 4;
            int spriteSheetDimensions  = spritesOnAxis * 32;

            GadgetCoreAPI.spriteSheet = new Texture2D(spriteSheetDimensions, spriteSheetDimensions, InstanceTracker.GameScript.TileManager.GetComponent <ChunkWorld>().Texture.format, false, false)
            {
                filterMode = FilterMode.Point
            };
            for (int i = 0; i < GadgetCoreAPI.spriteSheetSprites.Count; i++)
            {
                Vector2 coords;
                if (i < spritesOnFirstFourRows * 4)
                {
                    coords = new Vector2(4 + (i % spritesOnFirstFourRows), i / spritesOnFirstFourRows);
                }
                else
                {
                    coords = new Vector2((i - (spritesOnFirstFourRows * 4)) % spritesOnAxis, 4 + ((i - (spritesOnFirstFourRows * 4)) / spritesOnAxis));
                }
                GadgetCoreAPI.spriteSheetSprites[i].coords = coords;
                GadgetUtils.SafeCopyTexture(GadgetCoreAPI.spriteSheetSprites[i].tex, 0, 0, 0, 0, 32, 32, GadgetCoreAPI.spriteSheet, 0, 0, (int)coords.x * 32, (int)coords.y * 32);
            }
        }
示例#2
0
 public static void Prefix(GameScript __instance)
 {
     InstanceTracker.GameScript = __instance;
     GadgetCore.GenerateSpriteSheet();
     GadgetUtils.SafeCopyTexture(__instance.TileManager.GetComponent <ChunkWorld>().Texture, 0, 0, 0, 0, 128, 128, GadgetCoreAPI.spriteSheet, 0, 0, 0, 0);
     __instance.TileManager.GetComponent <ChunkWorld>().Texture = GadgetCoreAPI.spriteSheet;
     __instance.WallManager.GetComponent <ChunkWorld>().Texture = GadgetCoreAPI.spriteSheet;
     foreach (GadgetModInfo mod in GadgetMods.ListAllModInfos())
     {
         __instance.gameObject.AddComponent <GadgetModHookScript>().Mod = mod;
     }
 }