public async Task <InventoryMaster> DeleteInventory(InventoryMaster inventoryMaster)
        {
            _context.InventoryMaster.Remove(inventoryMaster);
            await _context.SaveChangesAsync();

            return(inventoryMaster);
        }
        public async Task <InventoryMaster> AddInventory(InventoryMaster inventoryMaster)
        {
            _context.InventoryMaster.Add(inventoryMaster);
            await _context.SaveChangesAsync();

            return(inventoryMaster);
        }
        public async Task <InventoryMaster> UpdateInventory(InventoryMaster inventoryMaster)
        {
            _context.Entry(inventoryMaster).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(inventoryMaster);
        }
        public bool Update([FromBody] InventoryMaster _oInventoryMaster)
        {
            try
            {
                int output;
                using (var context = new DB001Core())
                {
                    var input = context.InventoryMasters
                                .Where(s => s.InventoryID == _oInventoryMaster.InventoryID)
                                .FirstOrDefault();

                    input.ReferenceNumber = _oInventoryMaster.ReferenceNumber;
                    input.InventoryType   = _oInventoryMaster.InventoryType;
                    input.WarrantyDate    = _oInventoryMaster.WarrantyDate;
                    input.DeviceID        = _oInventoryMaster.DeviceID;
                    input.SpareID         = _oInventoryMaster.SpareID;

                    output = context.SaveChanges();
                }
                return(Convert.ToBoolean(output));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                context = null;
            }
        }
        public async Task <IActionResult> PostInventoryMaster([FromBody] InventoryMaster InventoryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.InventoryMaster.Add(InventoryMaster);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (InventoryMasterExists(InventoryMaster.InventoryID))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetInventoryMaster", new { id = InventoryMaster.InventoryID }, InventoryMaster));
        }
        public async Task <IActionResult> PutInventoryMaster([FromRoute] int id, [FromBody] InventoryMaster InventoryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != InventoryMaster.InventoryID)
            {
                return(BadRequest());
            }

            _context.Entry(InventoryMaster).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InventoryMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #7
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            List <ulong> masters = track[0x75];
            List <ulong> blank   = new List <ulong>();
            Dictionary <ulong, ulong> blankdict = new Dictionary <ulong, ulong>();
            List <string>             extract   = new List <string>();

            for (int i = 3; i < flags.Positionals.Length; ++i)
            {
                extract.Add(flags.Positionals[i].ToLowerInvariant());
            }
            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));
                if (masterStud.Instances == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                if (extract.Count > 0 && !extract.Contains(heroName.ToLowerInvariant()))
                {
                    continue;
                }
                if (master.Header.itemMaster.key != 0)   // AI
                {
                    InventoryMaster inventory = Extract.OpenInventoryMaster(master, map, handler);
                    if (inventory.ItemGroups.Length > 0 || inventory.DefaultGroups.Length > 0)
                    {
                        continue;
                    }
                }
                Console.Out.WriteLine("{0} {1:X}", heroName, GUID.Index(masterKey));
                string path = string.Format("{0}{1}{2}{1}{3:X}{1}", flags.Positionals[2], Path.DirectorySeparatorChar, Util.Strip(Util.SanitizePath(heroName)), GUID.LongKey(masterKey));

                HashSet <ulong>           models              = new HashSet <ulong>();
                Dictionary <ulong, ulong> animList            = new Dictionary <ulong, ulong>();
                HashSet <ulong>           parsed              = new HashSet <ulong>();
                Dictionary <ulong, List <ImageLayer> > layers = new Dictionary <ulong, List <ImageLayer> >();
                Dictionary <ulong, List <ulong> >      sound  = new Dictionary <ulong, List <ulong> >();

                ExtractLogic.Skin.FindModels(master.Header.binding, blank, models, animList, layers, blankdict, parsed, map, handler, sound);

                ExtractLogic.Skin.Save(master, path, heroName, $"{GUID.LongKey(masterKey):X}", blankdict, parsed, models, layers, animList, flags, track, map, handler, masterKey, false, quiet, sound, 0);
            }
        }
Пример #8
0
    public void Start()
    {
        if (s != null && s != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            s = this;
        }

        bool isThere = false;

        if (SaveMaster.toSave != null)
        {
            foreach (SaveMaster.SaveDelegate del in SaveMaster.toSave.GetInvocationList())
            {
                if (del == Save)
                {
                    isThere = true;
                    break;
                }
            }
        }

        if (!isThere)
        {
            SaveMaster.toSave += Save;
        }

        if (SaveMaster.s.mySave.activeEquipment != "none")
        {
            activeEquipment = myEquipments.Find(x => x.item.name == SaveMaster.s.mySave.activeEquipment);
        }
        else
        {
            activeEquipment = null;
        }

        selectedElement = SaveMaster.s.mySave.selectedElement;
        elementLevel    = SaveMaster.s.mySave.elementLevel;

        LoadInventory();

#if UNITY_EDITOR
        if (cheatInventory)
        {
            CheatInventory();
        }
#endif

        /*if (SceneMaster.s.curScene == 0) {
         *      MenuSwitchController.s.GetComponent<CharacterMenuController> ().SetEquipped ();
         *      ElementSelector.s.UpdateElementSliders ();
         * }*/
    }
Пример #9
0
    public void UnlockAllItems()
    {
        InventoryMaster invMaster = GetComponent <InventoryMaster>();

        foreach (List <GameObject> list in invMaster.AllItems)
        {
            foreach (GameObject obj in list)
            {
                obj.GetComponent <PowerupMain>().SetOwned(true);
            }
        }
    }
        public bool Delete([FromBody] InventoryMaster _oInventoryMaster)
        {
            try
            {
                int output;
                using (var context = new DB001Core())
                {
                    context.Remove <InventoryMaster>(_oInventoryMaster);

                    output = context.SaveChanges();
                }

                if (_oInventoryMaster.DeviceID != null)
                {
                    using (var context = new DB001Core())
                    {
                        var input = context.DeviceMasters
                                    .Where(s => s.DeviceID == _oInventoryMaster.DeviceID)
                                    .FirstOrDefault();

                        input.Stock = input.Stock + 1;

                        output = context.SaveChanges();
                    }
                }

                if (_oInventoryMaster.SpareID != null)
                {
                    using (var context = new DB001Core())
                    {
                        var input = context.SpareMasters
                                    .Where(s => s.SpareID == _oInventoryMaster.SpareID)
                                    .FirstOrDefault();

                        input.Stock = input.Stock + 1;

                        output = context.SaveChanges();
                    }
                }

                return(Convert.ToBoolean(output));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                context = null;
            }
        }
Пример #11
0
        public static InventoryMaster OpenInventoryMaster(HeroMaster master, Dictionary <ulong, Record> map, CASCHandler handler)
        {
            if (!map.ContainsKey(master.Header.itemMaster.key))
            {
                return(null);
            }
            STUD            inventoryStud = new STUD(Util.OpenFile(map[master.Header.itemMaster.key], handler));
            InventoryMaster inventory     = (InventoryMaster)inventoryStud.Instances[0];

            if (inventory == null)
            {
                return(null);
            }
            return(inventory);
        }
Пример #12
0
    public void StartNewGame()
    {
        PlayerPrefs.SetInt("CurrentLevel", 0);
        PlayerPrefs.SetString("Unlocks", "");
        InventoryMaster invMaster = GetComponent <InventoryMaster>();

        foreach (List <GameObject> list in invMaster.AllItems)
        {
            foreach (GameObject obj in list)
            {
                obj.GetComponent <PowerupMain>().SetOwned(false);
            }
        }
        nextLevel = 0;
        StartNextLevel();
    }
