Exemplo n.º 1
0
        protected bool SmeltMetal(Metal metal)
        {
            if (!metal.mCollected)
            {
                return(false);
            }

            if (Sim.FamilyFunds < Metal.GetSmelt.kCostToSmelt)
            {
                IncStat("Smelt Cost");
                return(false);
            }

            Money.AdjustFunds(Sim, "Smelting", -Metal.GetSmelt.kCostToSmelt);

            float chanceOfExtraIngot = Metal.GetSmelt.kChanceOfExtraIngot;

            Collecting skill = Sim.SkillManager.AddElement(SkillNames.Collecting) as Collecting;

            if (skill.IsMetalCollector())
            {
                chanceOfExtraIngot = Metal.GetSmelt.kMetalCollectorExtraIngotChance;
            }

            int num2 = 0x1;

            while ((num2 < Metal.GetSmelt.kMaxNumberOfIngots) && RandomUtil.RandomChance01(chanceOfExtraIngot))
            {
                num2++;
                Metal metal2 = RockGemMetalBase.Make(metal.Guid, true) as Metal;
                MetalEx.SmeltMetal(metal2, Sim);
                IncreaseIngotsCreatedForMetal(skill, metal2.Guid);

                Inventories.TryToMove(metal2, Sim.CreatedSim);
            }

            MetalEx.SmeltMetal(metal, Sim);
            IncreaseIngotsCreatedForMetal(skill, metal.Guid);

            skill.MetalSmelt();

            IncStat("Metal Smelt");

            return(true);
        }
Exemplo n.º 2
0
            private static IGameObject MakeHuntableFromData(WeightedHuntingData data)
            {
                IGameObject huntable = null;

                if (data != null)
                {
                    if (string.IsNullOrEmpty(data.StringID))
                    {
                        huntable = RockGemMetalBase.Make((RockGemMetal)data.ID, true);
                    }
                    else
                    {
                        huntable = GlobalFunctions.CreateObjectOutOfWorld(data.StringID, ProductVersion.EP5);
                    }
                }

                return(huntable);
            }
