Esempio n. 1
0
    private void addObject(KnyttPoint coords)
    {
        var bundle = GDKnyttObjectFactory.buildKnyttObject(trigger.ObjectID);

        if (bundle != null)
        {
            Layer.addObject(coords, bundle);
        }
    }
Esempio n. 2
0
    public override void _Ready()
    {
        string key     = $"Custom Object {ObjectID.y}";
        var    section = GDArea.GDWorld.KWorld.INIData[key];

        if (section == null)
        {
            QueueFree(); return;
        }

        int   bank  = getInt(section, "Bank", 0);
        int   obj   = getInt(section, "Object", 0);
        bool  safe  = getString(section, "Hurts")?.ToLower() == "false";
        Color color = new Color(KnyttUtil.BGRToRGBA(KnyttUtil.parseBGRString(getString(section, "Color"), 0xFFFFFF)));

        if (bank != 0 && obj != 0)
        {
            var bundle = GDKnyttObjectFactory.buildKnyttObject(new KnyttPoint(bank, obj));
            if (bundle != null)
            {
                var node = bundle.getNode(Layer, Coords);
                if (safe)
                {
                    node.makeSafe();
                }
                // TODO: make all images from bank 7 white (modulate can't be applied to black color)
                if (bank == 7)
                {
                    node.Modulate = color;
                }
                AddChild(node);
            }
            return;
        }

        info               = new CustomObjectInfo();
        info.image         = getString(section, "Image");
        info.tile_width    = getInt(section, "Tile Width", info.tile_width);
        info.tile_height   = getInt(section, "Tile Height", info.tile_height);
        info.anim_speed    = getInt(section, "Init AnimSpeed", info.anim_speed);
        info.offset_x      = getInt(section, "Offset X", info.offset_x);
        info.offset_y      = getInt(section, "Offset Y", info.offset_y);
        info.anim_repeat   = getInt(section, "Init AnimRepeat", info.anim_repeat);
        info.anim_from     = getInt(section, "Init AnimFrom", info.anim_from);
        info.anim_to       = getInt(section, "Init AnimTo", info.anim_to);
        info.anim_loopback = getInt(section, "Init AnimLoopback", info.anim_loopback);

        sprite = GetNode <AnimatedSprite>("AnimatedSprite");
        fillAnimation($"{GDArea.GDWorld.KWorld.WorldDirectoryName} custom{ObjectID.y}");
        sprite.Play();
    }
    public GDKnyttAssetManager(GDKnyttWorld gdworld, int tile_cache, int gradient_cache, int song_cache, int ambiance_cache, int object_cache)
    {
        this.GDWorld = gdworld;
        Directories  = new Dictionary <string, string>();

        TileSetCache          = new ObjectCache <int, TileSet>(tile_cache);
        TileSetCache.OnCreate = (int num) => buildTileSet(num);

        GradientCache          = new ObjectCache <int, Texture>(gradient_cache);
        GradientCache.OnCreate = (int num) => buildGradient(num);

        SongCache          = new ObjectCache <int, AudioStream>(song_cache);
        SongCache.OnCreate = (int num) => buildSong(num);

        AmbianceCache          = new ObjectCache <int, AudioStream>(ambiance_cache);
        AmbianceCache.OnCreate = (int num) => buildAmbiance(num);

        ObjectCache          = new ObjectCache <KnyttPoint, GDKnyttObjectBundle>(object_cache);
        ObjectCache.OnCreate = (KnyttPoint id) => GDKnyttObjectFactory.buildKnyttObject(id);
    }