Пример #13
0
            public override string Execute(string original)
            {
                original = original.Replace("${Gs2::Weave::InventoryNamespaceName}", _installer.inventoryNamespaceName);
                original = original.Replace("${Gs2::Weave::EnableDebugAcquireItemAction}", _installer.enableDebugAcquireItemAction.ToString());
                if (_installer.enableDebugAcquireItemAction)
                {
                    original = original.Replace("${Gs2::Weave::IdentifierAcquireItemPolicyName}", _installer.identifierAcquireItemPolicyName);
                    original = original.Replace("${Gs2::Weave::IdentifierAcquireItemUserName}", _installer.identifierAcquireItemUserName);
                }
                else
                {
                    var json = JsonMapper.ToObject(original);
                    json["Globals"]["Alias"].Remove("IdentifierAcquireItemPolicyName");
                    json["Globals"]["Alias"].Remove("IdentifierAcquireItemUserName");
                    json["Resources"].Remove("IdentifierAcquireItemUser");
                    json["Resources"].Remove("IdentifierAcquireItemPolicy");
                    json["Resources"].Remove("IdentifierAcquireItemUserAttachPolicy");
                    json["Resources"].Remove("IdentifierAcquireItemIdentifier");
                    json["Outputs"].Remove("IdentifierAcquireItemPolicyName");
                    json["Outputs"].Remove("IdentifierAcquireItemUserName");
                    json["Outputs"].Remove("IdentifierAcquireItemClientId");
                    json["Outputs"].Remove("IdentifierAcquireItemClientSecret");
                    original = json.ToJson();
                }

                {
                    var master = new InventoryMaster
                    {
                        inventoryModels = new List <WeaveInventoryModel>
                        {
                            _installer.inventoryModel
                        }
                    };

                    var stringBuilder = new StringBuilder();
                    var jsonWriter    = new JsonWriter(stringBuilder);
                    master.WriteJson(jsonWriter);

                    var json = JsonMapper.ToObject(original);
                    json["Resources"]["InventorySettings"]["Properties"]["Settings"] = stringBuilder.ToString();
                    original = json.ToJson();
                }

                return(original);
            }
Пример #14
0
        public async Task <IActionResult> DeleteInventoryMaster([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            InventoryMaster InventoryMaster = await _context.InventoryMaster.SingleOrDefaultAsync(m => m.InventoryID == id);

            if (InventoryMaster == null)
            {
                return(NotFound());
            }

            _context.InventoryMaster.Remove(InventoryMaster);
            await _context.SaveChangesAsync();

            return(Ok(InventoryMaster));
        }
Пример #15
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            List <ulong> masters = track[0x75];

            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));
                if (masterStud.Instances == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                if (master.Header.itemMaster.key != 0)   // AI
                {
                    InventoryMaster inventory = Extract.OpenInventoryMaster(master, map, handler);
                    if (inventory.ItemGroups.Length > 0 || inventory.DefaultGroups.Length > 0)
                    {
                        continue;
                    }
                }
                Console.Out.WriteLine("{0} {1:X}", heroName, GUID.LongKey(masterKey));
            }
        }
Пример #16
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            List <ulong> masters = track[0x75];

            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));

                if (masterStud.Instances == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                string goodhero = heroName;
                foreach (var c in Path.GetInvalidFileNameChars())
                {
                    goodhero = goodhero.Replace(c, '_');
                }

                if (master.Header.itemMaster.key == 0)   // AI
                {
                    continue;
                }
                bool ex = System.Diagnostics.Debugger.IsAttached || flags.Expert;

                bool hasName = false;
                if (!map.ContainsKey(master.Header.itemMaster.key))
                {
                    Console.Out.WriteLine("Error loading inventory master file...");
                    continue;
                }
                STUD inventoryStud = new STUD(Util.OpenFile(map[master.Header.itemMaster.key], handler));
#if OUTPUT_STUDINVENTORYMASTER
                Stream studStream  = Util.OpenFile(map[master.Header.itemMaster.key], handler);
                string outFilename = string.Format("./STUDs/ListInventoryMaster/{0}.stud", goodhero);
                string putPathname = outFilename.Substring(0, outFilename.LastIndexOf('/'));
                Directory.CreateDirectory(putPathname);
                Stream OutWriter = File.Create(outFilename);
                studStream.CopyTo(OutWriter);
                OutWriter.Close();
                studStream.Close();
#endif
                InventoryMaster inventory = (InventoryMaster)inventoryStud.Instances[0];
                if (inventory == null)
                {
                    Console.Out.WriteLine("Error loading inventory master file...");
                    continue;
                }

                Dictionary <int, string> indexMap = new Dictionary <int, string>();
                List <OWRecord>          items    = new List <OWRecord>();

                items.AddRange(inventory.Achievables.ToList());

                for (int i = 0; i < inventory.DefaultGroups.Length; ++i)
                {
                    string name = $"STANDARD_{ItemEvents.GetInstance().GetEvent(inventory.DefaultGroups[i].@event)}";
                    items.AddRange(inventory.Defaults[i].ToList());
                }

                for (int i = 0; i < inventory.ItemGroups.Length; ++i)
                {
                    string name = ItemEvents.GetInstance().GetEvent(inventory.ItemGroups[i].@event);
                    items.AddRange(inventory.Items[i].ToList());
                }

                foreach (OWRecord record in items)
                {
                    STUD item = new STUD(Util.OpenFile(map[record], handler));
                    if (item.Instances == null)
                    {
                        continue;
                    }
                    WeaponSkinItem skin = item.Instances[0] as WeaponSkinItem;
                    if (skin == null)
                    {
                        continue;
                    }
                    if (!hasName)
                    {
                        if (ex)
                        {
                            Console.Out.WriteLine("Weapons for {0} ({2:X16}) in package {1:X16}", heroName, map[masterKey].package.packageKey, masterKey);
                        }
                        else
                        {
                            Console.Out.WriteLine("Weapons for {0}", heroName);
                        }
                        hasName = true;
                    }

                    Console.Out.WriteLine("\tIndex {0} - {1}", skin.Data.index, Util.GetString(skin.Header.name, map, handler));
                }

                if (hasName)
                {
                    Console.Out.WriteLine("");
                }
            }
        }
Пример #17
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            List <ulong> masters = track[0x75];

            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));

                if (masterStud.Instances == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                string goodhero = heroName;
                foreach (var c in Path.GetInvalidFileNameChars())
                {
                    goodhero = goodhero.Replace(c, '_');
                }

                if (master.Header.itemMaster.key == 0)   // AI
                {
                    continue;
                }
                bool ex = System.Diagnostics.Debugger.IsAttached || flags.Expert;
                if (ex)
                {
                    Console.Out.WriteLine("Cosmetics for {0} ({1:X16})", heroName, GUID.LongKey(masterKey));
                }
                else
                {
                    Console.Out.WriteLine("Cosmetics for {0}", heroName);
                }
                if (!map.ContainsKey(master.Header.itemMaster.key))
                {
                    Console.Out.WriteLine("Error loading inventory master file...");
                    continue;
                }
                STUD inventoryStud = new STUD(Util.OpenFile(map[master.Header.itemMaster.key], handler));
#if OUTPUT_STUDINVENTORYMASTER
                Stream studStream  = Util.OpenFile(map[master.Header.itemMaster.key], handler);
                string outFilename = string.Format("./STUDs/ListInventoryMaster/{0}.stud", goodhero);
                string putPathname = outFilename.Substring(0, outFilename.LastIndexOf('/'));
                Directory.CreateDirectory(putPathname);
                Stream OutWriter = File.Create(outFilename);
                studStream.CopyTo(OutWriter);
                OutWriter.Close();
                studStream.Close();
#endif
                InventoryMaster inventory = (InventoryMaster)inventoryStud.Instances[0];
                if (inventory == null)
                {
                    Console.Out.WriteLine("Error loading inventory master file...");
                    continue;
                }

                Console.Out.WriteLine("\tACHIEVEMENT ({0} items)", inventory.Achievables.Length);
                foreach (OWRecord record in inventory.Achievables)
                {
                    GetInventoryName(record.key, ex, map, handler, goodhero);
                }

                for (int i = 0; i < inventory.DefaultGroups.Length; ++i)
                {
                    if (inventory.Defaults[i].Length == 0)
                    {
                        continue;
                    }
                    OWRecord[] records = inventory.Defaults[i];
                    Console.Out.WriteLine("\tSTANDARD_{0} ({1} items)", ItemEvents.GetInstance().GetEvent(inventory.DefaultGroups[i].@event), records.Length);
                    foreach (OWRecord record in records)
                    {
                        GetInventoryName(record.key, ex, map, handler, goodhero);
                    }
                }

                for (int i = 0; i < inventory.ItemGroups.Length; ++i)
                {
                    if (inventory.Items[i].Length == 0)
                    {
                        continue;
                    }
                    OWRecord[] records = inventory.Items[i];
                    Console.Out.WriteLine("\t{0} ({1} items)", ItemEvents.GetInstance().GetEvent(inventory.ItemGroups[i].@event), records.Length);
                    foreach (OWRecord record in records)
                    {
                        GetInventoryName(record.key, ex, map, handler, goodhero);
                    }
                }
                Console.Out.WriteLine("");
            }
        }
