Пример #1
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();
    }
Пример #2
0
 public static Color getCutsceneColor(string name = null)
 {
     return(new Color(KnyttUtil.BGRToRGBA(KnyttUtil.parseBGRString(
                                              GDKnyttDataStore.KWorld.INIData["Cutscene Color"][name ?? GDKnyttDataStore.CutsceneName], 0xFFFFFF))));
 }