コード例 #1
0
ファイル: StoreHelperClass.cs プロジェクト: yakoder/NRaas
        public static void UnSpoil(StoreSetRegister register, StoreSetBase storebase, ani_StoreRug rug, int servingPrice)
        {
            foreach (var stack in register.Inventory.InventoryItems.Values)
            {
                if (register != null)
                {
                    foreach (var item in stack.List)
                    {
                        // if (item.Object.Value == 0)
                        {
                            ServingContainer      single = item.Object as ServingContainer;
                            ServingContainerGroup group  = item.Object as ServingContainerGroup;

                            if (group != null)
                            {
                                group.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice * group.NumServingsLeft);
                                group.RemoveSpoilageAlarm();
                            }
                            else if (single != null)
                            {
                                single.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice);
                                single.RemoveSpoilageAlarm();
                            }
                        }
                    }
                }

                //if (rug != null)
                //{
                //    List<ObjectGuid> objectsICanBuyInDisplay = rug.GetObjectsICanBuyInDisplay(null);
                //    for (int i = 0; i < objectsICanBuyInDisplay.Count; i++)
                //    {
                //        GameObject gameObject = GlobalFunctions.ConvertGuidToObject<GameObject>(objectsICanBuyInDisplay[i]);
                //        if (gameObject != null)
                //        {
                //            CMStoreSet.PrintMessage(gameObject.GetType().ToString());
                //            if (gameObject.GetType() == typeof(ServingContainerGroup) || gameObject.GetType() == typeof(ServingContainerSingle))
                //            {
                //                CMStoreSet.PrintMessage("start unspoiling");
                //                ServingContainer single = gameObject as ServingContainer;
                //                ServingContainerGroup group = gameObject as ServingContainerGroup;

                //                if (group != null)
                //                {
                //                    group.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice * group.NumServingsLeft);
                //                    group.RemoveSpoilageAlarm();
                //                }
                //                else if (single != null)
                //                {
                //                    single.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice);
                //                    single.RemoveSpoilageAlarm();
                //                }
                //            }
                //        }
                //    }
                //}
            }
        }
コード例 #2
0
ファイル: RestockItem.cs プロジェクト: yakoder/NRaas
                public override bool Test(Sim a, RestockItem target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    //If restock from inventory, check does the item exist
                    StoreSetBase sBase = RestockItemHelperClass.FindParentShopBase(target);

                    if (sBase == null)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(CMStoreSet.LocalizeString("GrayNeedsPedestal", new object[0] {
                        }));
                        return(false);
                    }

                    if (sBase.Charred)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(CMStoreSet.LocalizeString("GrayCharred", new object[0] {
                        }));
                        return(false);
                    }

                    if (RestockItemHelperClass.RestockFromInventory(target, sBase.Info.RestockCraftable))
                    {
                        if (sBase.Info.RegisterId == ObjectGuid.InvalidObjectGuid && !sBase.Info.RestockCraftable)
                        {
                            greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(CMStoreSet.LocalizeString("GrayNeedsRegister", new object[0] {
                            }));
                            return(false);
                        }

                        if (sBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid && RestockItemHelperClass.ReturnRestocableObjectFromRegister(target, sBase.Info.RegisterId) == null)
                        {
                            greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(CMStoreSet.LocalizeString("GrayInventoryEmpty", new object[0] {
                            }));
                            return(false);
                        }
                    }
                    else
                    {
                        //Should restock buy items be disabled
                        if (target.info.Type == ItemType.Buy && !sBase.Info.RestockBuyMode)
                        {
                            greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(CMStoreSet.LocalizeString("GrayRestockBuyModeDisabled", new object[0] {
                            }));
                            return(false);
                        }
                    }
                    return(true);
                }