Пример #18
0
    /// <summary>
    /// Sets all of the saved Unlocks to be Owned.
    /// </summary>
    /// <remarks>
    /// Uses the string at PlayerPrefs["Unlocks"]. The string is broken apart and
    /// read to find the item which is owned and the list which contains it in the
    /// InventoryMaster class. Upon finding the correct prefab with a PowerupMain
    /// component, calls the SetOwned method with true.
    /// </remarks>
    private void LoadSavedUnlocks()
    {
        InventoryMaster invMast = gameObject.GetComponent <InventoryMaster>();
        // Get the things that are unlocked
        string ownedItemsStr = PlayerPrefs.GetString("Unlocks"); // follows the form "<slot>:<item name>,<slot>:<item name>,..."

        string[] ownedItems = ownedItemsStr.Split(',');
        foreach (string item in ownedItems)
        {
            if (item == "")
            {
                continue;
            }
            string[] itemParts = item.Split(':');
            string   slot      = itemParts[0];
            string   itemName  = itemParts[1];
            if (itemName == "stick" || itemName == "Bronze Medal" || itemName == "Silver Medal" || itemName == "Gold Medal")
            {
                continue;
            }
            System.Predicate <GameObject> findByName = (gO) => gO.name == itemName;
            switch (slot)
            {
            case "Bumpers":
                invMast.BumperMods.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);    // Look for the game object in this list with the
                break;                                                                              // name that matches itemName, then grab its PowerupMain and call SetOwned

            case "Engine":
                invMast.EngineMods.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Frame":
                invMast.FrameMods.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Tires":
                invMast.TireMods.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Trunk":
                invMast.TrunkMods.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Grill":
                invMast.GrillWeapons.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Hitch":
                invMast.HitchWeapons.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Roof":
                invMast.RoofWeapons.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Doors":
                invMast.DoorWeapons.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            case "Wheels":
                invMast.WheelWeapons.Find(findByName).GetComponent <PowerupMain>().SetOwned(true);
                break;

            default:
                break;
            }
        }
    }
        public int Add([FromBody] InventoryMaster _oInventoryMaster)
        {
            try
            {
                int  output;
                bool IsStockAvailable = true;

                if (_oInventoryMaster.DeviceID != null)
                {
                    using (var context = new DB001Core())
                    {
                        var input = context.DeviceMasters
                                    .Where(s => s.DeviceID == _oInventoryMaster.DeviceID)
                                    .FirstOrDefault();

                        if (input.Stock <= 0)
                        {
                            IsStockAvailable = false;
                        }
                        else
                        {
                            input.Stock = input.Stock - 1;
                            output      = context.SaveChanges();
                        }
                    }
                }

                if (_oInventoryMaster.SpareID != null)
                {
                    using (var context = new DB001Core())
                    {
                        var input = context.SpareMasters
                                    .Where(s => s.SpareID == _oInventoryMaster.SpareID)
                                    .FirstOrDefault();

                        if (input.Stock <= 0)
                        {
                            IsStockAvailable = false;
                        }
                        else
                        {
                            input.Stock = input.Stock - 1;
                            output      = context.SaveChanges();
                        }
                    }
                }


                if (IsStockAvailable)
                {
                    using (var context = new DB001Core())
                    {
                        context.InventoryMasters.Add(_oInventoryMaster);
                        output = context.SaveChanges();
                    }
                }
                else
                {
                    output = -1;
                }
                return(output);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                context = null;
            }
        }
