private AnimDrawable LoadUpgrade(StructureObject structObj, int upgradeSlot, DrawProperties inheritProps)
        {
            string upgradeName = "";

            if (upgradeSlot == 0)
            {
                upgradeName = structObj.Upgrade1;
            }
            else if (upgradeSlot == 1)
            {
                upgradeName = structObj.Upgrade2;
            }
            else if (upgradeSlot == 2)
            {
                upgradeName = structObj.Upgrade3;
            }

            IniFile.IniSection upgradeRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName);
            if (upgradeRules != null && upgradeRules.HasKey("Image"))
            {
                upgradeName = upgradeRules.ReadString("Image");
            }
            IniFile.IniSection upgradeArt = OwnerCollection.Art.GetOrCreateSection(upgradeName);
            if (upgradeArt != null && upgradeArt.HasKey("Image"))
            {
                upgradeName = upgradeArt.ReadString("Image");
            }

            IniFile.IniSection upgRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName);
            IniFile.IniSection upgArt   = OwnerCollection.Art.GetOrCreateSection(upgradeName);
            AnimDrawable       upgrade  = new AnimDrawable(_config, _vfs, upgRules, upgArt);

            upgrade.OwnerCollection = OwnerCollection;
            upgrade.Props           = inheritProps;
            upgrade.LoadFromRules();
            upgrade.NewTheater     = this.NewTheater;
            upgrade.IsBuildingPart = true;
            string shpfilename = NewTheater ? OwnerCollection.ApplyNewTheaterIfNeeded(upgradeName, upgradeName + ".shp") : upgradeName + ".shp";

            upgrade.Shp = _vfs.Open <ShpFile>(shpfilename);
            Point powerupOffset = new Point(_powerupSlots[upgradeSlot].X, _powerupSlots[upgradeSlot].Y);

            upgrade.Props.Offset.Offset(powerupOffset);
            return(upgrade);
        }
        private AnimDrawable LoadExtraImage(string extraImage, DrawProperties inheritProps)
        {
            string animSection = Art.ReadString(extraImage);

            if (animSection == "")
            {
                return(null);
            }

            IniFile.IniSection extraRules = OwnerCollection.Rules.GetOrCreateSection(animSection);
            IniFile.IniSection extraArt   = OwnerCollection.Art.GetOrCreateSection(animSection);
            var anim = new AnimDrawable(_config, _vfs, extraRules, extraArt);

            anim.OwnerCollection = OwnerCollection;
            anim.LoadFromRules();

            anim.NewTheater = this.NewTheater;

            if (extraArt.HasKey("YSortAdjust") || Art.HasKey(extraImage + "YSort") ||
                extraArt.HasKey("ZAdjust") || Art.HasKey(extraImage + "ZAdjust"))
            {
                anim.Props.SortIndex = extraArt.ReadInt("YSortAdjust", Art.ReadInt(extraImage + "YSort"))
                                       - extraArt.ReadInt("ZAdjust", Art.ReadInt(extraImage + "ZAdjust"));
            }
            else
            {
                anim.Props.SortIndex = inheritProps.SortIndex;
            }
            if (Art.HasKey(extraImage + "X") || Art.HasKey(extraImage + "Y"))
            {
                anim.Props.Offset = this.Props.Offset + new Size(Art.ReadInt(extraImage + "X"), Art.ReadInt(extraImage + "Y"));
            }
            else
            {
                anim.Props.Offset = inheritProps.Offset;
            }
            anim.Props.ZAdjust  = Art.ReadInt(extraImage + "ZAdjust");
            anim.IsBuildingPart = true;

            anim.Shp = _vfs.Open <ShpFile>(anim.GetFilename());
            return(anim);
        }