コード例 #3
0
ファイル: RestockItem.cs プロジェクト: yakoder/NRaas
            public override bool Run()
            {
                if (!this.Actor.RouteToObjectRadialRange(this.Target, UniversityWelcomeKit.kMinRouteDistance, UniversityWelcomeKit.kMaxRouteDistance))
                {
                    return(false);
                }

                base.StandardEntry();
                base.BeginCommodityUpdates();
                base.EnterStateMachine("UniversityWelcomeKit", "EnterUniversity", "x");
                base.AnimateSim("LoopTest");
                bool flag = base.DoTimedLoop(2f, ExitReason.Default);

                base.AnimateSim("ExitAptituteTest");
                base.EndCommodityUpdates(flag);
                base.StandardExit();

                //Replace restock item with the restocked item
                StoreSetBase b = RestockItemHelperClass.FindParentShopBase(this.Target);
                GameObject   o = RestockItemHelperClass.RecreateSoldObject(this.Target, this.Actor.SimDescription);

                //If the sim is tending the register, make him go back to tending
                if (b != null)
                {
                    b.AddInteractionsToChildObjects();
                    List <StoreSetRegister> registers = new List <StoreSetRegister>(Sims3.Gameplay.Queries.GetObjects <StoreSetRegister>(b.LotCurrent));
                    if (registers != null)
                    {
                        foreach (var register in registers)
                        {
                            //Push hired clerk to go back to work.
                            if (CMStoreSet.IsStoreOpen(register) && register.mPreferredClerk == this.Actor.SimDescription.SimDescriptionId)
                            {
                                base.TryPushAsContinuation(StoreSetRegister.PostureIdle.Singleton, register);
                                break;
                            }
                        }
                    }
                }

                return(true);
            }