Пример #20
0
        public void Create(ProcurementMasterViewModel ProcurementMasterViewModel, ProcurementDetailsViewModel[] procurementDetailsViewModel, int intStoreId, string strUserName)
        {
            ProcurementMaster ProcurementMaster = new ProcurementMaster();


            ProcurementMaster.DateOfPurchase       = ProcurementMasterViewModel.DateOfPurchase;
            ProcurementMaster.DateOfReceive        = ProcurementMasterViewModel.DateOfReceive;
            ProcurementMaster.PO_GRAND_TOTAL       = ProcurementMasterViewModel.PO_GRAND_TOTAL;
            ProcurementMaster.ProcurementTypeId    = ProcurementMasterViewModel.ProcurementTypeId;
            ProcurementMaster.SupplierCompanyId    = ProcurementMasterViewModel.SupplierCompanyId;
            ProcurementMaster.SubContractCompanyId = ProcurementMasterViewModel.SubContractCompanyId;
            if (intStoreId >= 1000 && intStoreId < 2000)
            {
                ProcurementMaster.StoreId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                ProcurementMaster.SubStoreId = intStoreId;
            }
            else if (intStoreId >= 3000 && intStoreId < 4000)
            {
                ProcurementMaster.SubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 4000 && intStoreId < 5000)
            {
                ProcurementMaster.SubSubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 5000 && intStoreId < 6000)
            {
                ProcurementMaster.SubSubSubSubStoreId = intStoreId;
            }
            ProcurementMaster.PurchasedBy_ProcureBy = 1;
            ProcurementMaster.CreateBy   = strUserName;
            ProcurementMaster.CreateDate = DateTime.Now;
            ProcurementMaster.UpdateBy   = strUserName;
            ProcurementMaster.UpdateDate = DateTime.Now;



            UnitOfWork.ProcurementMasterRepository.Insert(ProcurementMaster);
            UnitOfWork.Save();

            var Pohdid = ProcurementMaster.PO_HD_ID;

            foreach (var items in procurementDetailsViewModel)
            {
                var ProcurementDetails = new ProcurementDetails
                {
                    PO_HD_ID               = Pohdid,
                    DateOfExpired          = Convert.ToDateTime(items.DateOfExpired),
                    DateOfNextMaintainance = Convert.ToDateTime(items.DateOfNextMaintainance),
                    Barcode                = items.Barcode,
                    Item_Unique_Number     = items.Item_Unique_Number,
                    Chesis_Number          = items.Chesis_Number,
                    Engine_Number          = items.Engine_Number,
                    ItemId                 = items.ItemId,
                    CountryId              = items.CountryId,
                    Principle_id           = items.Principle_id,
                    ConditionOfItemId      = items.ConditionOfItemId,
                    WarrantyId             = items.WarrantyId,
                    PO_QTD                 = items.PO_QTD,
                    PO_Price               = items.PO_Price,
                    SO_Price               = items.SO_Price,
                    PO_SubTotal            = items.PO_SubTotal,
                    CategoryId             = items.CategoryId,
                    SubCategoryId          = items.SubCategoryId,
                    SubSubCategoryId       = items.SubSubCategoryId,
                    SubSubSubCategoryId    = items.SubSubSubCategoryId,
                    SubSubSubSubCategoryId = items.SubSubSubSubCategoryId,
                    BrandId                = items.BrandId,
                    ModelId                = items.ModelId,
                    UnitId                 = items.UnitId,
                    MethodId               = items.MethodId,
                    IsNew = items.IsNew,
                    IsHot = items.IsHot
                };

                UnitOfWork.ProcurementDetailsRepository.Insert(ProcurementDetails);
                UnitOfWork.Save();
            }

            InventoryMaster InventoryMaster = new InventoryMaster();

            InventoryMaster.PO_HD_ID             = Pohdid;
            InventoryMaster.DateOfPurchase       = ProcurementMasterViewModel.DateOfPurchase;
            InventoryMaster.DateOfReceive        = ProcurementMasterViewModel.DateOfReceive;
            InventoryMaster.PO_GRAND_TOTAL       = ProcurementMasterViewModel.PO_GRAND_TOTAL;
            InventoryMaster.ProcurementTypeId    = ProcurementMasterViewModel.ProcurementTypeId;
            InventoryMaster.SupplierCompanyId    = ProcurementMasterViewModel.SupplierCompanyId;
            InventoryMaster.SubContractCompanyId = ProcurementMasterViewModel.SubContractCompanyId;
            if (intStoreId >= 1000 && intStoreId < 2000)
            {
                InventoryMaster.StoreId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                InventoryMaster.SubStoreId = intStoreId;
            }
            else if (intStoreId >= 3000 && intStoreId < 4000)
            {
                InventoryMaster.SubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 4000 && intStoreId < 5000)
            {
                InventoryMaster.SubSubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 5000 && intStoreId < 6000)
            {
                InventoryMaster.SubSubSubSubStoreId = intStoreId;
            }
            InventoryMaster.PurchasedBy_ProcureBy = 1;
            InventoryMaster.CreateBy   = strUserName;
            InventoryMaster.CreateDate = DateTime.Now;
            InventoryMaster.UpdateBy   = strUserName;
            InventoryMaster.UpdateDate = DateTime.Now;



            UnitOfWork.InventoryMasterRepository.Insert(InventoryMaster);
            UnitOfWork.Save();



            var invId = InventoryMaster.Inv_HD_ID;


            foreach (var items in procurementDetailsViewModel)
            {
                InventoryDetail InventoryDetails = new InventoryDetail();

                InventoryDetails.Inv_HD_ID              = invId;
                InventoryDetails.DateOfExpired          = Convert.ToDateTime(items.DateOfExpired);
                InventoryDetails.DateOfNextMaintainance = Convert.ToDateTime(items.DateOfNextMaintainance);
                InventoryDetails.Barcode                = items.Barcode;
                InventoryDetails.Item_Unique_Number     = items.Item_Unique_Number;
                InventoryDetails.Chesis_Number          = items.Chesis_Number;
                InventoryDetails.Engine_Number          = items.Engine_Number;
                InventoryDetails.ItemId                 = items.ItemId;
                InventoryDetails.CountryId              = items.CountryId;
                InventoryDetails.Principle_id           = items.Principle_id;
                InventoryDetails.ConditionOfItemId      = items.ConditionOfItemId;
                InventoryDetails.WarrantyId             = items.WarrantyId;
                InventoryDetails.TransactionQty         = items.PO_QTD;
                InventoryDetails.PO_Price               = items.PO_Price;
                InventoryDetails.SO_Price               = items.SO_Price;
                InventoryDetails.PO_SubTotal            = items.PO_SubTotal;
                InventoryDetails.CategoryId             = items.CategoryId;
                InventoryDetails.SubCategoryId          = items.SubCategoryId;
                InventoryDetails.SubSubCategoryId       = items.SubSubCategoryId;
                InventoryDetails.SubSubSubCategoryId    = items.SubSubSubCategoryId;
                InventoryDetails.SubSubSubSubCategoryId = items.SubSubSubSubCategoryId;
                InventoryDetails.BrandId                = items.BrandId;
                InventoryDetails.ModelId                = items.ModelId;
                InventoryDetails.UnitId                 = items.UnitId;
                InventoryDetails.MethodId               = items.MethodId;
                InventoryDetails.AvailableQty           = items.PO_QTD;
                InventoryDetails.IsNew = items.IsNew;
                InventoryDetails.IsHot = items.IsHot;
                UnitOfWork.InventoryDetailRepository.Insert(InventoryDetails);
                UnitOfWork.Save();
            }
        }
