コード例 #1
0
    // Call this in any level-optimizing procedure (level load screen, post-download processing, special button).
    public static void compileInternalTileset(KnyttWorld world, bool recompile)
    {
        ensureDirExists($"user://Cache/{world.WorldDirectoryName}");

        for (int num = 0; num < 256; num++)
        {
            string tileset_path = $"Tilesets/Tileset{num}.png";
            if (!world.worldFileExists(tileset_path))
            {
                continue;
            }

            string cached_path = $"user://Cache/{world.WorldDirectoryName}/Tileset{num}.res";
            if (!recompile && new File().FileExists(cached_path))
            {
                continue;
            }

            var texture = world.getWorldTexture(tileset_path);
            if (texture is Texture t)
            {
                t = preprocessTilesetTexture(t);
                ResourceSaver.Save(cached_path, makeTileset(t, true), ResourceSaver.SaverFlags.Compress);
            }
        }
    }
コード例 #2
0
ファイル: MapPanel.cs プロジェクト: youkaicountry/yknytt
    public void init(KnyttWorld world, Juni juni)
    {
        SetProcessInput(false);
        SetProcess(false);
        SetPhysicsProcess(false);

        if (world == null || juni == null)
        {
            return;
        }
        this.world = world;
        this.juni  = juni;

        this.RectSize = new Vector2(
            (world.MaxBounds.x - world.MinBounds.x + 1) * XSIZE,
            (world.MaxBounds.y - world.MinBounds.y + 1) * YSIZE);

        foreach (var area in world.Map)
        {
            if (area?.ExtraData == null)
            {
                continue;
            }
            var coord = area.Position;

            int?map_x = int.TryParse(area.ExtraData["MapX"], out var i) ? i : null as int?;
            int?map_y = int.TryParse(area.ExtraData["MapY"], out i) ? i : null as int?;
            if (map_x != null || map_y != null)
            {
                spoofing[coord] = new KnyttPoint(map_x ?? coord.x, map_y ?? coord.y);
            }

            if (area.ExtraData["MapVisible"]?.ToLower() == "true")
            {
                visible[coord] = true;
            }
            if (area.ExtraData["MapVisible"]?.ToLower() == "false")
            {
                visible[coord] = false;
            }

            int?color = int.TryParse(area.ExtraData["MapColor"], out i) ? i : null as int?;
            if (color != null)
            {
                if (color == 64)
                {
                    visible[coord] = false;
                }
                else
                {
                    colors[coord] = new Color((color.Value % 4) / 3f, ((color.Value / 4) % 4) / 3f, ((color.Value / 16) % 4) / 3f);
                }
            }
        }
    }