Example #1
0
        public FlagVM(GameVM game, AmfObject flags, XmlEnum data, int index)
        {
            _flagArray = flags;
            _game = game;
            _index = index;
            _label = data != null ? data.Name : "";
            _comment = data != null ? data.Description : "";
            if (!String.IsNullOrEmpty(_comment)) _label = _label + "\u202F*";

            var value = flags[_index];
            if (value is AmfObject) _valueTrait = ((AmfObject)value).Trait;
            _valueLabel = flags.GetString(_index);

            GameVMProperties = new HashSet<string>();
        }
Example #2
0
        public GameVM(AmfFile file, GameVM previousVM, bool isRevampMod = false)
            : base(file)
        {
            if (previousVM != null)
            {
                _itemSearchText = previousVM._itemSearchText;
                _perkSearchText = previousVM._perkSearchText;
                _rawDataSearchText = previousVM._rawDataSearchText;
                _keyItemSearchText = previousVM._keyItemSearchText;
            }

            // Is this save from vanilla CoC or the CoC-Revamp-Mod?
            IsRevampMod = isRevampMod;

            // Unique children
            Ass = new AssVM(file.GetObj("ass"));
            LipPiercing = new PiercingVM(file, "lip", PiercingLocation.Lip);
            NosePiercing = new PiercingVM(file, "nose", PiercingLocation.Nose);
            EarsPiercing = new PiercingVM(file, "ears", PiercingLocation.Ears);
            EyebrowPiercing = new PiercingVM(file, "eyebrow", PiercingLocation.Eyebrow);
            NipplesPiercing = new PiercingVM(file, "nipples", PiercingLocation.Nipples);
            TonguePiercing = new PiercingVM(file, "tongue", PiercingLocation.Tongue);

            // Collections
            Cocks = new CockArrayVM(this, file.GetObj("cocks"));
            Vaginas = new VaginaArrayVM(file.GetObj("vaginas"));
            Breasts = new BreastArrayVM(this, file.GetObj("breastRows"));
            Vaginas.CollectionChanged += OnGenitalCollectionChanged;
            Breasts.CollectionChanged += OnGenitalCollectionChanged;
            Cocks.CollectionChanged += OnGenitalCollectionChanged;

            // Flags
            int numFlags = XmlData.Current.Flags.Max(x => x.ID) + 25; // was 200; I'm unsure if there's really a need for a buffer at all anymore
            var xmlFlagByID = new XmlEnum[numFlags];
            foreach(var xml in XmlData.Current.Flags) xmlFlagByID[xml.ID] = xml;

            var flagsArray = GetObj("flags");
            if (flagsArray == null)
            {
                // For very old versions of CoC
                _obj["flags"] = flagsArray = new AmfObject(AmfTypes.Array);
                for (int i = 0; i < 3000; ++i) flagsArray.Push(0);
            }
            _allFlags = new FlagVM[numFlags];
            for (int i = 0; i < _allFlags.Length; ++i) _allFlags[i] = new FlagVM(this, flagsArray, xmlFlagByID[i], i);
            Flags = new UpdatableCollection<FlagVM>(_allFlags.Where(x => x.Index > 0 && x.Match(_rawDataSearchText)));

            // Statuses
            var cocStatuses = file.GetObj("statusAffects");
            var xmlStatuses = XmlData.Current.Statuses;
            ImportMissingNamedVectors(cocStatuses, xmlStatuses, "statusAffectName");
            _allStatuses = XmlData.Current.Statuses.OrderBy(x => x.Name).Select(x => new StatusVM(this, cocStatuses, x)).ToArray();
            Statuses = new UpdatableCollection<StatusVM>(_allStatuses.Where(x => x.Match(_rawDataSearchText)));

            // KeyItems
            var cocKeys = file.GetObj("keyItems");
            var xmlKeys = XmlData.Current.KeyItems;
            ImportMissingNamedVectors(cocKeys, xmlKeys, "keyName");
            _allKeyitems = XmlData.Current.KeyItems.OrderBy(x => x.Name).Select(x => new KeyItemVM(this, cocKeys, x)).ToArray();
            KeyItems = new UpdatableCollection<KeyItemVM>(_allKeyitems.Where(x => x.Match(_keyItemSearchText)));

            // Perks
            var cocPerks = _obj.GetObj("perks");
            var xmlPerks = XmlData.Current.PerkGroups.SelectMany(x => x.Perks).ToArray();
            var unknownPerkGroup = XmlData.Current.PerkGroups.Last();
            ImportMissingNamedVectors(cocPerks, xmlPerks, "id", null, unknownPerkGroup.Perks);

            PerkGroups = new List<PerkGroupVM>();
            foreach (var xmlGroup in XmlData.Current.PerkGroups)
            {
                var perksVM = xmlGroup.Perks.OrderBy(x => x.Name).Select(x => new PerkVM(this, cocPerks, x)).ToArray();
                _allPerks.AddRange(perksVM);

                var groupVM = new PerkGroupVM(this, xmlGroup.Name, perksVM);
                PerkGroups.Add(groupVM);
            }

            // Item containers
            var containers = new List<ItemContainerVM>();
            _inventory = new ItemContainerVM(this, "Inventory", ItemCategories.All);
            containers.Add(_inventory);
            UpdateInventory();

            _chest = new ItemContainerVM(this, IsRevampMod ? "Chest(s)" : "Chest", ItemCategories.All);
            containers.Add(_chest);
            UpdateChest();

            _weaponRack = new ItemContainerVM(this, "Weapon rack", ItemCategories.Weapon | ItemCategories.Unknown);
            containers.Add(_weaponRack);
            UpdateWeaponRack();

            _armorRack = new ItemContainerVM(this, "Armor rack", ItemCategories.Armor | ItemCategories.ArmorCursed | ItemCategories.Unknown);
            containers.Add(_armorRack);
            UpdateArmorRack();

            if (IsRevampMod)
            {
                _shieldRack = new ItemContainerVM(this, "Shield rack", ItemCategories.Shield | ItemCategories.Unknown);
                containers.Add(_shieldRack);
                UpdateShieldRack();

                _dresser = new ItemContainerVM(this, "Dresser", ItemCategories.Undergarment | ItemCategories.Unknown);
                containers.Add(_dresser);
                UpdateDresser();

                _jewelryBox = new ItemContainerVM(this, "Jewelry box", ItemCategories.Jewelry | ItemCategories.Unknown);
                containers.Add(_jewelryBox);
                UpdateJewelryBox();
            }

            // Import missing items
            var unknownItemGroup = XmlData.Current.ItemGroups.Last();

            foreach (var slot in containers.SelectMany(x => x.Slots))
            {
                // Add this item to the DB if it does not exist
                var type = slot.Type;
                if (String.IsNullOrEmpty(type)) continue;
                if (XmlData.Current.ItemGroups.SelectMany(x => x.Items).Any(x => x.ID == type)) continue;

                var xml = new XmlItem { ID = type, Name = type };
                unknownItemGroup.Items.Add(xml);
            }
            foreach (var slot in containers.SelectMany(x => x.Slots)) slot.UpdateGroups(); // Update item groups after new items have been added

            // Complete slots creation
            ItemContainers = new UpdatableCollection<ItemContainerVM>(containers.Where(x => x.Slots.Count != 0));
        }