Пример #21
0
        public void Create(ProductionMasterViewModel ProductionMasterViewModel, ProductionDetailsViewModel[] productionDetailsViewModels, int?intStoreId)
        {
            int?StorId             = null;
            int?SubStorId          = null;
            int?SubSubStorId       = null;
            int?SubSubSubStorId    = null;
            int?SubSubSubSubStorId = null;

            if (intStoreId >= 1000 && intStoreId < 2000)
            {
                StorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubStorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubSubStorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubSubSubStorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubSubSubSubStorId = intStoreId;
            }



            ProductionMaster Producionheader = new ProductionMaster();

            Producionheader.ProductId           = ProductionMasterViewModel.ProductId;
            Producionheader.ProductionQuantity  = ProductionMasterViewModel.ProductionQuantity;
            Producionheader.ProductPrice        = ProductionMasterViewModel.ProductPrice;
            Producionheader.Productiondate      = DateTime.Now;
            Producionheader.StoreId             = StorId;
            Producionheader.SubStoreId          = SubStorId;
            Producionheader.SubSubStoreId       = SubSubStorId;
            Producionheader.SubSubSubStoreId    = SubSubSubStorId;
            Producionheader.SubSubSubSubStoreId = SubSubSubSubStorId;

            unitOfWork.ProductionMasterRepository.Insert(Producionheader);
            unitOfWork.Save();

            var Productionhdid = Producionheader.ProductionMasterId;

            foreach (var items in productionDetailsViewModels)
            {
                var productionDetails = new ProductionDetails
                {
                    ProductionMasterId = Productionhdid,
                    ItemId             = items.ItemId,
                    ItemQuantity       = items.ItemQuantity,
                    ItemCost           = items.ItemCost,
                    SubTotal           = items.SubTotal
                };
                unitOfWork.ProductionDetailsRepository.Insert(productionDetails);
                unitOfWork.Save();


                var avalableqty = unitOfWork.InventoryMasterRepository.Get().Join(unitOfWork.InventoryDetailRepository.Get(),
                                                                                  (invd => invd.Inv_HD_ID),
                                                                                  (invh => invh.Inv_HD_ID),
                                                                                  ((invd, invh) => new { Inventorymaster = invd, inventorydetails = invh })).Where(k => k.Inventorymaster.StoreId == StorId || k.Inventorymaster.SubStoreId == SubStorId || k.Inventorymaster.SubSubStoreId == SubSubStorId || k.Inventorymaster.SubSubSubStoreId == SubSubSubStorId || k.Inventorymaster.SubSubSubSubStoreId == SubSubSubSubStorId).Where(i => i.inventorydetails.ItemId == items.ItemId).Select(q => q.inventorydetails.AvailableQty).Sum();
                var itemqty = Convert.ToDecimal(items.ItemQuantity);



                var invdetails = (from p in unitOfWork.InventoryDetailRepository.Get()
                                  join m in unitOfWork.InventoryMasterRepository.Get() on p.Inv_HD_ID equals m.Inv_HD_ID
                                  where p.AvailableQty > 0 && p.ItemId == items.ItemId && (m.StoreId == StorId || m.SubStoreId == SubStorId || m.SubSubStoreId == SubSubStorId || m.SubSubSubStoreId == SubSubSubStorId || m.SubSubSubSubStoreId == SubSubSubSubStorId)
                                  select new
                {
                    InvDetailsId = p.Inv_Details_ID,
                }).ToList();



                foreach (var invid in invdetails)
                {
                    if (itemqty > 0)
                    {
                        var invdetailidqty = unitOfWork.InventoryDetailRepository.Get().Where(m => m.Inv_Details_ID == invid.InvDetailsId).Select(l => l.AvailableQty).SingleOrDefault();

                        if (itemqty <= invdetailidqty)
                        {
                            var result = unitOfWork.InventoryDetailRepository.Get().SingleOrDefault(b => b.Inv_Details_ID == invid.InvDetailsId);
                            if (result != null)
                            {
                                result.AvailableQty = invdetailidqty - itemqty;
                                unitOfWork.Save();
                                itemqty = Convert.ToDecimal(items.ItemQuantity) - itemqty;
                            }
                        }
                        else
                        {
                            var result = unitOfWork.InventoryDetailRepository.Get().SingleOrDefault(b => b.Inv_Details_ID == invid.InvDetailsId);
                            if (result != null)
                            {
                                result.AvailableQty = result.AvailableQty - invdetailidqty;
                                unitOfWork.Save();
                                itemqty = itemqty - invdetailidqty;
                            }
                        }
                    }
                }
            }


            var InventoryMaster = new InventoryMaster
            {
                ProductionMasterId = Productionhdid,
                StoreId            = ProductionMasterViewModel.StoreId,
                CreateDate         = DateTime.Now
            };

            unitOfWork.InventoryMasterRepository.Insert(InventoryMaster);
            unitOfWork.Save();

            var invId = InventoryMaster.Inv_HD_ID;

            InventoryDetail inventoryDetail = new InventoryDetail();

            inventoryDetail.Inv_HD_ID      = invId;
            inventoryDetail.ProductId      = ProductionMasterViewModel.ProductId;
            inventoryDetail.TransactionQty = ProductionMasterViewModel.ProductionQuantity;
            inventoryDetail.AvailableQty   = ProductionMasterViewModel.ProductionQuantity;
            inventoryDetail.PO_Price       = ProductionMasterViewModel.ProductPrice / ProductionMasterViewModel.ProductionQuantity;

            unitOfWork.InventoryDetailRepository.Insert(inventoryDetail);
            unitOfWork.Save();



            //foreach (var items in productionDetailsViewModels)
            //{
            //    //InventoryDetail lst = new InventoryDetail();

            //    var ProductionQty = items.ItemQuantity;

            //    var inventoryQty = unitOfWork.InventoryDetailRepository.Get().Where(m => m.ItemId == items.ItemId).Select(k => k.TransactionQty).Sum();

            //    var updateqty = inventoryQty - ProductionQty;

            //    if (inventoryQty > ProductionQty)
            //    {
            //        //var jj = (from p in unitOfWork.InventoryDetailRepository.Get() join m in unitOfWork.InventoryMasterRepository.Get() on p.Inv_HD_ID equals m.Inv_HD_ID  where p.ItemId == items.ItemId && m.StoreId == ProductionMasterViewModel.StoreId select p).SingleOrDefault();

            //        var kk = unitOfWork.InventoryDetailRepository.Get().SingleOrDefault(b => b.ItemId == items.ItemId);
            //        //foreach (var f in jj)
            //        //{
            //        //    lst.Inv_Details_ID = f.Inv_Details_ID;
            //        //    lst.Inv_HD_ID = f.Inv_HD_ID;
            //        //    lst.ItemId = f.ItemId;
            //        //    lst.UnitId = f.UnitId;
            //        //    lst.MethodId = f.MethodId;
            //        //    lst.DateOfExpired = f.DateOfExpired;
            //        //    lst.DateOfNextMaintainance = f.DateOfNextMaintainance;
            //        //    lst.TransactionQty = inventoryQty - ProductionQty;

            //        //}
            //        kk.AvailableQty = updateqty;

            //        unitOfWork.Save();
            //    }


            //}
        }
Пример #22
0
 // Start is called before the first frame update
 void Awake()
 {
     controller = GameObject.Find("GameControllerObject").GetComponent <GameController>();
     inventory  = controller.GetComponent <InventoryMaster>();
     car        = controller.GetCar().GetComponent <Driving>();
 }
Пример #23
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            string output = flags.Positionals[2];

            List <string> heroes = new List <string>();

            if (flags.Positionals.Length > 3)
            {
                heroes.AddRange(flags.Positionals[3].ToLowerInvariant().Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries));
            }
            bool heroAllWildcard = heroes.Count == 0 || heroes.Contains("*");

            List <ulong> masters = track[0x75];

            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));
                if (masterStud.Instances == null || masterStud.Instances[0] == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                if (!heroes.Contains(heroName.ToLowerInvariant()))
                {
                    if (!heroAllWildcard)
                    {
                        continue;
                    }
                }
                if (master.Header.itemMaster.key != 0)   // AI
                {
                    InventoryMaster inventory = Extract.OpenInventoryMaster(master, map, handler);
                    if (inventory.ItemGroups.Length > 0 || inventory.DefaultGroups.Length > 0)
                    {
                        continue;
                    }
                }
                Console.Out.WriteLine("Dumping voice bites for NPC {0}", heroName);
                Dictionary <ulong, List <ulong> > soundData = ExtractLogic.Sound.FindSounds(master, track, map, handler, null, masterKey);
                string path = string.Format("{0}{1}{2}{1}{3}{1}", output, Path.DirectorySeparatorChar, Util.Strip(Util.SanitizePath(heroName)), "Sound Dump");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                Save(path, soundData, map, handler, quiet);
            }
        }
Пример #24
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            string output = flags.Positionals[2];

            List <string> heroes = new List <string>();

            if (flags.Positionals.Length > 3)
            {
                heroes.AddRange(flags.Positionals[3].ToLowerInvariant().Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries));
            }
            bool heroAllWildcard = heroes.Count == 0 || heroes.Contains("*");

            List <ulong> masters = track[0x75];

            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));
                if (masterStud.Instances == null || masterStud.Instances[0] == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                if (!heroes.Contains(heroName.ToLowerInvariant()))
                {
                    if (!heroAllWildcard)
                    {
                        continue;
                    }
                }
                HashSet <ulong> items     = new HashSet <ulong>();
                InventoryMaster inventory = Extract.OpenInventoryMaster(master, map, handler);
                if (inventory == null)
                {
                    continue;
                }

                foreach (OWRecord record in inventory.Achievables)
                {
                    items.Add(record);
                }
                for (int i = 0; i < inventory.DefaultGroups.Length; ++i)
                {
                    for (int j = 0; j < inventory.Defaults[i].Length; ++j)
                    {
                        items.Add(inventory.Defaults[i][j]);
                    }
                }
                for (int i = 0; i < inventory.ItemGroups.Length; ++i)
                {
                    for (int j = 0; j < inventory.Items[i].Length; ++j)
                    {
                        items.Add(inventory.Items[i][j]);
                    }
                }

                HashSet <ulong> done = new HashSet <ulong>();

                string path = string.Format("{0}{1}{2}{1}{3}{1}", output, Path.DirectorySeparatorChar, Util.Strip(Util.SanitizePath(heroName)), "Sound Dump Full");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                bool haveBase = false;

                foreach (ulong itemKey in items)
                {
                    if (!map.ContainsKey(itemKey))
                    {
                        continue;
                    }
                    using (Stream itemStream = Util.OpenFile(map[itemKey], handler)) {
                        STUD itemStud = new STUD(itemStream);
                        if (itemStud.Instances == null)
                        {
                            continue;
                        }
                        SkinItem item = itemStud.Instances[0] as SkinItem;
                        if (item == null)
                        {
                            continue;
                        }
                        Dictionary <ulong, List <ulong> > sound = new Dictionary <ulong, List <ulong> >();
                        if (!haveBase)
                        {
                            sound.Clear();
                            Console.Out.WriteLine("Processing base sounds for hero {0}", heroName);
                            Skin.ExtractData(item, master, false, new HashSet <ulong>(), new Dictionary <ulong, ulong>(), new HashSet <ulong>(), new Dictionary <ulong, List <ImageLayer> >(), new Dictionary <ulong, ulong>(), sound, new List <ulong>(), -1, map, handler);
                            Sound.FindSounds(master, track, map, handler, null, masterKey, sound);
                            DumpVoice.Save($"{path}_Base{Path.DirectorySeparatorChar}", sound, map, handler, quiet, null, done);
                            haveBase = true;
                        }
                        sound.Clear();
                        string itemName = Util.GetString(item.Header.name, map, handler);
                        if (string.IsNullOrWhiteSpace(itemName))
                        {
                            itemName = $"Item-{itemKey:X16}";
                        }
                        Console.Out.WriteLine("Processing new sounds for skin {0}", itemName);
                        Dictionary <ulong, ulong> replace = new Dictionary <ulong, ulong>();
                        Skin.ExtractData(item, master, true, new HashSet <ulong>(), new Dictionary <ulong, ulong>(), new HashSet <ulong>(), new Dictionary <ulong, List <ImageLayer> >(), replace, sound, new List <ulong>(), -1, map, handler);
                        Sound.FindSounds(master, track, map, handler, replace, masterKey, sound);
                        DumpVoice.Save($"{path}{Util.Strip(Util.SanitizePath(itemName))}{Path.DirectorySeparatorChar}", sound, map, handler, quiet, replace, done);
                    }
                }
            }
        }
