Пример #1
0
        public static bool RemoveFabricForProject(GameObject obj, Sim actor, int amount)
        {
            List <IngredientFabric> list  = actor.Inventory.FindAll <IngredientFabric>(true);
            List <IngredientFabric> list2 = obj.Inventory.FindAll <IngredientFabric>(true);
            List <IngredientFabric> list3 = new List <IngredientFabric>();

            if (obj != null && obj.Inventory != null)
            {
                if (list2.Count + list.Count < amount)
                {
                    return(false);
                }
                list3.AddRange(list2);
                list3.AddRange(list);

                for (int j = 0; j < amount; j++)
                {
                    IngredientFabric fabric = list3[j];
                    if (!obj.Inventory.TryToRemove(fabric))
                    {
                        SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric ingredient, Destroyed item.");
                        return(false);
                    }
                    list3.Remove(fabric);
                    SewingTable.print("Was able to remove fabric from table");
                }
            }
            return(false);
        }
Пример #2
0
        public static bool CreateAndAddToInventory(GameObject obj, int amount)
        {
            if (obj != null && obj.Inventory != null)
            {
                for (int i = 0; i < amount; i++)
                {
                    FabricInitParameters initData = new FabricInitParameters(1);

                    IGameObject   Knitted           = (IngredientFabric)GlobalFunctions.CreateObjectOutOfWorld(fabricKnittedRK, null, initData);
                    FabricKnitted ingredientKnitted = Knitted as FabricKnitted;

                    IGameObject  Cotton           = (IngredientFabric)GlobalFunctions.CreateObjectOutOfWorld(fabricCottonRK, null, initData);
                    FabricCotton ingredientCotton = Cotton as FabricCotton;

                    IGameObject   leather           = (IngredientFabric)GlobalFunctions.CreateObjectOutOfWorld(fabricLeatherRK, null, initData);
                    FabricLeather ingredientLeather = leather as FabricLeather;

                    IGameObject     synthetic           = (IngredientFabric)GlobalFunctions.CreateObjectOutOfWorld(fabricSyntheticRK, null, initData);
                    FabricSynthetic ingredientSynthetic = synthetic as FabricSynthetic;

                    IGameObject denim           = (IngredientFabric)GlobalFunctions.CreateObjectOutOfWorld(fabricDenimRK, null, initData);
                    FabricDenim ingredientDenim = denim as FabricDenim;

                    IGameObject satin           = (IngredientFabric)GlobalFunctions.CreateObjectOutOfWorld(fabricSatinRK, null, initData);
                    FabricSatin ingredientSatin = satin as FabricSatin;

                    if (ingredientKnitted != null)
                    {
                        if (!obj.Inventory.TryToAdd(ingredientKnitted))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric Knitted, Destroyed item.");
                            ingredientKnitted.Destroy();
                            return(false);
                        }
                    }
                    if (ingredientLeather != null)
                    {
                        if (!obj.Inventory.TryToAdd(ingredientLeather))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric Leather, Destroyed item.");
                            ingredientLeather.Destroy();
                            return(false);
                        }
                    }
                    if (ingredientSynthetic != null)
                    {
                        if (!obj.Inventory.TryToAdd(ingredientSynthetic))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric Synthetic, Destroyed item.");
                            ingredientSynthetic.Destroy();
                            return(false);
                        }
                    }
                    if (ingredientCotton != null)
                    {
                        if (!obj.Inventory.TryToAdd(ingredientCotton))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric Cotton, Destroyed item.");
                            ingredientCotton.Destroy();
                            return(false);
                        }
                    }
                    if (ingredientDenim != null)
                    {
                        if (!obj.Inventory.TryToAdd(ingredientDenim))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric Denim, Destroyed item.");
                            ingredientDenim.Destroy();
                            return(false);
                        }
                    }
                    if (ingredientSatin != null)
                    {
                        if (!obj.Inventory.TryToAdd(ingredientSatin))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric Satin, Destroyed item.");
                            ingredientSatin.Destroy();
                            return(false);
                        }
                    }
                }
                return(true);
            }
            return(false);
        }
