public override bool Run() { bool success = base.Run(); WorldType type = GameUtils.GetCurrentWorldType(); bool processPurchase = success; //Don't process for the cashier if (!CommonMethods.IsSociable(base.Actor)) { processPurchase = false; } //Pay the lot owner if (processPurchase && success && base.Actor.IsHoldingAnything()) { int price = AddMenuItem.ReturnCoffeePrice(); //No lot owners abroad if (type != WorldType.Vacation) { CommonMethods.PayLotOwner(base.Actor, base.Target.LotCurrent, price); } householdFunds = 0; //if this happened through "Call for meal" //Removing the price from the active buying Sim needs to be done manually base.Actor.ModifyFunds(-price); } return(success); }
// Methods public override bool Run() { //Navigate to the register if (!base.Actor.RouteToPointRadialRange(base.Target.Position, 0.5f, 2f)) { return(false); } purchasedItems = new List <object>(); if (base.Actor.Household.IsActive && this.GetPriority().Level == InteractionPriorityLevel.UserDirected) { //ShowShoppingDialog(); purchasedItems = base.SelectedObjects; FinishedCallBack(base.Actor); } else { if (!base.Actor.Household.IsActive) { //Buy and go home if (Buy(AddMenuItem.ReturnCustomerPrecentage())) { purchasedItems = ReturnRandomObject(); FinishedCallBack(base.Actor); } Sim.MakeSimGoHome(base.Actor, false); } } return(true); }
public static void CalculateBroughtItems(Dictionary <uint, List <ObjectGuid> > inventoryItemStack, Sim sim, GameObject target) { // if (sim.Household.IsActive) { List <ObjectGuid> newItemList = new List <ObjectGuid>(); foreach (IInventoryItemStack item in sim.InventoryComp.InventoryUIModel.InventoryItems) { //new item if (!inventoryItemStack.ContainsKey(item.StackId)) { newItemList.AddRange(item.StackObjects); } else { List <ObjectGuid> foundStack = inventoryItemStack[item.StackId]; //Check stack if (foundStack.Count < item.StackObjects.Count) { List <ObjectGuid> ids = new List <ObjectGuid>(); //Find the objec it foreach (ObjectGuid g in item.StackObjects) { if (!foundStack.Contains(g)) { ids.Add(g); } } if (ids != null && ids.Count > 0) { newItemList.AddRange(ids); } } } } //Loop through the new items int totalPrice = 0; foreach (ObjectGuid g in newItemList) { GameObject itemPurchased = GameObject.GetObject(g); if (itemPurchased != null) { int price = (int)(itemPurchased.Value * (new decimal(AddMenuItem.ReturnProfit()) / 100)); if (price == 0) { price = 1; } totalPrice += price; } } if (newItemList.Count > 0) { CommonMethods.PayLotOwner(sim, target.LotCurrent, totalPrice); } } }
public static bool PushDrinkAsContinuation(Sim sim, ConcessionsStand.ConcessionsBeverage g) { GameObject chair = FindClosestChair(sim); Posture posture = new Glass.CarryingGlassPosture(sim, g); if (sim.Posture is Sim.StandingPosture) { sim.Posture = posture; } else { posture.PreviousPosture = sim.Posture.PreviousPosture; sim.Posture.PreviousPosture = posture; } //if (chair != null) //{ // foreach (InteractionObjectPair item in chair.Interactions) // { // //Get the sit interaction // if (item.ToString().ToLower().Contains(".sit+definition")) // { // g.mTotalSips = AddMenuItem.ReturnTotalSipsSitting(); // g.mAvailableSipsLeft = g.mTotalSips; // sim.InteractionQueue.PushAsContinuation(Sims3.Gameplay.InteractionsShared.Sit.Singleton, chair, true, new InteractionPriority(InteractionPriorityLevel.UserDirected), true); // sim.InteractionQueue.PushAsContinuation(Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup.DrinkHeldCup.Singleton, g, true, new InteractionPriority(InteractionPriorityLevel.UserDirected), true); // } // } //} //else { try { g.mTotalSips = AddMenuItem.ReturnTotalSipsStanding(); g.mAvailableSipsLeft = g.mTotalSips; sim.InteractionQueue.PushAsContinuation(Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup.DrinkHeldCup.Singleton, g, true, new InteractionPriority(InteractionPriorityLevel.UserDirected), true); } catch (Exception ex) { StyledNotification.Show(new StyledNotification.Format(ex.Message, StyledNotification.NotificationStyle.kGameMessageNegative)); } // sim.InteractionQueue.PushAsContinuation(Glass.Drink.Singleton, g, true); } return(true); }
/// <summary> /// If we brought an item through a normal game register, pay the lot owner /// </summary> /// <param name="sim"></param> /// <param name="o"></param> public static void PayLotOwner(Sim sim, Lot lotCurrent, int price) { if (price > 0) { Household lotOwner = ReturnLotOwner(lotCurrent); if (lotOwner != null && lotOwner != sim.Household) { lotOwner.ModifyFamilyFunds(price); if (AddMenuItem.ReturnShowNotifications()) { StyledNotification.Show(new StyledNotification.Format(CommonMethods.LocalizeString("LotOwnerEarned", new object[] { lotOwner.Name, price }), StyledNotification.NotificationStyle.kGameMessagePositive)); } } } }
/// <summary> /// Returns a list of items from the store's inventory /// </summary> /// <param name="sim"></param> /// <returns></returns> public static List <GameObject> ItemDictionary(Sim actor, RegisterType type, Lot lot) { //Nuutti //Get all treasure boxes on this lot List <GameObject> list = new List <GameObject>(); List <TreasureChest> tList = ReturnTreasureChests(actor, lot); foreach (TreasureChest tChest in tList) { List <GameObject> cInventoryItems = tChest.Inventory.FindAll <GameObject>(false); //Go through list and filter foreach (var item in cInventoryItems) { ItemType itemType = ItemType.General; DriedFood driedFood = item as DriedFood; Morsel _morsel = item as Morsel; if (driedFood != null || _morsel != null || item.GetType() == typeof(Morsel) || item.GetType() == typeof(PlateServing) || item.GetType() == typeof(Ingredient) || item.GetType() == typeof(Cake) || item.GetType() == typeof(Fish)) { itemType = ItemType.Food; } else { NectarBottle nectar = item as NectarBottle; Book book = item as Book; if (book != null) { itemType = ItemType.Book; } else if (nectar != null) { itemType = ItemType.Nectar; } } //Add only to the correct type of register if (type == RegisterType.Food && itemType == ItemType.Food) { list.Add(item); } else if (type == RegisterType.Books && itemType == ItemType.Book) { list.Add(item); } else if (type == RegisterType.General && (itemType == ItemType.General || AddMenuItem.ReturnSellIngInGeneralRegister())) { list.Add(item); } else if (type == RegisterType.Nectar && itemType == ItemType.Nectar) { list.Add(item); } } } return(list); }
/// <summary> /// Handle payments and object inventory swapping. /// </summary> /// <param name="purchasedItems"></param> public void HandlePurchases(List <object> purchasedItems) { try { Boolean okToShop = true; if (purchasedItems.Count > 0 && okToShop) { StringBuilder sb = new StringBuilder(); sb.Append(CommonMethods.LocalizeString("ItemsPurchasedBySim", new object[] { base.Actor.Name })); //Get the lot owner Household ownerHousehold = CommonMethods.ReturnLotOwner(base.Target.LotCurrent); int purchaseTotal = 0; int lotOwnerIncome = 0; //Get Shop inventory List <StorageInventory> storeInventory = CommonMethods.ReturnStorageInventory(base.Actor, base.Target.LotCurrent); //Loop through the items that were purchased foreach (GameObject item in purchasedItems) { StorageInventory si = storeInventory.Find(delegate(StorageInventory o) { return(o.ItemGuid == item.ObjectId); }); List <TreasureChest> tList = CommonMethods.ReturnTreasureChests(base.Actor, base.Target.LotCurrent); int price = 0; int objectValue = (int)ReturnItemPrice(item); if (si != null) { //Find the chest the object is in TreasureChest tc = tList.Find(delegate(TreasureChest t) { return(t.ObjectId == si.StorageGuid); }); GameObject storageObject = null; if (tc != null) { storageObject = tc; } if (storageObject != null) { //Did removing of the item succeed if (storageObject.Inventory.TryToRemove(item)) { //If the product was made by a sim who is not a member of the lot owner household //Give the maker, 50% of the value SimDescription productMaker = CommonMethods.ReturnCreaotrSimDescription(item); if (productMaker != null && !productMaker.IsDead) { //Devide the earnings if (ownerHousehold != null) { price = objectValue / 2; lotOwnerIncome += price; } else { price = objectValue; } //lotOwner.ModifyFamilyFunds(price); productMaker.Household.ModifyFamilyFunds(price); //If the owner of the pruduct is in a skill based career, and the item they sold is related to their job //Count it towards their job performance if (productMaker != null && productMaker.Occupation != null && productMaker.Occupation.IsSkillBased) { //First check that the buyer and the product maker are not in the same household if (base.Actor.Household != productMaker.Household) { UpdateSkillBasedCareerEarning(productMaker, item, price); } } purchaseTotal += objectValue; } else { //The item doesn't have an owner //Add 30% to the price, if not the active Household price = (int)objectValue; //(int)(objectValue * 1.3); purchaseTotal += price; //If the lot is owned by a sim if (ownerHousehold != null) { lotOwnerIncome += price; //If the item was harvested, we assume it was planted by the owner or somebody in his household // lotOwner.ModifyFamilyFunds(price); //Collect all sims from the lot, and if their occupation is gardener, //devide the money earned from the purchase between them if (item.GetType() == typeof(Ingredient)) { if (((Ingredient)item).CraftType == CraftType.Fruit) { List <Sim> gardnerSims = new List <Sim>(); foreach (Sim sim in ownerHousehold.Sims) { if (sim.SimDescription.YoungAdultOrAbove && sim.SimDescription.OccupationAsSkillBasedCareer != null) { if (sim.SimDescription.OccupationAsSkillBasedCareer.CareerName.Equals(OccupationNames.Gardener.ToString())) { gardnerSims.Add(sim); } } } if (gardnerSims != null && gardnerSims.Count > 0) { foreach (Sim sim in gardnerSims) { int simoleansEarned = (price / gardnerSims.Count) > 1 ? (price / gardnerSims.Count) : 1; UpdateSkillBasedCareerEarning(sim.SimDescription, item, simoleansEarned); } } } } } } base.Actor.Inventory.TryToAdd(item, false); storeInventory.Remove(si); sb.Append(CommonMethods.LocalizeString("PurchasedItem", new object[] { item.CatalogName, price })); } else { StyledNotification.Show(new StyledNotification.Format("Failed to remove " + item.CatalogName, StyledNotification.NotificationStyle.kGameMessagePositive)); } } } } if (purchaseTotal > 0) { base.Actor.ModifyFunds(-purchaseTotal); sb.Append(CommonMethods.LocalizeString("PurchaseTotal", new object[] { purchaseTotal })); //Give the money earned from the purchase to the owner of the lot if (lotOwnerIncome > 0 && ownerHousehold != null) { ownerHousehold.ModifyFamilyFunds(lotOwnerIncome); sb.Append(CommonMethods.LocalizeString("LotOwnerEarned", new object[] { ownerHousehold.Name, lotOwnerIncome })); } //Show only if wanted if (AddMenuItem.ReturnShowNotifications()) { StyledNotification.Show(new StyledNotification.Format(sb.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive)); } } } } catch (Exception ex) { StyledNotification.Show(new StyledNotification.Format(ex.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive)); } }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> public static float ReturnItemPrice(GameObject obj) { bool isFood = false; float objectValue = (float)obj.Value; SimDescription productMaker = CommonMethods.ReturnCreaotrSimDescription(obj); //Food has no value by default if (objectValue == 0) { ServingContainer pf = obj as ServingContainer; if (pf != null) { //Set price depending on quality pf.RemoveSpoilageAlarm(); // StyledNotification.Show(new StyledNotification.Format(pf.Cost + " " + pf.FoodQuality, StyledNotification.NotificationStyle.kGameMessagePositive)); isFood = true; switch (pf.FoodQuality) { case Quality.Foul: case Quality.Horrifying: case Quality.Bad: case Quality.Putrid: objectValue = AddMenuItem.ReturnFoodPriceBad(); break; case Quality.Nice: case Quality.VeryNice: objectValue = AddMenuItem.ReturnFoodPriceNice(); break; case Quality.Great: case Quality.Outstanding: case Quality.Excellent: objectValue = AddMenuItem.ReturnFoodPriceGreat(); break; case Quality.Perfect: objectValue = AddMenuItem.ReturnFoodPricePerfect(); break; default: objectValue = AddMenuItem.ReturnFoodPriceDefault(); break; } } } //If the product has no maker, multiply by 1.3 float priceIncrease = objectValue * (1 + (float)AddMenuItem.ReturnProfitForNoneGrownGoods() / 100); if (productMaker == null && !isFood) { if (priceIncrease < (objectValue + 1)) { objectValue += 1; } else { objectValue = priceIncrease; } } else if (obj.GetType() == typeof(Ingredient)) { objectValue *= (1 + (float)AddMenuItem.ReturnProfitForIngredients() / 100); } return(objectValue); }
public override bool Run() { StyledNotification.Show(new StyledNotification.Format("RUN", StyledNotification.NotificationStyle.kGameMessageNegative)); bool success = base.Run(); WorldType type = GameUtils.GetCurrentWorldType(); bool processPurchase = success; //Don't process for the cashier if (!CommonMethods.IsSociable(base.Actor)) { processPurchase = false; } StyledNotification.Show(new StyledNotification.Format("After run", StyledNotification.NotificationStyle.kGameMessageNegative)); //Pay the lot owner if (processPurchase && success) { int price = (int)((householdFunds - base.Actor.Household.FamilyFunds) * (new decimal(AddMenuItem.ReturnProfit()) / 100)); if (price <= 0) { price = 5; } StyledNotification.Show(new StyledNotification.Format(base.Actor.Name, StyledNotification.NotificationStyle.kGameMessageNegative)); //No lot owners abroad if (type != WorldType.Vacation) { CommonMethods.PayLotOwner(base.Actor, base.Target.LotCurrent, price); } householdFunds = 0; //if this happened through "Call for meal" //Removing the price from the active buying Sim needs to be done manually if (base.Autonomous) { base.Actor.ModifyFunds(-price); } } return(success); }
public BaseFoodStand.BaseFoodData ShowBuyConcessionsFoodDialog(bool autonomous) { List <ushort> availibleFoodGuids = GetAvailibleFoodGuids(BaseFoodStand.FoodType.None, base.Actor); ThumbnailKey thumbnail = ThumbnailKey.kInvalidThumbnailKey; string text = string.Empty; List <ObjectPicker.RowInfo> list = new List <ObjectPicker.RowInfo>(); List <BaseFoodStand.BaseFoodData> foods = new List <BaseFoodStand.BaseFoodData>(); foreach (ushort current in availibleFoodGuids) { BaseFoodStand.BaseFoodData baseFoodData = null; if (ConcessionsStand.SeasonalFoodData.sSeasonalFoodData.TryGetValue(current, out baseFoodData)) { List <ObjectPicker.ColumnInfo> list2 = new List <ObjectPicker.ColumnInfo>(); bool addToList = false; switch (baseFoodData.FoodType) { case ConcessionsStand.FoodType.HotBeverage: { thumbnail = GetThumbnailKeyForDrink(baseFoodData.FoodType == BaseFoodStand.FoodType.HotBeverage); text = Localization.LocalizeString(ConcessionsStand.sBaseBeverageLocKey + baseFoodData.DrinkNameLocKey, new object[0]); addToList = true; foods.Add(baseFoodData); break; } } if (addToList) { list2.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, text)); int num = AddMenuItem.ReturnCoffeePrice(); list2.Add(new ObjectPicker.MoneyColumn(num)); ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(current, list2); list.Add(item); } } } BaseFoodStand.BaseFoodData foodData = null; if (!autonomous) { List <ObjectPicker.HeaderInfo> list3 = new List <ObjectPicker.HeaderInfo>(); List <ObjectPicker.TabInfo> list4 = new List <ObjectPicker.TabInfo>(); list3.Add(new ObjectPicker.HeaderInfo(ShoppingRegister.sLocalizationKey + ":BuyConcessionsFoodColumnName", ShoppingRegister.sLocalizationKey + ":BuyConcessionsFoodColumnTooltip", 200)); list3.Add(new ObjectPicker.HeaderInfo("Ui/Caption/Shopping/Cart:Price", "Ui/Tooltip/Shopping/Cart:Price")); list4.Add(new ObjectPicker.TabInfo("coupon", ShoppingRegister.LocalizeString("AvailableConcessionsFoods", new object[0]), list)); List <ObjectPicker.RowInfo> list5 = SimplePurchaseDialog.Show(ShoppingRegister.LocalizeString("BuyConcessionsFoodTitle", new object[0]), base.Actor.Household.FamilyFunds, list4, list3, true); if (list5 == null || list5.Count != 1) { return(null); } foodData = list5[0].Item as BaseFoodStand.BaseFoodData; CommonMethods.ShowMessage(list5.Count.ToString()); CommonMethods.ShowMessage(list5[0].Item.ToString()); if (foodData == null) { CommonMethods.ShowMessage("foodData null"); } } else { foodData = RandomUtil.GetRandomObjectFromList <BaseFoodStand.BaseFoodData>(foods); } return(foodData); }
public override bool Run() { bool success = base.Run(); //Pay lot owner WorldType type = GameUtils.GetCurrentWorldType(); if (type != WorldType.Vacation) { bool processPurchase = success; //Don't process for the cashier if (!CommonMethods.IsSociable(base.Actor)) { processPurchase = false; } //Pay the lot owner if (processPurchase) { int price = (int)((householdFunds - base.Actor.Household.FamilyFunds) * (new decimal(AddMenuItem.ReturnProfit()) / 100)); if (price <= 0) { price = 5; } CommonMethods.PayLotOwner(base.Actor, base.Target.LotCurrent, price); householdFunds = 0; } } return(success); }