Пример #25
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            string output = flags.Positionals[2];

            string[] validCommands = new string[] { "skin", "spray", "icon", "victory pose", "emote", "heroic intro" };

            bool          typeWildcard = true;
            List <string> types        = new List <string>();

            if (flags.Positionals.Length > 3)
            {
                types.AddRange(flags.Positionals[3].ToLowerInvariant().Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries));
                typeWildcard = types.Contains("*");
                types        = types.FindAll((string it) => validCommands.Contains(it)).ToList();
            }

            if (!typeWildcard && types.Count == 0)
            {
                string cmdlist = "";
                for (int i = 0; i < validCommands.Length; i++)
                {
                    if (i != 0)
                    {
                        cmdlist += ", ";
                        if (i == validCommands.Length - 1)
                        {
                            cmdlist += "or ";
                        }
                    }
                    cmdlist += validCommands[i].ToString().ToLower();
                }
                Console.Out.WriteLine("The output type was not a valid option. ({0})", cmdlist);
                return;
            }

            Dictionary <string, List <string> > heroTypes    = new Dictionary <string, List <string> >();
            Dictionary <string, bool>           heroWildcard = new Dictionary <string, bool>();
            Dictionary <string, Dictionary <string, List <ulong> > > heroIgnore = new Dictionary <string, Dictionary <string, List <ulong> > >();
            bool heroAllWildcard = false;

            if (flags.Positionals.Length > 4 && flags.Positionals[4] != "*")
            {
                foreach (string pair in flags.Positionals[4].ToLowerInvariant().Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    List <string> data = new List <string>(pair.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries));
                    string        name = data[0];
                    data.RemoveAt(0);

                    if (!heroTypes.ContainsKey(name))
                    {
                        heroTypes[name]    = new List <string>();
                        heroIgnore[name]   = new Dictionary <string, List <ulong> >();
                        heroWildcard[name] = false;
                    }

                    if (data.Count > 0)
                    {
                        foreach (string d in data)
                        {
                            List <string> subdata = new List <string>(d.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
                            string        subn    = subdata[0];
                            subdata.RemoveAt(0);
                            heroTypes[name].Add(subn);
                            heroIgnore[name][subn] = new List <ulong>();
                            if (subdata.Count > 0)
                            {
                                foreach (string sd in subdata)
                                {
                                    try {
                                        heroIgnore[name][subn].Add(ulong.Parse(sd, System.Globalization.NumberStyles.HexNumber));
                                    } catch { }
                                }
                            }
                        }
                    }

                    if (data.Count == 0 || data.Contains("*"))
                    {
                        heroWildcard[name] = true;
                    }
                }
            }
            else
            {
                heroAllWildcard = true;
            }

            int replacementIndex = flags.WeaponSkinIndex;

            List <ulong> masters = track[0x75];

            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));
                if (masterStud.Instances == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                if (master.Header.itemMaster.key == 0)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                if (heroAllWildcard)
                {
                    if (!heroTypes.ContainsKey(heroName.ToLowerInvariant()))
                    {
                        heroTypes.Add(heroName.ToLowerInvariant(), new List <string>());
                    }
                    if (!heroWildcard.ContainsKey(heroName.ToLowerInvariant()))
                    {
                        heroWildcard.Add(heroName.ToLowerInvariant(), true);
                    }
                }
                if (!heroTypes.ContainsKey(heroName.ToLowerInvariant()))
                {
                    continue;
                }
                InventoryMaster inventory = OpenInventoryMaster(master, map, handler);
                if (inventory == null)
                {
                    continue;
                }

                Dictionary <OWRecord, string> items = new Dictionary <OWRecord, string>();
                foreach (OWRecord record in inventory.Achievables)
                {
                    items[record] = "ACHIEVEMENT";
                }

                for (int i = 0; i < inventory.DefaultGroups.Length; ++i)
                {
                    string name = $"STANDARD_{ItemEvents.GetInstance().GetEvent(inventory.DefaultGroups[i].@event)}";
                    for (int j = 0; j < inventory.Defaults[i].Length; ++j)
                    {
                        items[inventory.Defaults[i][j]] = name;
                    }
                }

                for (int i = 0; i < inventory.ItemGroups.Length; ++i)
                {
                    string name = ItemEvents.GetInstance().GetEvent(inventory.ItemGroups[i].@event);
                    for (int j = 0; j < inventory.Items[i].Length; ++j)
                    {
                        items[inventory.Items[i][j]] = name;
                    }
                }

                foreach (KeyValuePair <OWRecord, string> recordname in items)
                {
                    OWRecord record    = recordname.Key;
                    string   itemGroup = recordname.Value;
                    if (!map.ContainsKey(record.key))
                    {
                        continue;
                    }

                    STUD stud = new STUD(Util.OpenFile(map[record.key], handler));
                    if (stud.Instances == null)
                    {
                        continue;
                    }
                    IInventorySTUDInstance instance = (IInventorySTUDInstance)stud.Instances[0];
                    if (!typeWildcard && !types.Contains(instance.Name.ToLowerInvariant()))
                    {
                        continue;
                    }

                    string name = Util.GetString(instance.Header.name.key, map, handler);
                    if (name == null)
                    {
                        name = $"Untitled-{GUID.LongKey(instance.Header.name.key):X12}";
                        continue;
                    }
                    if (!heroWildcard[heroName.ToLowerInvariant()] && !heroTypes[heroName.ToLowerInvariant()].Contains(name.ToLowerInvariant()))
                    {
                        continue;
                    }

                    switch (instance.Name)
                    {
                    case "Spray":
                        Console.Out.WriteLine("Extracting spray {0} for {1}...", name, heroName);
                        ExtractLogic.Spray.Extract(stud, output, heroName, name, itemGroup, track, map, handler, quiet, flags);
                        break;

                    case "Skin":
                        List <ulong> ignoreList = new List <ulong>();
                        try {
                            ignoreList = heroIgnore[heroName.ToLowerInvariant()][name.ToLowerInvariant()];
                        } catch { }
                        Console.Out.WriteLine("Extracting {0} models and textures for {1}", name, heroName);
                        ExtractLogic.Skin.Extract(master, stud, output, heroName, name, itemGroup, ignoreList, track, map, handler, quiet, flags, masterKey, replacementIndex);
                        break;

                    case "Icon":
                        Console.Out.WriteLine("Extracting icon {0} for {1}...", name, heroName);
                        ExtractLogic.Icon.Extract(stud, output, heroName, name, itemGroup, track, map, handler, quiet, flags);
                        break;

                    case "Emote":
                    case "Victory Pose":
                    case "Heroic Intro":
                        Console.Out.WriteLine("Extracting {2} {0} for {1}...", name, heroName, instance.Name);
                        ExtractLogic.ItemAnimation.Extract(record.key, stud, output, heroName, name, itemGroup, track, map, handler, quiet, flags);
                        break;

                    case "Voice Line":
                        //Console.Out.WriteLine("Extracting voice line {0} for {1}...", name, heroName);
                        //ExtractLogic.VoiceLine.Extract(master, stud, output, heroName, name, track, map, handler);
                        break;
                    }
                }
            }
        }