Пример #3
0
        // If we know the type of fabric, use this one instead
        public static bool RemoveFabricForProject(GameObject obj, Sim actor, SewingSkill.FabricType type, int amount)
        {
            List <FabricCotton> listCotton  = actor.Inventory.FindAll <FabricCotton>(true);
            List <FabricCotton> list2Cotton = obj.Inventory.FindAll <FabricCotton>(true);

            List <FabricDenim> listDenim  = actor.Inventory.FindAll <FabricDenim>(true);
            List <FabricDenim> list2Denim = obj.Inventory.FindAll <FabricDenim>(true);

            List <FabricKnitted> listKnitted  = actor.Inventory.FindAll <FabricKnitted>(true);
            List <FabricKnitted> list2Knitted = obj.Inventory.FindAll <FabricKnitted>(true);

            List <FabricLeather> listLeather  = actor.Inventory.FindAll <FabricLeather>(true);
            List <FabricLeather> list2Leather = obj.Inventory.FindAll <FabricLeather>(true);

            List <FabricSatin> listSatin  = actor.Inventory.FindAll <FabricSatin>(true);
            List <FabricSatin> list2Satin = obj.Inventory.FindAll <FabricSatin>(true);

            List <FabricSynthetic> listSynthetic  = actor.Inventory.FindAll <FabricSynthetic>(true);
            List <FabricSynthetic> list2Synthetic = obj.Inventory.FindAll <FabricSynthetic>(true);

            List <FabricCotton>    list3Cotton    = new List <FabricCotton>();
            List <FabricDenim>     list3Denim     = new List <FabricDenim>();
            List <FabricKnitted>   list3Knitted   = new List <FabricKnitted>();
            List <FabricLeather>   list3Leather   = new List <FabricLeather>();
            List <FabricSatin>     list3Satin     = new List <FabricSatin>();
            List <FabricSynthetic> list3Synthetic = new List <FabricSynthetic>();

            if (obj != null && obj.Inventory != null)
            {
                if (type == SewingSkill.FabricType.Cotton)
                {
                    list3Cotton.AddRange(listCotton);
                    list3Cotton.AddRange(list2Cotton);
                    if (list3Cotton.Count < amount)
                    {
                        SewingTable.print("Lyralei's Sewing Table: all inventories don't have enough fabric in it");
                        return(false);
                    }
                    for (int j = 0; j < amount; j++)
                    {
                        FabricCotton fabric = list3Cotton[j];
                        if (!obj.Inventory.TryToRemove(fabric))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric ingredient, Destroyed item.");
                            return(false);
                        }
                        list3Cotton.Remove(fabric);
                    }
                }

                if (type == SewingSkill.FabricType.Denim)
                {
                    list3Denim.AddRange(listDenim);
                    list3Denim.AddRange(list2Denim);
                    if (list3Denim.Count < amount)
                    {
                        SewingTable.print("Lyralei's Sewing Table: all inventories don't have enough fabric in it");
                        return(false);
                    }
                    for (int j = 0; j < amount; j++)
                    {
                        FabricDenim fabric = list3Denim[j];
                        if (!obj.Inventory.TryToRemove(fabric))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric ingredient, Destroyed item.");
                            return(false);
                        }
                        list3Denim.Remove(fabric);
                    }
                }

                if (type == SewingSkill.FabricType.Knitted)
                {
                    list3Knitted.AddRange(listKnitted);
                    list3Knitted.AddRange(list2Knitted);
                    if (list3Knitted.Count < amount)
                    {
                        SewingTable.print("Lyralei's Sewing Table: all inventories don't have enough fabric in it");
                        return(false);
                    }
                    for (int j = 0; j < amount; j++)
                    {
                        FabricKnitted fabric = list3Knitted[j];
                        if (!obj.Inventory.TryToRemove(fabric))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric ingredient, Destroyed item.");
                            return(false);
                        }
                        list3Knitted.Remove(fabric);
                    }
                }
                if (type == SewingSkill.FabricType.Leather)
                {
                    list3Leather.AddRange(listLeather);
                    list3Leather.AddRange(list2Leather);
                    if (list3Leather.Count < amount)
                    {
                        SewingTable.print("Lyralei's Sewing Table: all inventories don't have enough fabric in it");
                        return(false);
                    }
                    for (int j = 0; j < amount; j++)
                    {
                        FabricLeather fabric = list3Leather[j];
                        if (!obj.Inventory.TryToRemove(fabric))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric ingredient, Destroyed item.");
                            return(false);
                        }
                        list3Leather.Remove(fabric);
                    }
                }
                if (type == SewingSkill.FabricType.Satin)
                {
                    list3Satin.AddRange(listSatin);
                    list3Satin.AddRange(list2Satin);
                    if (list3Satin.Count < amount)
                    {
                        SewingTable.print("Lyralei's Sewing Table: all inventories don't have enough fabric in it");
                        return(false);
                    }
                    for (int j = 0; j < amount; j++)
                    {
                        FabricSatin fabric = list3Satin[j];
                        if (!obj.Inventory.TryToRemove(fabric))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric ingredient, Destroyed item.");
                            return(false);
                        }
                        list3Satin.Remove(fabric);
                    }
                }
                if (type == SewingSkill.FabricType.Synthetic)
                {
                    list3Synthetic.AddRange(listSynthetic);
                    list3Synthetic.AddRange(list2Synthetic);
                    if (list3Synthetic.Count < amount)
                    {
                        SewingTable.print("Lyralei's Sewing Table: all inventories don't have enough fabric in it");
                        return(false);
                    }
                    for (int j = 0; j < amount; j++)
                    {
                        FabricSynthetic fabric = list3Synthetic[j];
                        if (!obj.Inventory.TryToRemove(fabric))
                        {
                            SewingTable.print("Lyralei's SewingTable: Couldn't add Fabric ingredient, Destroyed item.");
                            return(false);
                        }
                        list3Synthetic.Remove(fabric);
                    }
                }
            }
            return(true);
        }