Exemplo n.º 3
0
        public static GameObject ReturnShoppingObject(RestockItem rItem, SimDescription actor, StoreSetRegister register)
        {
            GameObject o           = null;
            bool       keepLooping = true;

            switch (rItem.info.Type)
            {
            case ItemType.Herb:
            case ItemType.Ingredient:
                foreach (KeyValuePair <string, List <StoreItem> > kvp in Grocery.mItemDictionary)
                {
                    foreach (StoreItem item in kvp.Value)
                    {
                        if (item.Name.Equals(rItem.info.Name))
                        {
                            keepLooping = false;
                            IngredientData data = (IngredientData)item.CustomData;
                            if (rItem.info.Type == ItemType.Ingredient)
                            {
                                o = Ingredient.Create(data);
                            }
                            else
                            {
                                o = Herb.Create(data);
                                //PlantableNonIngredientData data = (PlantableNonIngredientData)item.CustomData;
                                //o = (GameObject)PlantableNonIngredient.Create(data);
                            }
                            break;
                        }
                    }
                    if (!keepLooping)
                    {
                        break;
                    }
                }

                break;

            case ItemType.Fish:
                o = Fish.CreateFishOfRandomWeight(rItem.info.FType);
                break;

            case ItemType.Craftable:
                break;

            case ItemType.Gem:
            case ItemType.Metal:

                o = (GameObject)RockGemMetalBase.Make(rItem.info.RockData, false);
                break;

            case ItemType.Nectar:

                NectarBottle bottle = (NectarBottle)GlobalFunctions.CreateObjectOutOfWorld("NectarBottle");
                NectarBottleObjectInitParams nectarBottleObjectInitParams = bottle.CreateAncientBottle(rItem.info.NectarAge, rItem.info.Price);

                if (nectarBottleObjectInitParams != null)
                {
                    bottle.mBottleInfo.FruitHash   = nectarBottleObjectInitParams.FruitHash;
                    bottle.mBottleInfo.Ingredients = nectarBottleObjectInitParams.Ingredients;
                    bottle.mBottleInfo.Name        = rItem.info.Name;             //nectarBottleObjectInitParams.Name;
                    bottle.mDateString             = nectarBottleObjectInitParams.DateString;
                    bottle.mBottleInfo.DateNum     = nectarBottleObjectInitParams.DateNum;
                    bottle.mBaseValue                   = rItem.info.Price;  // nectarBottleObjectInitParams.BaseValue;
                    bottle.ValueModifier                = (int)(nectarBottleObjectInitParams.CurrentValue - rItem.info.Price);
                    bottle.mBottleInfo.mCreator         = nectarBottleObjectInitParams.Creator;
                    bottle.mBottleInfo.NectarQuality    = Sims3.Gameplay.Objects.Quality.Neutral;                 //NectarBottle.GetQuality((float)rItem.info.Price);
                    bottle.mBottleInfo.MadeByLevel10Sim = nectarBottleObjectInitParams.MadeByLevel10Sim;
                    bottle.UpdateVisualState();
                }

                o = bottle;

                break;

            case ItemType.AlchemyPotion:

                foreach (AlchemyRecipe recipe in AlchemyRecipe.GetAllAwardPotionRecipes())
                {
                    if (rItem.info.Name.Equals(recipe.Name))
                    {
                        string[] array = new string[] { recipe.Key };

                        AlchemyRecipe randomAwardPotionRecipe = AlchemyRecipe.GetRandomAwardPotionRecipe();
                        PotionShopConsignmentRegister.PotionShopConsignmentRegisterData potionShopConsignmentRegisterData = new PotionShopConsignmentRegister.PotionShopConsignmentRegisterData();

                        potionShopConsignmentRegisterData.mParameters             = array;
                        potionShopConsignmentRegisterData.mObjectName             = randomAwardPotionRecipe.MedatorName;
                        potionShopConsignmentRegisterData.mGuid                   = potionShopConsignmentRegisterData.mObjectName.GetHashCode();
                        potionShopConsignmentRegisterData.mSellerAge              = CASAgeGenderFlags.None;
                        potionShopConsignmentRegisterData.mWeight                 = 100f;
                        potionShopConsignmentRegisterData.mSellPriceMinimum       = 0.75f;
                        potionShopConsignmentRegisterData.mSellPriceMaximum       = 1.25f;
                        potionShopConsignmentRegisterData.mDepreciationAgeMinimum = 0;
                        potionShopConsignmentRegisterData.mDepreciationAgeMaximum = 5;
                        potionShopConsignmentRegisterData.mLifespan               = 3f;
                        string text = string.Empty;
                        if (!string.IsNullOrEmpty(randomAwardPotionRecipe.CustomClassName))
                        {
                            text = randomAwardPotionRecipe.CustomClassName;
                        }
                        else
                        {
                            text = "Sims3.Gameplay.Objects.Alchemy.AlchemyPotion";
                        }
                        potionShopConsignmentRegisterData.mScriptClass = text;
                        potionShopConsignmentRegisterData.mIsRotatable = true;

                        PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData potionShopConsignmentRegisterObjectData2 = PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData.Create(potionShopConsignmentRegisterData);
                        potionShopConsignmentRegisterObjectData2.ShowTooltip = true;

                        o = (GameObject)potionShopConsignmentRegisterObjectData2.mObject;


                        break;
                    }
                }

                break;

            case ItemType.Bug:
                Terrarium t = Terrarium.Create(rItem.info.BugType);
                if (t != null)
                {
                    t.StartVfx();
                }
                o = t;
                break;

            case ItemType.Food:
                int servingPrice = 25;
                if (register != null)
                {
                    servingPrice = register.Info.ServingPrice;
                }

                IFoodContainer container = rItem.info.cookingProcess.Recipe.CreateFinishedFood(rItem.info.cookingProcess.Quantity, rItem.info.cookingProcess.Quality);

                if (rItem.info.cookingProcess.Quantity == Recipe.MealQuantity.Group)
                {
                    ((ServingContainerGroup)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice * ((ServingContainerGroup)container).mNumServingsLeft);
                    ((ServingContainerGroup)container).RemoveSpoilageAlarm();
                }
                else
                {
                    ((ServingContainerSingle)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice);
                    ((ServingContainerSingle)container).RemoveSpoilageAlarm();
                }

                o = (GameObject)container;

                break;

            case ItemType.Flowers:
                o = Wildflower.CreateWildflowerOfType(rItem.info.TypeOfWildFlower, Wildflower.WildflowerState.InVase);
                break;

            case ItemType.BookAlchemyRecipe_:
            case ItemType.BookComic_:
            case ItemType.BookFish_:
            case ItemType.BookGeneral_:
            case ItemType.BookRecipe_:
            case ItemType.BookSkill_:
            case ItemType.BookToddler_:
            case ItemType.SheetMusic_:
            case ItemType.AcademicTextBook_:

                foreach (KeyValuePair <string, List <StoreItem> > kvp in Bookstore.sItemDictionary)
                {
                    foreach (StoreItem item in kvp.Value)
                    {
                        if (item.Name.Equals(rItem.info.Name))
                        {
                            keepLooping = false;

                            if (rItem.info.Type == ItemType.BookGeneral_)
                            {
                                o = (GameObject)BookGeneral.CreateOutOfWorld(item.CustomData as BookGeneralData);
                            }
                            if (rItem.info.Type == ItemType.BookSkill_)
                            {
                                o = (GameObject)BookSkill.CreateOutOfWorld(item.CustomData as BookSkillData);
                            }
                            if (rItem.info.Type == ItemType.BookRecipe_)
                            {
                                o = (GameObject)BookRecipe.CreateOutOfWorld(item.CustomData as BookRecipeData);
                            }
                            if (rItem.info.Type == ItemType.SheetMusic_)
                            {
                                o = (GameObject)SheetMusic.CreateOutOfWorld(item.CustomData as SheetMusicData);
                            }
                            if (rItem.info.Type == ItemType.BookToddler_)
                            {
                                o = (GameObject)BookToddler.CreateOutOfWorld(item.CustomData as BookToddlerData);
                            }
                            if (rItem.info.Type == ItemType.BookFish_)
                            {
                                o = (GameObject)BookFish.CreateOutOfWorld(item.CustomData as BookFishData);
                            }
                            if (rItem.info.Type == ItemType.BookAlchemyRecipe_)
                            {
                                o = (GameObject)BookAlchemyRecipe.CreateOutOfWorld(item.CustomData as BookAlchemyRecipeData);
                            }
                            if (rItem.info.Type == ItemType.AcademicTextBook_)
                            {
                                o = (GameObject)AcademicTextBook.CreateOutOfWorld(item.CustomData as AcademicTextBookData, actor);
                            }
                            if (rItem.info.Type == ItemType.BookComic_)
                            {
                                o = (GameObject)BookComic.CreateOutOfWorld(item.CustomData as BookComicData);
                            }

                            break;
                        }
                    }
                    if (!keepLooping)
                    {
                        break;
                    }
                }


                break;

            case ItemType.JamJar:
                JamJar jamJar = GlobalFunctions.CreateObjectOutOfWorld("canningJarJam", ProductVersion.Store) as JamJar;

                if (jamJar != null)
                {
                    Type         tInfo = jamJar.GetType();
                    BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
                    FieldInfo    ingredientDataField = tInfo.GetField("mData", flags);
                    FieldInfo    ingredientKeyField  = tInfo.GetField("mIngredientKey", flags);
                    FieldInfo    qualityField        = tInfo.GetField("mQuality", flags);
                    FieldInfo    preservesField      = tInfo.GetField("mIsPreserves", flags);
                    MethodInfo   materialStateMethod = tInfo.GetMethod("SetMaterialState", flags);

                    ingredientDataField.SetValue(jamJar, rItem.info.IngData);
                    ingredientKeyField.SetValue(jamJar, rItem.info.IngredientKey);
                    qualityField.SetValue(jamJar, rItem.info.JamQuality);
                    preservesField.SetValue(jamJar, rItem.info.JamIsPreserve);
                    materialStateMethod.Invoke(jamJar, null);
                }
                o = (GameObject)jamJar;
                break;

            default:
                break;
            }

            return(o);
        }