Пример #26
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            Dictionary <string, Dictionary <string, Dictionary <string, Dictionary <string, List <JSONPkg> > > > > dict_upper = new Dictionary <string, Dictionary <string, Dictionary <string, Dictionary <string, List <JSONPkg> > > > >();

            foreach (ulong key in track[0x75])
            {
                if (!map.ContainsKey(key))
                {
                    continue;
                }

                using (Stream input = Util.OpenFile(map[key], handler)) {
                    if (input == null)
                    {
                        continue;
                    }
                    STUD stud = new STUD(input);
                    if (stud.Instances == null || stud.Instances[0] == null)
                    {
                        continue;
                    }

                    HeroMaster hero = stud.Instances[0] as HeroMaster;
                    if (hero == null)
                    {
                        continue;
                    }
                    Dictionary <string, Dictionary <string, Dictionary <string, List <JSONPkg> > > > dict = new Dictionary <string, Dictionary <string, Dictionary <string, List <JSONPkg> > > >();


                    string heroName = Util.GetString(hero.Header.name.key, map, handler);
                    if (heroName == null)
                    {
                        continue;
                    }
                    if (hero.Header.itemMaster.key == 0)   // AI
                    {
                        continue;
                    }

                    if (!map.ContainsKey(hero.Header.itemMaster.key))
                    {
                        continue;
                    }
                    STUD            inventoryStud = new STUD(Util.OpenFile(map[hero.Header.itemMaster.key], handler));
                    InventoryMaster master        = (InventoryMaster)inventoryStud.Instances[0];
                    if (master == null)
                    {
                        continue;
                    }

                    if (!dict.ContainsKey("ACHIEVEMENT"))
                    {
                        dict["ACHIEVEMENT"] = new Dictionary <string, Dictionary <string, List <JSONPkg> > >();
                    }

                    if (!dict.ContainsKey("STANDARD"))
                    {
                        dict["STANDARD"] = new Dictionary <string, Dictionary <string, List <JSONPkg> > >();
                    }

                    if (!dict.ContainsKey("AVAILABLE"))
                    {
                        dict["AVAILABLE"] = new Dictionary <string, Dictionary <string, List <JSONPkg> > >();
                    }

                    string s = ItemEvents.GetInstance().GetEvent(0);
                    if (!dict["ACHIEVEMENT"].ContainsKey(s))
                    {
                        dict["ACHIEVEMENT"][s] = new Dictionary <string, List <JSONPkg> >();
                    }

                    for (int i = 0; i < master.Achievables.Length; ++i)
                    {
                        JSONPkg pkg = JSONGeneral.GenerateJSONPkg(master.Achievables[i], map, handler);
                        if (pkg.Name == null)
                        {
                            continue;
                        }
                        pkg.EventId = 0;
                        pkg.Event   = s;

                        if (!dict["ACHIEVEMENT"][s].ContainsKey(pkg.Type))
                        {
                            dict["ACHIEVEMENT"][s][pkg.Type] = new List <JSONPkg>();
                        }
                        dict["ACHIEVEMENT"][s][pkg.Type].Add(pkg);
                    }

                    for (int i = 0; i < master.DefaultGroups.Length; ++i)
                    {
                        if (master.Defaults[i].Length == 0)
                        {
                            continue;
                        }

                        s = ItemEvents.GetInstance().GetEvent(master.DefaultGroups[i].@event);
                        if (!dict["STANDARD"].ContainsKey(s))
                        {
                            dict["STANDARD"][s] = new Dictionary <string, List <JSONPkg> >();
                        }

                        for (int j = 0; j < master.Defaults[i].Length; ++j)
                        {
                            JSONPkg pkg = GenerateJSONPkg(master.Defaults[i][j].key, map, handler);
                            if (pkg.Name == null)
                            {
                                continue;
                            }
                            pkg.EventId = master.DefaultGroups[i].@event;
                            pkg.Event   = s;

                            if (!dict["STANDARD"][s].ContainsKey(pkg.Type))
                            {
                                dict["STANDARD"][s][pkg.Type] = new List <JSONPkg>();
                            }
                            dict["STANDARD"][s][pkg.Type].Add(pkg);
                        }
                    }


                    for (int i = 0; i < master.ItemGroups.Length; ++i)
                    {
                        if (master.Items[i].Length == 0)
                        {
                            continue;
                        }

                        s = ItemEvents.GetInstance().GetEvent(master.ItemGroups[i].@event);
                        if (!dict["AVAILABLE"].ContainsKey(s))
                        {
                            dict["AVAILABLE"][s] = new Dictionary <string, List <JSONPkg> >();
                        }

                        for (int j = 0; j < master.Items[i].Length; ++j)
                        {
                            JSONPkg pkg = GenerateJSONPkg(master.Items[i][j].key, map, handler);
                            if (pkg.Name == null)
                            {
                                continue;
                            }
                            pkg.EventId = master.ItemGroups[i].@event;
                            pkg.Event   = s;

                            if (!dict["AVAILABLE"][s].ContainsKey(pkg.Type))
                            {
                                dict["AVAILABLE"][s][pkg.Type] = new List <JSONPkg>();
                            }
                            dict["AVAILABLE"][s][pkg.Type].Add(pkg);
                        }
                    }

                    dict_upper[heroName] = dict;
                }
            }

            if (Path.GetDirectoryName(flags.Positionals[2]).Trim().Length > 0 && !Directory.Exists(Path.GetDirectoryName(flags.Positionals[2])))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(flags.Positionals[2]));
            }
            using (Stream file = File.OpenWrite(flags.Positionals[2])) {
                using (TextWriter writer = new StreamWriter(file)) {
                    writer.Write(JsonConvert.SerializeObject(dict_upper, Formatting.Indented));
                }
            }
        }
