public ObjectGuid CreateServingCallback(object customData, ref Simulator.ObjectInitParameters initData, Quality quality) { IFoodContainer container = (customData as Recipe).CreateFinishedFood(Recipe.MealQuantity.Group, Quality.Nice); if (container != null) { return(container.ObjectId); } return(ObjectGuid.InvalidObjectGuid); }
public ObjectGuid CreateSnackCallback(object customData, ref Simulator.ObjectInitParameters initData, Quality quality) { Recipe recipe = (customData as Recipe); if (recipe != null) { IFoodContainer container = (customData as Recipe).CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Outstanding); if (container != null) { return(container.ObjectId); } } return(ObjectGuid.InvalidObjectGuid); }
public Quality GetQuality(IGameObject obj) { Ingredient ingredient = obj as Ingredient; if (ingredient != null) { return(ingredient.GetQuality()); } else { ICraft craft = obj as ICraft; if (craft != null) { return(craft.GetQuality()); } else { IFoodContainer food = obj as IFoodContainer; if (food != null) { return(food.FoodQuality); } else { IHarvestable harvestable = obj as IHarvestable; if (harvestable != null) { return(harvestable.GetQuality()); } else { return(Quality.Neutral); } } } } }
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); }
public static void RestockDisplay(CraftersConsignmentDisplay display, out Common.StringBuilder debug) { debug = new Common.StringBuilder("Display: " + display.CatalogName + Common.NewLine + "ObjectID:" + display.ObjectId); if (qualites.Count == 0) { InitLists(); } List <int> slotsToSkipForWeddingCakeSetupOnChiller = new List <int> { 23, 25 }; List <int> slotsToSkipForWeddingCakeSetupOnRack = new List <int> { 0, 2, 4 }; List <int> slotsForWeddingCakesChiller = new List <int> { 21, 22, 24 }; List <int> slotsForWeddingCakesOnRack = new List <int> { 1, 3 }; // wedding cake slots are included in these so they get stocked... if the cakes are disabled, they will be skipped properly List <int> slotsForElegantStockingOnRack = new List <int> { 1, 3, 5, 8, 9, 11, 13, 14, 17, 18, 20, 22, 23, 26 }; List <int> slotsForElegantStockingOnChiller = new List <int> { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 22, 24 }; Recipe randomRestockRecipe = null; if (display.LotCurrent != null) { debug += Common.NewLine + "LotCurrent: " + display.LotCurrent.Name; } if (!display.InWorld) { debug += Common.NewLine + "Display not in world"; return; } if (Cupcake.Settings.IsDisplayExempt(display.ObjectId)) { debug += Common.NewLine + "Display has auto restock disabled"; return; } bool random = false; if (!Cupcake.Settings.HasSettings(display.ObjectId)) { debug += Common.NewLine + "Display has no user defined settings."; random = true; } if (!Cupcake.Settings.mAffectActive && random) { if (display.LotCurrent == null) { debug += Common.NewLine + "LotCurrent null"; return; } if (display.LotCurrent.LotId == Household.ActiveHousehold.LotId) { debug += Common.NewLine + "On active household lot"; return; } List <PropertyData> list = RealEstateManager.AllPropertiesFromAllHouseholds(); for (int i = 0; i < list.Count; i++) { if (list[i] != null && display.LotCurrent.LotId == list[i].LotId && list[i].Owner != null && list[i].Owner.OwningHousehold == Household.ActiveHousehold) { debug += Common.NewLine + "On owned lot"; return; } } } DisplayHelper.DisplayTypes displayType; Dictionary <int, Slot> slots = DisplayHelper.GetEmptyOrFoodSlots(display, out displayType); foreach (KeyValuePair <int, Slot> slot in slots) { debug += Common.NewLine + "Slot: " + slot.Key; if (displayType == DisplayHelper.DisplayTypes.Chiller) { if (!Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key)) { if (slot.Key > 20 && !Cupcake.Settings.mStockWeddingCakes) { debug += Common.NewLine + "Wedding cakes disabled, skipping top shelf"; continue; } if (Cupcake.Settings.mStockWeddingCakes && slotsToSkipForWeddingCakeSetupOnChiller.Contains(slot.Key)) { debug += Common.NewLine + "Skipping slots for presentable wedding cake setup"; continue; } if (Cupcake.Settings.mElegantRestock && !slotsForElegantStockingOnChiller.Contains(slot.Key)) { debug += Common.NewLine + "Skipping slot for elegant restocking"; continue; } } } if (displayType == DisplayHelper.DisplayTypes.Rack) { if (!Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key)) { if (Cupcake.Settings.mStockWeddingCakes && slotsToSkipForWeddingCakeSetupOnRack.Contains(slot.Key)) { debug += Common.NewLine + "Skipping slots for presentable wedding cake setup"; continue; } if (Cupcake.Settings.mElegantRestock && !slotsForElegantStockingOnRack.Contains(slot.Key)) { debug += Common.NewLine + "Skipping slot for elegant restocking"; continue; } } } GameObject containedObject = display.GetContainedObject(slot.Value) as GameObject; if (containedObject == null) { Dictionary <string, List <Quality> > settings = Cupcake.Settings.GetDisplaySettingsForSlot(display.ObjectId, slot.Key); Recipe recipe = null; IFoodContainer container = null; Quality quality = Quality.Perfect; if (random && !Cupcake.Settings.mDisableRandomAutoRestock && (!Cupcake.Settings.mOneRecipePerDisplayOnRandom || (Cupcake.Settings.mOneRecipePerDisplayOnRandom && randomRestockRecipe == null))) { debug += Common.NewLine + "Random"; if (Cupcake.Settings.mRandomRestockSettings.Count > 0) { if (Cupcake.Settings.Debugging) { debug += Common.NewLine + "Choices:"; foreach (KeyValuePair <string, List <Quality> > val in Cupcake.Settings.mRandomRestockSettings) { debug += Common.NewLine + val.Key; foreach (Quality val2 in val.Value) { debug += Common.NewLine + val2.ToString(); } } } if (Recipe.NameToRecipeHash.Count > 0) { string pick = RandomUtil.GetRandomObjectFromList <string>(new List <string>(Cupcake.Settings.mRandomRestockSettings.Keys)); if (Recipe.NameToRecipeHash.ContainsKey(pick)) { recipe = Recipe.NameToRecipeHash[pick]; debug += Common.NewLine + "Fetching random recipe..."; debug += Common.NewLine + "Pick: " + recipe.Key; quality = RandomUtil.GetRandomObjectFromList <Quality>(Cupcake.Settings.mRandomRestockSettings[pick]); debug += Common.NewLine + "Fetching random quality..."; debug += Common.NewLine + "Pick: " + quality.ToString(); } else { debug += Common.NewLine + "Failed to find defined recipe"; continue; } } } else { if (goodies.Count > 0) { recipe = RandomUtil.GetRandomObjectFromList <Recipe>(goodies); debug += Common.NewLine + "Fetching random bakery recipe..."; debug += Common.NewLine + "Pick: " + recipe.SpecificNameKey; debug += Common.NewLine + "Quality: Always Perfect"; } } randomRestockRecipe = recipe; } if (random && Cupcake.Settings.mOneRecipePerDisplayOnRandom && randomRestockRecipe != null) { debug += Common.NewLine + "OneRecipePerDisplayOnRandom = true" + Common.NewLine + "Last Recipe: " + randomRestockRecipe.GenericName; recipe = randomRestockRecipe; } if (settings != null) { debug += Common.NewLine + "Reading user settings..."; if (Cupcake.Settings.Debugging) { debug += Common.NewLine + "Choices:"; foreach (KeyValuePair <string, List <Quality> > val in settings) { debug += Common.NewLine + val.Key; foreach (Quality val2 in val.Value) { debug += Common.NewLine + val2.ToString(); } } } string pick = ""; if (settings.Count > 0) { List <string> tempList = new List <string>(); tempList.AddRange(settings.Keys); pick = RandomUtil.GetRandomObjectFromList <string>(tempList); if (Recipe.NameToRecipeHash.ContainsKey(pick)) { recipe = Recipe.NameToRecipeHash[pick]; debug += Common.NewLine + "Fetching random recipe..."; debug += Common.NewLine + "Pick: " + recipe.Key; } else { debug += Common.NewLine + "Failed to find defined recipe: " + pick; continue; } } else { debug += Common.NewLine + "Settings for slot was 0 count."; continue; } quality = RandomUtil.GetRandomObjectFromList <Quality>(Cupcake.Settings.mDisplayRestockSettings[display.ObjectId][slot.Key][pick]); debug += Common.NewLine + "Fetching random quality..."; debug += Common.NewLine + "Pick: " + quality.ToString(); } bool tryCake = false; if (random && Cupcake.Settings.mStockWeddingCakes && !Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key)) { List <string> cakes = new List <string> { "BSBakeWeddingCake", "WeddingCakeSliceDOT07" }; tryCake = true; if (GameUtils.IsInstalled(ProductVersion.EP4)) { cakes.Add("Wedding Cake Slice"); } if ((displayType == DisplayHelper.DisplayTypes.Chiller && slotsForWeddingCakesChiller.Contains(slot.Key)) || (displayType == DisplayHelper.DisplayTypes.Rack && slotsForWeddingCakesOnRack.Contains(slot.Key))) { debug += Common.NewLine + "Wedding cake slot"; recipe = null; while (recipe == null) { string pick = RandomUtil.GetRandomObjectFromList <string>(cakes); if (!Recipe.NameToRecipeHash.TryGetValue(pick, out recipe)) { // for folks with out of date mods if (pick == "BSBakeWeddingCake") { break; } } } } } if (recipe != null) { if (quality == Quality.Any) { // EA standard apparently doesn't handle this correctly... quality = RandomUtil.GetRandomObjectFromList <Quality>(qualites); } // Catalog recipes IGameObject cake = null; if (recipe.Key == "WeddingCakeSliceDOT07") { debug += Common.NewLine + "Attempt at Monte Vista cake"; cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingDOT07", ~ProductVersion.Undefined); if (cake is FailureObject) { cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingDOT07", ProductVersion.BaseGame); } } else if (recipe.Key == "Wedding Cake Slice") { debug += Common.NewLine + "Attempt at Generations cake"; cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingTraditional", ProductVersion.EP4); if (cake is FailureObject) { cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingTraditional", ProductVersion.BaseGame); } } else if (((tryCake && cake is FailureObject) || recipe.Key == "BSBakeWeddingCake")) { debug += Common.NewLine + "Attempt at Store Wedding cake"; cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingBakery", ~ProductVersion.Undefined); if (cake is FailureObject) { cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingBakery", ProductVersion.BaseGame); } } else if (recipe.Key == "BSBakeBirthdayCake") { debug += Common.NewLine + "Attempt at Store Birthday cake"; cake = GlobalFunctions.CreateObjectOutOfWorld("FoodBirthdayCakeBakery", ~ProductVersion.Undefined); if (cake is FailureObject) { cake = GlobalFunctions.CreateObjectOutOfWorld("FoodBirthdayCakeBakery", ProductVersion.BaseGame); } } else { container = recipe.CreateFinishedFood(recipe.CanMakeGroupServing ? Recipe.MealQuantity.Group : Recipe.MealQuantity.Single, quality); } if (cake != null) { if (cake is FailureObject) { debug += Common.NewLine + "Cake was FailureObject"; try { cake.Destroy(); } catch { } continue; } debug += Common.NewLine + "Cake success"; DisplayHelper.ParentToSlot(cake as GameObject, slot.Value, display); cake.AddToWorld(); InitInteractions(cake as GameObject); } if (container != null) { if (container is FailureObject) { debug += Common.NewLine + "Container was FailureObject"; try { container.Destroy(); } catch { } continue; } DisplayHelper.ParentToSlot(container as GameObject, slot.Value, display); container.SetGeometryState(recipe.SingleServingContainer); // this is how EA sets it, don't ask container.AddToWorld(); ServingContainer container2 = container as ServingContainer; if (container2 != null) { int[] numArray = new int[] { 0, 0, 0, 0, 0, 0, 15, 30, 0x2d, 60, 0x4b, 100, 0x65 }; container2.CookingProcess.FoodPoints = numArray[(int)quality]; container2.CookingProcess.FoodState = FoodCookState.Cooked; container2.FoodCookStateChanged(container2.CookingProcess.FoodState); } InitInteractions(container as GameObject); debug += Common.NewLine + "Success: " + recipe.GenericName + Common.NewLine + quality.ToString(); } } } else { debug += Common.NewLine + "Slot contained object: " + containedObject.CatalogName; } } display.AddInteractionsToChildObjects(); }