Exemplo n.º 4
0
        public static IGameObject FetchRandomOccultTreat(OccultTypes type, bool isAlien)
        {
            if (isAlien)
            {
                InteractionDefinition      instance  = RabbitHole.StealSpaceRocks.Singleton;
                RabbitHole.StealSpaceRocks instance2 = instance as RabbitHole.StealSpaceRocks;
                if (instance2 != null)
                {
                    RabbitHole.StealSpaceRocks.SpaceRockSize weightedIndex = (RabbitHole.StealSpaceRocks.SpaceRockSize)RandomUtil.GetWeightedIndex(instance2.SSRTuning.SpaceRockWeights);
                    RockGemMetal spaceRockSize = RockGemMetal.SpaceRockSmall;
                    switch (weightedIndex)
                    {
                    case RabbitHole.StealSpaceRocks.SpaceRockSize.Small:
                        spaceRockSize = RockGemMetal.SpaceRockSmall;
                        break;

                    case RabbitHole.StealSpaceRocks.SpaceRockSize.Medium:
                        spaceRockSize = RockGemMetal.SpaceRockMedium;
                        break;

                    case RabbitHole.StealSpaceRocks.SpaceRockSize.Large:
                        spaceRockSize = RockGemMetal.SpaceRockLarge;
                        break;
                    }

                    return(RockGemMetalBase.Make(spaceRockSize, false));
                }
            }

            switch (type)
            {
            case OccultTypes.Fairy:
                PlantRarity      rarity  = (PlantRarity)RandomUtil.GetInt(0, 3);
                Quality          quality = (Quality)RandomUtil.GetInt(4, 9);
                PlayerDisclosure playerKnowledgeOfPlantableType = (rarity == PlantRarity.Common) ? PlayerDisclosure.Exposed : PlayerDisclosure.Concealed;
                IGameObject      seed = PlantHelper.CreateRandomPlantable(rarity, quality, true, playerKnowledgeOfPlantableType);

                return(seed);

            case OccultTypes.Frankenstein:
                ScrapInitParameters initData = new ScrapInitParameters(1);
                IGameObject         scrap    = GlobalFunctions.CreateObjectOutOfWorld("scrapPile", ProductVersion.EP2, null, initData);
                return(scrap);

            case OccultTypes.Genie:
                IGameObject lamp = GlobalFunctions.CreateObjectOutOfWorld("GenieLamp", ProductVersion.EP6);
                return(lamp);

            case OccultTypes.Mermaid:
                IGameObject kelp = MermadicKelp.MakeMermadicKelp(RandomUtil.CoinFlip());
                return(kelp);

            case OccultTypes.PlantSim:
                string     randomHerb = RandomUtil.GetRandomObjectFromList <string>(new List <string>(Herb.sIngredientToHerbDataMap.Keys));
                Ingredient herb       = Ingredient.Create(IngredientData.NameToDataMap[randomHerb]);
                return(herb as IGameObject);

            case OccultTypes.Robot:
                TraitChipStaticData data = RandomUtil.GetRandomObjectFromDictionary <ulong, TraitChipStaticData>(GenericManager <TraitChipName, TraitChipStaticData, TraitChip> .sDictionary);
                if (data != null)
                {
                    TraitChip chip = TraitChipManager.CreateTraitChip(data.Guid);
                    return(chip);
                }
                return(null);

            case OccultTypes.Vampire:
                IGameObject vampireTreat = null;
                if (!GameUtils.IsInstalled(ProductVersion.EP3))
                {
                    vampireTreat = Recipe.NameToRecipeHash["VampireJuiceEP7"].CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Perfect);
                }
                else
                {
                    bool coinToss = RandomUtil.CoinFlip();
                    if (coinToss)
                    {
                        vampireTreat = Recipe.NameToRecipeHash["VampireJuice"].CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Perfect);
                    }
                    else
                    {
                        vampireTreat = Ingredient.Create(IngredientData.NameToDataMap["VampireFruit"]);
                    }
                }
                return(vampireTreat);

            case OccultTypes.Werewolf:
                List <FishType> fish    = new List <FishType>();
                List <float>    weights = new List <float>(fish.Count);
                foreach (FishType fishType in Fish.sFishData.Keys)
                {
                    FishData data2 = Fish.sFishData[fishType];
                    if (((data2.IngredientData != null) && data2.IngredientData.CanBuyFromStore) && (data2.Level >= 0))
                    {
                        fish.Add(fishType);
                        weights.Add(1f);
                    }
                }
                int  weightedIndexFish = RandomUtil.GetWeightedIndex(weights.ToArray());
                Fish obj2 = Fish.CreateFishOfRandomWeight(fish[weightedIndexFish]);
                return(obj2 as IGameObject);

            case OccultTypes.Witch:
                if (RandomUtil.CoinFlip())
                {
                    ISoloInteractionDefinition  cdef     = TraitFunctions.ConjureApple.Singleton;
                    TraitFunctions.ConjureApple appleDef = cdef as TraitFunctions.ConjureApple;
                    if (appleDef != null)
                    {
                        return(appleDef.CreateAppleForInventory(RandomUtil.CoinFlip(), Quality.Perfect));
                    }
                }
                else
                {
                    AlchemyPotion potion = AlchemyPotion.CreateARandomPotion(RandomUtil.CoinFlip(), 0);
                    return(potion as IGameObject);
                }
                return(null);

            case OccultTypes.None:
            default:
                return(null);
            }
        }