Пример #27
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            string output = flags.Positionals[2];

            HashSet <string> heroes    = new HashSet <string>();
            HashSet <string> heroBlank = new HashSet <string>();
            Dictionary <string, HashSet <string> > heroSkin = new Dictionary <string, HashSet <string> >();
            bool heroAllWildcard = false;

            if (flags.Positionals.Length > 3 && flags.Positionals[1] != "*")
            {
                foreach (string name in flags.Positionals[3].ToLowerInvariant().Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    string[] data     = name.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    string   realname = data[0];
                    heroes.Add(realname);
                    data = data.Skip(1).ToArray();
                    if (data.Length == 0)
                    {
                        heroBlank.Add(realname);
                        continue;
                    }
                    heroSkin[realname] = new HashSet <string>();
                    foreach (string skin in data)
                    {
                        heroSkin[realname].Add(skin);
                    }
                }
            }
            else
            {
                heroAllWildcard = true;
            }

            List <ulong> masters = track[0x75];

            foreach (ulong masterKey in masters)
            {
                if (!map.ContainsKey(masterKey))
                {
                    continue;
                }
                STUD masterStud = new STUD(Util.OpenFile(map[masterKey], handler));
                if (masterStud.Instances == null)
                {
                    continue;
                }
                HeroMaster master = (HeroMaster)masterStud.Instances[0];
                if (master == null)
                {
                    continue;
                }
                if (master.Header.itemMaster.key == 0)
                {
                    continue;
                }
                string heroName = Util.GetString(master.Header.name.key, map, handler);
                if (heroName == null)
                {
                    continue;
                }
                if (heroAllWildcard)
                {
                    heroes.Add(heroName.ToLowerInvariant());
                    heroBlank.Add(heroName.ToLowerInvariant());
                }
                if (!heroes.Contains(heroName.ToLowerInvariant()))
                {
                    continue;
                }
                InventoryMaster inventory = OpenInventoryMaster(master, map, handler);
                if (inventory == null)
                {
                    continue;
                }

                Dictionary <OWRecord, string> items = new Dictionary <OWRecord, string>();
                foreach (OWRecord record in inventory.Achievables)
                {
                    items[record] = "ACHIEVEMENT";
                }

                for (int i = 0; i < inventory.DefaultGroups.Length; ++i)
                {
                    string name = $"STANDARD_{ItemEvents.GetInstance().GetEvent(inventory.DefaultGroups[i].@event)}";
                    for (int j = 0; j < inventory.Defaults[i].Length; ++j)
                    {
                        items[inventory.Defaults[i][j]] = name;
                    }
                }

                for (int i = 0; i < inventory.ItemGroups.Length; ++i)
                {
                    string name = ItemEvents.GetInstance().GetEvent(inventory.ItemGroups[i].@event);
                    for (int j = 0; j < inventory.Items[i].Length; ++j)
                    {
                        items[inventory.Items[i][j]] = name;
                    }
                }

                Dictionary <string, WeaponSkinItem> weaponskins = new Dictionary <string, WeaponSkinItem>();
                Console.Out.WriteLine("Finding weapon skins for {0}", heroName);
                foreach (KeyValuePair <OWRecord, string> recordname in items)
                {
                    OWRecord record    = recordname.Key;
                    string   itemGroup = recordname.Value;
                    if (!map.ContainsKey(record.key))
                    {
                        continue;
                    }

                    STUD stud = new STUD(Util.OpenFile(map[record.key], handler));
                    if (stud.Instances == null)
                    {
                        continue;
                    }
                    IInventorySTUDInstance instance = (IInventorySTUDInstance)stud.Instances[0];
                    WeaponSkinItem         weapon   = instance as WeaponSkinItem;
                    if (weapon == null)
                    {
                        continue;
                    }
                    if (weapon.Data.index == 0)
                    {
                        continue;
                    }
                    string name = Util.GetString(instance.Header.name.key, map, handler);
                    if (name == null)
                    {
                        name = $"Untitled-{GUID.LongKey(instance.Header.name.key):X12}";
                        continue;
                    }
                    weaponskins[name] = weapon;
                    Console.Out.WriteLine("Found data for weapon skin {0}", name);
                }
                foreach (KeyValuePair <OWRecord, string> recordname in items)
                {
                    OWRecord record    = recordname.Key;
                    string   itemGroup = recordname.Value;
                    if (!map.ContainsKey(record.key))
                    {
                        continue;
                    }

                    STUD stud = new STUD(Util.OpenFile(map[record.key], handler));
                    if (stud.Instances == null)
                    {
                        continue;
                    }
                    IInventorySTUDInstance instance = (IInventorySTUDInstance)stud.Instances[0];
                    SkinItem skin = instance as SkinItem;
                    if (skin == null)
                    {
                        continue;
                    }

                    string name = Util.GetString(instance.Header.name.key, map, handler);
                    if (name == null)
                    {
                        name = $"Untitled-{GUID.LongKey(instance.Header.name.key):X12}";
                        continue;
                    }
                    if (heroBlank.Contains(heroName.ToLowerInvariant()) || heroSkin[heroName.ToLowerInvariant()].Contains(name.ToLowerInvariant()))
                    {
                        Console.Out.WriteLine("Saving textures for skin {0}", name);
                        foreach (KeyValuePair <string, WeaponSkinItem> pair in weaponskins)
                        {
                            string output_real = string.Format("{0}{1}{4}{1}Weapon Skin{1}{2}{1}{3}{1}", output, System.IO.Path.DirectorySeparatorChar, Util.SanitizePath(pair.Key), Util.SanitizePath(name), Util.SanitizePath(heroName));
                            Dictionary <ulong, ulong> replace = new Dictionary <ulong, ulong>();
                            ExtractLogic.Skin.FindReplacements(skin.Data.skin.key, (int)pair.Value.Data.index, replace, new HashSet <ulong>(), map, handler, master, skin, true);
                            Dictionary <ulong, ulong> replace_blank = new Dictionary <ulong, ulong>();
                            ExtractLogic.Skin.FindReplacements(skin.Data.skin.key, -1, replace_blank, new HashSet <ulong>(), map, handler, master, skin, false);
                            if (replace.Values.Count == 0)
                            {
                                continue;
                            }
                            Dictionary <ulong, List <ImageLayer> > layers      = new Dictionary <ulong, List <ImageLayer> >();
                            Dictionary <ulong, List <ImageLayer> > layers_orig = new Dictionary <ulong, List <ImageLayer> >();
                            foreach (KeyValuePair <ulong, ulong> texture_pair in replace)
                            {
                                ushort type = GUID.Type(texture_pair.Key);
                                switch (type)
                                {
                                case 0x1A:
                                    ExtractLogic.Skin.FindTextures(texture_pair.Value, layers, replace, new HashSet <ulong>(), map, handler);
                                    if (replace_blank.ContainsKey(texture_pair.Key))
                                    {
                                        ExtractLogic.Skin.FindTextures(replace_blank[texture_pair.Key], layers_orig, replace_blank, new HashSet <ulong>(), map, handler);
                                    }
                                    else
                                    {
                                        ExtractLogic.Skin.FindTextures(texture_pair.Key, layers_orig, replace_blank, new HashSet <ulong>(), map, handler);
                                    }
                                    break;
                                }
                            }

                            Dictionary <ulong, HashSet <ulong> > origTextures = new Dictionary <ulong, HashSet <ulong> >();
                            foreach (KeyValuePair <ulong, List <ImageLayer> > kv in layers_orig)
                            {
                                ulong             materialId     = kv.Key;
                                List <ImageLayer> sublayers      = kv.Value;
                                HashSet <ulong>   materialParsed = new HashSet <ulong>();
                                if (!origTextures.ContainsKey(materialId))
                                {
                                    origTextures[materialId] = new HashSet <ulong>();
                                }
                                foreach (ImageLayer layer in sublayers)
                                {
                                    origTextures[materialId].Add(layer.key);
                                }
                            }

                            foreach (KeyValuePair <ulong, List <ImageLayer> > kv in layers)
                            {
                                ulong             materialId     = kv.Key;
                                List <ImageLayer> sublayers      = kv.Value;
                                HashSet <ulong>   materialParsed = new HashSet <ulong>();
                                foreach (ImageLayer layer in sublayers)
                                {
                                    if (!materialParsed.Add(layer.key))
                                    {
                                        continue;
                                    }
                                    if (origTextures.ContainsKey(materialId) && origTextures[materialId].Contains(layer.key))
                                    {
                                        continue;
                                    }
                                    ExtractLogic.Skin.SaveTexture(layer.key, materialId, map, handler, output_real, quiet, "");
                                }
                            }
                        }
                    }
                }
            }
        }