コード例 #4
0
        public static GameObject RecreateSoldObject(RestockItem restockItem, SimDescription actor)
        {
            try
            {
                IGameObject      gameObject       = null;
                bool             restockBuyMode   = false;
                bool             restockCraftable = false;
                StoreSetRegister register         = null;

                bool         isRug;
                StoreSetBase shopBase = ReturnStoreSetBase(restockItem, out isRug);

                if (shopBase != null)
                {
                    if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                    {
                        register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
                    }

                    restockBuyMode   = shopBase.Info.RestockBuyMode;
                    restockCraftable = shopBase.Info.RestockCraftable;

                    #region Find the slot

                    bool slotFound = false;
                    Slot slot      = Slot.ContainmentSlot_0;
                    if (!isRug)
                    {
                        Slot[] containmentSlots = shopBase.GetContainmentSlots();

                        if (containmentSlots != null)
                        {
                            for (int i = 0; i < containmentSlots.Length; i++)
                            {
                                GameObject o = shopBase.GetContainedObject(containmentSlots[i]) as GameObject;

                                if (o != null && o.ObjectId == restockItem.ObjectId)
                                {
                                    slotFound = true;
                                    slot      = containmentSlots[i];
                                    break;
                                }
                            }
                        }
                    }
                    #endregion

                    //Restock from inventory only, if not buy object and linked to register
                    bool restockFromInventory = RestockFromInventory(restockItem, restockCraftable);

                    //Restock from buy mode
                    #region Buy Mode
                    if (!restockFromInventory)
                    {
                        if (restockItem.info.Type == ItemType.Buy || restockItem.info.Type == ItemType.Craftable)
                        {
                            gameObject = GlobalFunctions.CreateObject(restockItem.info.Key, restockItem.Position, restockItem.mLevel, restockItem.ForwardVector);
                            if (!(gameObject is FailureObject))
                            {
                                if (!string.IsNullOrEmpty(restockItem.info.DesignPreset))
                                {
                                    SortedList <string, bool>     enabledStencils = new SortedList <string, bool>();
                                    SortedList <string, Complate> patterns        = StoreHelperClass.ExtractPatterns(restockItem.info.DesignPreset, enabledStencils);
                                    DesignModeSwap designModeSwap = Complate.SetupDesignSwap(gameObject.ObjectId, patterns, false, enabledStencils);
                                    if (designModeSwap != null)
                                    {
                                        designModeSwap.ApplyToObject();
                                    }
                                }
                            }
                        }
                        else
                        {
                            gameObject = ReturnShoppingObject(restockItem, actor, register);
                            gameObject.AddToWorld();
                            gameObject.SetPosition(restockItem.Position);
                        }
                        #region Pay for Restock

                        //Reduce from base owner or register's owner
                        if (shopBase.Info.Owner != 0uL)
                        {
                            SimDescription sd = CMStoreSet.ReturnSim(shopBase.Info.Owner);
                            if (sd != null)
                            {
                                sd.ModifyFunds(-restockItem.info.Price);
                            }
                            else
                            {
                                CMStoreSet.PrintMessage("Couldn't find owner sim");
                            }
                        }
                        else if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                        {
                            //StoreSetRegister register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
                            if (register != null && register.Info.OwnerId != 0uL)
                            {
                                SimDescription sd = CMStoreSet.ReturnSim(register.Info.OwnerId);
                                if (sd != null)
                                {
                                    sd.ModifyFunds(-restockItem.info.Price);
                                }
                            }
                        }

                        #endregion
                    }
                    #endregion Buy Mode

                    #region Inventory
                    else
                    {
                        //Restock from Inventory
                        if (shopBase != null && shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                        {
                            gameObject = ReturnRestocableObject(restockItem, shopBase.Info.RegisterId);

                            if (gameObject != null)
                            {
                                gameObject.AddToWorld();
                                gameObject.SetPosition(restockItem.Position);
                                gameObject.SetForward(restockItem.ForwardVector);
                            }
                            else
                            {
                                CMStoreSet.PrintMessage("Restockable object null");
                            }
                        }
                    }
                    #endregion Inventory

                    //Delete restock object
                    if (restockItem != null)
                    {
                        restockItem.Destroy();
                    }

                    //Add restocked item back to slot
                    if (slotFound)
                    {
                        IGameObject io = (IGameObject)shopBase;
                        gameObject.ParentToSlot(io, slot);
                    }


                    return((GameObject)gameObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Exception ex)
            {
                CMStoreSet.PrintMessage("RecreateSoldObject: " + ex.Message);
                return(null);
            }
        }
コード例 #5
0
ファイル: StoreHelperClass.cs プロジェクト: yakoder/NRaas
        public static bool AddPurchaseInteraction(Sim sim, GameObject o, StoreSetBase sBase, bool isAutonomous)
        {
            if (o.GetType() == typeof(FoodProp))
            {
                return(false);
            }

            if (o.GetType() == typeof(RestockItem))
            {
                return(false);
            }

            if (o.Charred)
            {
                return(false);
            }

            //Custom tests
            //Find register and then the owner
            if (sim != null && sBase != null)
            {
                StoreSetRegister register = null;

                if (sBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                {
                    register = CMStoreSet.ReturnRegister(sBase.Info.RegisterId, sBase.LotCurrent);
                }

                //If linked to register and nobody tending, can't buy
                //TODO

                //If sim is not in the active household and BuyWhenActive = true
                //Can buy autonomously only if store owner is the active hosuehold
                if (isAutonomous && StoreSetBase.ReturnBuyWhenActive())
                {
                    SimDescription owner = null;

                    if (sBase.Info.Owner != 0uL)
                    {
                        owner = CMStoreSet.ReturnSim(sBase.Info.Owner);
                    }
                    else if (sBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                    {
                        if (register != null && register.Info.OwnerId != 0uL)
                        {
                            owner = CMStoreSet.ReturnSim(register.Info.OwnerId);
                        }
                    }

                    //in-active sims shouldn't buy unless from the store of the active sim
                    if ((!sim.Household.IsActive && owner == null) || (!sim.Household.IsActive && owner != null && !owner.Household.IsActive))
                    {
                        return(false);
                    }

                    //Sims in the active household can buy if they don't own the store
                    if (sim.Household.IsActive && owner != null && owner.Household.IsActive)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #6
0
ファイル: StoreHelperClass.cs プロジェクト: Robobeurre/NRaas
		public static bool AddPurchaseInteraction(Sim sim, GameObject o, StoreSetBase sBase, bool isAutonomous)
		{
			if (o.GetType() == typeof(FoodProp))
				return false;

			if (o.GetType() == typeof(RestockItem))
				return false;

			if (o.Charred)
				return false;

			//Custom tests
			//Find register and then the owner
			if (sim != null && sBase != null)
			{
				StoreSetRegister register = null;

				if (sBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
					register = CMStoreSet.ReturnRegister(sBase.Info.RegisterId, sBase.LotCurrent);

				//If linked to register and nobody tending, can't buy
				//TODO

				//If sim is not in the active household and BuyWhenActive = true     
				//Can buy autonomously only if store owner is the active hosuehold
				if (isAutonomous && StoreSetBase.ReturnBuyWhenActive())
				{
					SimDescription owner = null;

					if (sBase.Info.Owner != 0uL)
						owner = CMStoreSet.ReturnSim(sBase.Info.Owner);
					else if (sBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
					{

						if (register != null && register.Info.OwnerId != 0uL)
						{
							owner = CMStoreSet.ReturnSim(register.Info.OwnerId);
						}
					}

					//in-active sims shouldn't buy unless from the store of the active sim
					if ((!sim.Household.IsActive && owner == null) || (!sim.Household.IsActive && owner != null && !owner.Household.IsActive))
					{
						return false;
					}

					//Sims in the active household can buy if they don't own the store
					if (sim.Household.IsActive && owner != null && owner.Household.IsActive)
					{
						return false;
					}
				}
			}

			return true;
		}
コード例 #7
0
ファイル: StoreHelperClass.cs プロジェクト: Robobeurre/NRaas
		public static void UnSpoil(StoreSetRegister register, StoreSetBase storebase, ani_StoreRug rug, int servingPrice)
		{
			foreach (var stack in register.Inventory.InventoryItems.Values)
			{
				if (register != null)
				{
					foreach (var item in stack.List)
					{
						// if (item.Object.Value == 0)
						{
							ServingContainer single = item.Object as ServingContainer;
							ServingContainerGroup group = item.Object as ServingContainerGroup;

							if (group != null)
							{
								group.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice * group.NumServingsLeft);
								group.RemoveSpoilageAlarm();
							}
							else if (single != null)
							{
								single.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice);
								single.RemoveSpoilageAlarm();
							}
						}
					}
				}

				//if (rug != null)
				//{
				//    List<ObjectGuid> objectsICanBuyInDisplay = rug.GetObjectsICanBuyInDisplay(null);
				//    for (int i = 0; i < objectsICanBuyInDisplay.Count; i++)
				//    {
				//        GameObject gameObject = GlobalFunctions.ConvertGuidToObject<GameObject>(objectsICanBuyInDisplay[i]);
				//        if (gameObject != null)
				//        {
				//            CMStoreSet.PrintMessage(gameObject.GetType().ToString());
				//            if (gameObject.GetType() == typeof(ServingContainerGroup) || gameObject.GetType() == typeof(ServingContainerSingle))
				//            {
				//                CMStoreSet.PrintMessage("start unspoiling");
				//                ServingContainer single = gameObject as ServingContainer;
				//                ServingContainerGroup group = gameObject as ServingContainerGroup;

				//                if (group != null)
				//                {
				//                    group.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice * group.NumServingsLeft);
				//                    group.RemoveSpoilageAlarm();
				//                }
				//                else if (single != null)
				//                {
				//                    single.mPurchasedPrice = ReturnPriceByQuality(single.FoodQuality, servingPrice);
				//                    single.RemoveSpoilageAlarm();
				//                }
				//            }
				//        }
				//    }
				//}


			}
		}