Ejemplo n.º 1
0
        public static bool CreateFoodAndPushConsumeOnSim(ConcessionsStand.BaseFoodData baseFoodData, Sim sim)
        {
            CommonMethods.ShowMessage(baseFoodData.mFoodType.ToString() + " " + baseFoodData);
            bool result = true;

            switch (baseFoodData.mFoodType)
            {
            case ConcessionsStand.FoodType.HotBeverage:
            case ConcessionsStand.FoodType.ColdBeverage:
            {
                BaseFoodStand.BaseFoodStandBeverage baseFoodStandBeverage = CreateBeverage(baseFoodData.FoodType == BaseFoodStand.FoodType.HotBeverage, sim);
                if (baseFoodStandBeverage != null)
                {
                    BaseFoodStand.FoodType foodType = baseFoodData.FoodType;
                    baseFoodStandBeverage.IsColdResortDrink = (foodType == BaseFoodStand.FoodType.ColdBeverage);
                    float tempChangePerSip = (foodType == BaseFoodStand.FoodType.HotBeverage) ? ConcessionsStand.kTempChangePerSipHotDrink : ConcessionsStand.kTempChangePerSipColdDrink;
                    baseFoodStandBeverage.InitData(baseFoodData.DrinkNameLocKey, baseFoodData.BevFoodUnits, baseFoodData.BuffToAdd, tempChangePerSip);
                    baseFoodData = null;
                    baseFoodStandBeverage.SetOpacity(0f, 0f);
                    if (sim.ParentToRightHand(baseFoodStandBeverage))
                    {
                        CarrySystem.EnterWhileHolding(sim, baseFoodStandBeverage);
                        baseFoodStandBeverage.FadeIn(true);
                        sim.Wander(ConcessionsStand.kMinMaxWanderBeforeDrink[0], ConcessionsStand.kMinMaxWanderBeforeDrink[1], false, RouteDistancePreference.NoPreference, false);
                        result = baseFoodStandBeverage.PushDrinkAsContinuation(sim);
                    }
                    else
                    {
                        baseFoodStandBeverage.Destroy();
                        result = false;
                    }
                }
                break;

                //string instanceName = (selectedFood.mFoodType == ConcessionsStand.FoodType.HotBeverage) ? "beverageCupHot" : "beverageCupCold";
                //ConcessionsStand.ConcessionsBeverage concessionsBeverage = GlobalFunctions.CreateObject(instanceName, ProductVersion.EP8, sim.Position, 1, Vector3.UnitZ, null, null) as ConcessionsStand.ConcessionsBeverage;
                //if (concessionsBeverage != null)
                //{
                //    float tempChangePerSip = (selectedFood.mFoodType == BaseFoodStand.FoodType.HotBeverage) ? ConcessionsStand.kTempChangePerSipHotDrink : ConcessionsStand.kTempChangePerSipColdDrink;
                //    concessionsBeverage.InitData(selectedFood.DrinkNameLocKey, selectedFood.BevFoodUnits, selectedFood.BuffToAdd, tempChangePerSip);
                //  //  concessionsBeverage.InitData(selectedFood.mFoodType, selectedFood.mDrinkNameLocKey, selectedFood.mBevFoodUnits, selectedFood.mBuffToAdd);
                //    concessionsBeverage.SetOpacity(0f, 0f);
                //    if (sim.ParentToRightHand(concessionsBeverage))
                //    {
                //        CarrySystem.EnterWhileHolding(sim, concessionsBeverage);
                //        concessionsBeverage.FadeIn(true);
                //        sim.Wander(ConcessionsStand.kMinMaxWanderBeforeDrink[0], ConcessionsStand.kMinMaxWanderBeforeDrink[1], false, RouteDistancePreference.NoPreference, false);
                //        result = concessionsBeverage.PushDrinkAsContinuation(sim);
                //    }
                //    else
                //    {
                //        concessionsBeverage.Destroy();
                //        result = false;
                //    }
                //}
                //break;
            }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public override bool RunMakeBehavior()
        {
            Recipe    recipe = Recipe.NameToRecipeHash["TrueBlood"];
            TrueBlood tb     = GlobalFunctions.CreateObjectOutOfWorld(recipe.ObjectToCreateInFridge, recipe.CodeVersion) as TrueBlood;

            tb.ParentToSlot(this.Actor, Sim.ContainmentSlots.RightHand);
            CarrySystem.EnterWhileHolding(this.Actor, tb);
            return(true);
        }
Ejemplo n.º 3
0
 public override void CleanupAfterExitReason()
 {
     if (this.Actor.IsHoldingAnything())
     {
         if (this.Actor.CarryStateMachine == null)
         {
             CarrySystem.EnterWhileHolding(this.Actor, this.Actor.GetObjectInRightHand() as ICarryable);
         }
         Food.PutHeldObjectDownOnCounterTableOrFloor(this.Actor, SurfaceType.Normal);
     }
     base.CleanupAfterExitReason();
 }
        public bool CreateFinalCookingObjectAndExit(TrueBlood trueBlood)
        {
            this.Target.SimStateMachineClient.SetActor((trueBlood as IMicrowavable).ActorNameForMicrowave, trueBlood);
            this.Target.SimStateMachineClient.RequestState("x", "Exit - " + "BowlLarge");
            CarrySystem.EnterWhileHolding(this.Actor, trueBlood as ICarryable);
            if (this.CheckForCancelAndCleanup())
            {
                return(false);
            }
            trueBlood.PushEatSnack(this.Actor);

            return(true);
        }
Ejemplo n.º 5
0
        public bool BuyAndEatConcessionsFood(Sim sim, bool autonomous)
        {
            bool result = true;

            //Find the counter the cash register is on
            bool    registerFound = false;
            int     cupLevel      = 1;
            Vector3 cupPosition   = sim.Position;

            if (base.Target.SimDescription.HasActiveRole && base.Target.SimDescription.AssignedRole != null && base.Target.SimDescription.AssignedRole.RoleGivingObject != null)
            {
                if (base.Target.SimDescription.AssignedRole.RoleGivingObject.Parent != null)
                {
                    registerFound = true;
                }
            }

            if (registerFound)
            {
                cupLevel    = base.Target.SimDescription.AssignedRole.RoleGivingObject.Level + 100;
                cupPosition = base.Target.SimDescription.AssignedRole.RoleGivingObject.Position;
            }

            HotBeverageMachine.Cup cup = GlobalFunctions.CreateObject("CoffeeCup", cupPosition, cupLevel, Vector3.UnitZ) as HotBeverageMachine.Cup;

            if (cup != null)
            {
                cup.Contents = new HotBeverageMachine.CustomDrinkRecipe();
                if (sim.ParentToRightHand(cup))
                {
                    CarrySystem.EnterWhileHolding(sim, cup);
                    cup.PushDrinkAsContinuation(sim);
                    cup.StartEffects();
                    result = true;
                }
                else
                {
                    cup.Destroy();
                    result = false;
                }
            }

            //HotBeverageMachine.Cup cup = GlobalFunctions.CreateObject("CoffeeCup", cupPosition, cupLevel, Vector3.UnitZ) as HotBeverageMachine.Cup;
            //cup.Contents = new HotBeverageMachine.CustomDrinkRecipe();
            //CarrySystem.PickUp(sim, cup);
            ////   CarrySystem.EnterWhileHolding(sim, cup);
            //cup.PushDrinkAsContinuation(sim);


            return(result);
        }
Ejemplo n.º 6
0
            public override bool Run()
            {
                Counter parent = base.Target.Parent as Counter;

                if (parent == null)
                {
                    return(false);
                }
                if (!SurfaceUtil.RouteToObjectOnSurface(parent, base.Actor, base.Target))
                {
                    return(false);
                }
                base.StandardEntry();
                HotBeverageMachine.Cup actor = GlobalFunctions.CreateObject("CoffeeCup", base.Target.Parent.Position, base.Target.Level, Vector3.UnitZ) as HotBeverageMachine.Cup;
                try
                {
                    actor.AddToUseList(base.Actor);
                    actor.Contents = (base.InteractionDefinition as Definition).Drink;
                    actor.SetHiddenFlags(HiddenFlags.Model);
                    HotBeverageMachine.EnterStateMachine(this);
                    base.SetActor("coffeeCup", actor);
                    base.BeginCommodityUpdates();
                    base.AnimateSim("Make One Drink");
                    base.EndCommodityUpdates(true);
                    CarrySystem.VerifyAnimationParent(actor, base.Actor);
                }
                finally
                {
                    actor.RemoveFromUseList(base.Actor);
                }

                //pay for drink
                CommonMethods.PayForCoffee(base.Actor, base.Target.LotCurrent);

                CarrySystem.EnterWhileHolding(base.Actor, actor);
                actor.PushDrinkAsContinuation(base.Actor);
                if (parent.IsCleanable)
                {
                    parent.Cleanable.DirtyInc(base.Actor);
                }
                base.mCurrentStateMachine.Dispose();
                actor.StartEffects();
                base.StandardExit();
                return(true);
            }
Ejemplo n.º 7
0
            public override bool Run()
            {
                Counter parent = base.Target.Parent as Counter;

                if (parent == null)
                {
                    return(false);
                }
                if (!SurfaceUtil.RouteToObjectOnSurface(parent, base.Actor, base.Target))
                {
                    return(false);
                }
                base.StandardEntry();

                this.Cup = this.MakeCup() as HotBeverageMachine.Cup;
                this.Cup.SetHiddenFlags(HiddenFlags.Model);

                this.BarTray = GlobalFunctions.CreateObject("barTray", (base.Target.Parent ?? base.Target).Position, base.Target.Level, Vector3.UnitZ) as BarTray;
                this.BarTray.SetHiddenFlags(HiddenFlags.Model);
                this.BarTray.AddInteraction(CallForCoffee.Singleton);

                base.Target.mLastCreatedTrayOfDrinksId = this.BarTray.ObjectId;
                HotBeverageMachine.EnterStateMachine(this);
                base.AddOneShotScriptEventHandler(100, new SacsEventHandler(this.FillTray));
                base.SetActor("coffeeCup", this.Cup);
                base.SetActor("barTray", this.BarTray);
                base.BeginCommodityUpdates();
                base.AnimateSim("Make Many Drinks");
                base.EndCommodityUpdates(true);
                base.StandardExit();
                CarrySystem.VerifyAnimationParent(this.BarTray, base.Actor);
                CarrySystem.EnterWhileHolding(base.Actor, this.BarTray);
                CarrySystem.PutDown(base.Actor, SurfaceType.Normal, true);
                //if ((!base.Autonomous || !base.Actor.HasBuffsToPreventSleepiness()) && CarrySystem.PickUp(base.Actor, this.Cup))
                //{
                //    this.Cup.PushDrinkAsContinuation(base.Actor);
                //}
                base.mCurrentStateMachine.Dispose();
                this.Cup.StartEffects();
                if (parent.IsCleanable)
                {
                    parent.Cleanable.DirtyInc(base.Actor);
                }
                return(true);
            }
Ejemplo n.º 8
0
        private bool StartCookingProcessWithFoodTray(string menuText, string[] menuPath, Recipe.MealDestination destination, Recipe.MealQuantity quantity, Recipe.MealRepetition repetition)
        {
            List <Ingredient> ingredientsUsed = new List <Ingredient>();

            if (!this.Actor.IsNPC && !AniRecipe.UseUpIngredientsFrom(this.ChosenRecipe, this.Actor, ref ingredientsUsed, quantity, false))
            {
                return(false);
            }
            this.Actor.SkillManager.AddElement(SkillNames.Cooking);
            FoodTray foodTray = (FoodTray)GlobalFunctions.CreateObject("FoodTray", Vector3.OutOfWorld, 0, Vector3.UnitZ);

            foodTray.CookingProcess = new CookingProcess(this.ChosenRecipe, ingredientsUsed, this.Target, this.Target.LotCurrent, destination, quantity, repetition, menuText, menuPath, foodTray, this.Actor);
            foodTray.CreateFoodProp(Slots.Hash("Slot_0"), foodTray.CookingProcess.Recipe.ModelsAndMaterials.GrillModel_FoodTray);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            StateMachineClient stateMachineClient = StateMachineClient.Acquire(this.Actor.Proxy.ObjectId, "Grill");

            if (stateMachineClient == null)
            {
                return(false);
            }
            stateMachineClient.AddInterest <TraitNames>(TraitNames.Clumsy);
            stateMachineClient.SetActor("x", this.Actor);
            stateMachineClient.SetActor("FoodTray", foodTray);
            stateMachineClient.EnterState("x", "Enter - Hands Empty");
            stateMachineClient.RequestState("x", "Take Out Food Tray");
            stateMachineClient.RequestState("x", "Exit - Holding Food Tray");
            if (this.Actor.HasExitReason(ExitReason.Canceled))
            {
                CarrySystem.EnterWhileHolding(this.Actor, foodTray);
                Food.PutHeldObjectDownOnCounterTableOrFloor(this.Actor, SurfaceType.Normal);
                return(false);
            }
            CarrySystem.EnterWhileHolding(this.Actor, foodTray);
            InteractionInstance instance = FoodTray_Prepare.Singleton.CreateInstance(foodTray, this.Actor, this.Actor.InheritedPriority(), base.Autonomous, true);

            return(this.Actor.InteractionQueue.PushAsContinuation(instance, true));
        }
Ejemplo n.º 9
0
        public override bool Run()
        {
            Definition interactionDefinition = base.InteractionDefinition as Definition;

            if (interactionDefinition == null)
            {
                return(false);
            }
            ObjectGuid mObject = interactionDefinition.mObject;
            int        mCost   = interactionDefinition.mCost;

            if (mObject == ObjectGuid.InvalidObjectGuid)
            {
                List <ObjectGuid> objectsICanBuyInDisplay = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
                if (!Autonomous && Actor.IsSelectable)
                {
                    List <ObjectPicker.RowInfo> list = new List <ObjectPicker.RowInfo>();
                    foreach (ObjectGuid current in objectsICanBuyInDisplay)
                    {
                        GameObject           obj  = GlobalFunctions.ConvertGuidToObject <GameObject>(current);
                        ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(current, new List <ObjectPicker.ColumnInfo>
                        {
                            new ObjectPicker.ThumbAndTextColumn(obj.GetThumbnailKey(), obj.GetLocalizedName()),
                            new ObjectPicker.MoneyColumn(DisplayHelper.ComputeFinalPriceOnObject(obj, true))
                        });
                        list.Add(item);
                    }
                    List <ObjectPicker.HeaderInfo> list2 = new List <ObjectPicker.HeaderInfo>();
                    List <ObjectPicker.TabInfo>    list3 = new List <ObjectPicker.TabInfo>();
                    list2.Add(new ObjectPicker.HeaderInfo(ShoppingRegister.sLocalizationKey + ":BuyFoodColumnName", ShoppingRegister.sLocalizationKey + ":BuyFoodColumnTooltip", 200));
                    list2.Add(new ObjectPicker.HeaderInfo("Ui/Caption/Shopping/Cart:Price", "Ui/Tooltip/Shopping/Cart:Price"));
                    list3.Add(new ObjectPicker.TabInfo("", ShoppingRegister.LocalizeString("AvailableFoods"), list));
                    List <ObjectPicker.RowInfo> list4 = SimplePurchaseDialog.Show(ShoppingRegister.LocalizeString("BuyFoodTitle"), Actor.FamilyFunds, list3, list2, true);
                    if (list4 == null || list4.Count != 1)
                    {
                        return(false);
                    }
                    mObject = (ObjectGuid)list4[0].Item;
                    mCost   = ((ObjectPicker.MoneyColumn)list4[0].ColumnInfo[1]).Value;
                }
                else
                {
                    RandomUtil.RandomizeListOfObjects <ObjectGuid>(objectsICanBuyInDisplay);
                    int familyFunds = base.Actor.FamilyFunds;
                    for (int i = 0; i < objectsICanBuyInDisplay.Count; i++)
                    {
                        int cost = DisplayHelper.ComputeFinalPriceOnObject(objectsICanBuyInDisplay[i]);
                        if (cost <= familyFunds)
                        {
                            //Definition continuationDefinition = new Definition(objectsICanBuyInDisplay[i], cost, false);
                            //base.TryPushAsContinuation(continuationDefinition);
                            //return true;
                            mObject = objectsICanBuyInDisplay[i];
                            mCost   = cost;
                            break;
                        }
                    }
                    //return false;
                }
            }
            if (mObject == ObjectGuid.InvalidObjectGuid)
            {
                return(false);
            }
            if (!base.Actor.RouteToObjectRadialRange(base.Target, 0f, base.Target.MaxProximityBeforeSwiping()))
            {
                return(false);
            }
            base.Actor.RouteTurnToFace(base.Target.Position);
            if (!DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target).Contains(mObject))
            {
                return(false);
            }
            if (base.Actor.FamilyFunds < mCost)
            {
                return(false);
            }
            GameObject target = GlobalFunctions.ConvertGuidToObject <GameObject>(mObject);

            if (target == null)
            {
                return(false);
            }

            base.StandardEntry();
            base.BeginCommodityUpdates();
            string swipeAnimationName = base.Target.GetSwipeAnimationName(target);

            if (Actor.SimDescription.Child)
            {
                swipeAnimationName = "c" + swipeAnimationName.Substring(1);
            }
            base.Actor.PlaySoloAnimation(swipeAnimationName, true);
            VisualEffect effect = VisualEffect.Create(base.Target.GetSwipeVfxName());
            Vector3      zero   = Vector3.Zero;
            Vector3      axis   = Vector3.Zero;

            if (Slots.AttachToBone(effect.ObjectId, base.Target.ObjectId, ResourceUtils.HashString32("transformBone"), false, ref zero, ref axis, 0f) == TransformParentingReturnCode.Success)
            {
                effect.SetAutoDestroy(true);
                effect.Start();
            }
            else
            {
                effect.Dispose();
                effect = null;
            }
            //bool flag = false;
            //bool flag2 = false;
            bool   succeeded       = false;
            bool   addInteractions = true;
            string tnsKey          = null;

            if (target.IsLiveDraggingEnabled() && !target.InUse && (interactionDefinition.mPushEat || (target.ItemComp != null && target.ItemComp.CanAddToInventory(base.Actor.Inventory) && base.Actor.Inventory.CanAdd(target)))) //&& base.Actor.Inventory.TryToAdd(target)))
            {
                ServingContainerGroup groupServing = null;
                if (interactionDefinition.mSingleServing)
                {
                    groupServing = target as ServingContainerGroup;
                    if (groupServing != null)
                    {
                        target          = groupServing.CookingProcess.CreateSingleServingOfFood(groupServing, true, true);
                        addInteractions = false;
                    }
                }
                if (interactionDefinition.mPushEat)
                {
                    target.SetOpacity(0f, 0f);
                    if (Actor.ParentToRightHand(target))
                    {
                        succeeded = true;
                        CarrySystem.EnterWhileHolding(Actor, target as ICarryable);
                    }
                    target.FadeIn();
                }
                else if (Actor.Inventory.TryToAdd(target))
                {
                    succeeded = true;
                    tnsKey    = "PlacedInPersonalInventory";
                }
                if (succeeded)
                {
                    if (groupServing != null)
                    {
                        groupServing.DecrementServings();
                        if (groupServing.NumServingsLeft == 0)
                        {
                            groupServing.FadeOut(false, true);
                        }
                    }
                }
                else if (groupServing != null && target != null)
                {
                    target.Destroy();
                }
            }
            else if (!target.InUse && base.Actor.Household.SharedFamilyInventory.Inventory.TryToAdd(target))
            {
                succeeded = true;
                tnsKey    = "PlacedInFamilyInventory";
            }
            //bool succeeded = flag || flag2;
            if (succeeded)
            {
                if (addInteractions)
                {
                    Target.OnHandToolChildUnslotted(target, Slot.None);
                    if (target is Snack)
                    {
                        target.AddInteraction(Sims3.Gameplay.Objects.CookingObjects.Eat.Singleton, true);
                        target.AddInteraction(Snack_CleanUp.Singleton, true);
                    }
                }

                /*if (flag2)
                 * {
                 *  base.Actor.ShowTNSIfSelectable(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "PlacedInFamilyInventory", new object[] { base.Actor, target }), StyledNotification.NotificationStyle.kGameMessagePositive);
                 * }
                 * else
                 * {
                 *  base.Actor.ShowTNSIfSelectable(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "PlacedInPersonalInventory", new object[] { base.Actor, target }), StyledNotification.NotificationStyle.kGameMessagePositive);
                 * }*/
                if (tnsKey != null)
                {
                    Actor.ShowTNSIfSelectable(CraftersConsignment.LocalizeString(Actor.IsFemale, tnsKey, new object[] { Actor, target }), StyledNotification.NotificationStyle.kGameMessagePositive);
                }
                base.Target.GiveMarkupBuffs(base.Actor, mObject);
                base.Actor.ModifyFunds(-mCost);
                base.Target.GiveLotOwnerMoney(mCost, base.Actor);
                base.Target.AccumulateRevenue(mCost);
                if (interactionDefinition.mPushEat)
                {
                    (target as IFoodContainer).PushEatHeldFoodInteraction(Actor);
                }
            }
            base.EndCommodityUpdates(succeeded);
            base.StandardExit();
            return(succeeded);
        }
Ejemplo n.º 10
0
        public override bool Run()
        {
            try
            {
                if (this.CheckForCancelAndCleanup())
                {
                    return(false);
                }
                if (!this.Target.RouteToOpen(this, true))
                {
                    return(false);
                }
                if (this.Target.InUse)
                {
                    this.Actor.AddExitReason(ExitReason.RouteFailed);
                    return(false);
                }
                this.mImpassableRegion.AddMember(this.Actor);
                this.mImpassableRegion.AddMember(this.Target);
                this.mImpassableRegion.UpdateFootprint();
                base.StandardEntry();
                if (this.Actor.SimDescription.TeenOrAbove && !this.ChosenRecipe.IsSnack)
                {
                    this.Actor.SkillManager.AddElement(SkillNames.Cooking);
                }
                bool flag = true;
                List <Ingredient> ingredientsUsed = new List <Ingredient>();

                if (AniRecipe.UseUpIngredientsFrom(this.ChosenRecipe, this.Actor, ref ingredientsUsed, this.Quantity, this.ChosenRecipe.IsSnack) || this.Actor.IsNPC)
                {
                    //If the food is a snack, remove ingredient
                    if (this.ChosenRecipe.IsSnack && !this.Actor.IsNPC)
                    {
                        Recipe snack = AniRecipe.ReturnSnackIngredientRecipe(this.Actor, this.ChosenRecipe);
                        if (snack != null)
                        {
                            //Create new temp ingredient list
                            foreach (var item in ingredientsUsed)
                            {
                                item.Destroy();
                            }
                            ingredientsUsed.Clear();
                        }
                    }

                    //CommonMethods.PrintMessage("Snack: " + this.ChosenRecipe.IsSnack + " / " + ingredientsUsed.Count.ToString());

                    Fridge.EnterStateMachine(this);
                    IRemovableFromFridgeAsInitialRecipeStep removableFromFridgeAsInitialRecipeStep = GlobalFunctions.CreateObjectOutOfWorld(this.ChosenRecipe.ObjectToCreateInFridge, this.ChosenRecipe.ModelCodeVersion) as IRemovableFromFridgeAsInitialRecipeStep;
                    GameObject gameObject = removableFromFridgeAsInitialRecipeStep as GameObject;
                    gameObject.AddToUseList(this.Actor);
                    try
                    {
                        this.Target.PutOnFridgeShelf(gameObject);
                        this.mThingToPrepareOrEat = (removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess);
                        this.mThingToPrepareOrEat.CookingProcess = new CookingProcess(this.ChosenRecipe, ingredientsUsed, this.ObjectClickedOn, this.Target.LotCurrent, this.Destination, this.Quantity, this.Repetition, this.MenuText, this.MenuPath, removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess, this.Actor);
                        removableFromFridgeAsInitialRecipeStep.InitializeForRecipe(this.ChosenRecipe, false);
                        CookingProcess.MoveToNextStep(removableFromFridgeAsInitialRecipeStep as IPartOfCookingProcess, this.Actor);
                        base.SetActor(removableFromFridgeAsInitialRecipeStep.ActorNameForFridge, gameObject);
                        if (this.mbWasHaveSomething)
                        {
                            base.AnimateSim("Ponder");
                        }
                        base.AnimateSim("Remove - " + removableFromFridgeAsInitialRecipeStep.ActorNameForFridge);
                        this.TriggerWatchCookingReactionBroadcaster();
                    }
                    catch (Exception ex)
                    {
                        if (ex == null)
                        {
                        }
                        gameObject.Destroy();
                        throw;
                    }
                    CarrySystem.EnterWhileHolding(this.Actor, removableFromFridgeAsInitialRecipeStep, false);
                    if (this.CheckForCancelAndCleanup())
                    {
                        return(false);
                    }
                    if (this.Actor.HasTrait(TraitNames.NaturalCook))
                    {
                        TraitTipsManager.ShowTraitTip(13271263770231522448uL, this.Actor, TraitTipsManager.TraitTipCounterIndex.NaturalCook, TraitTipsManager.kNaturalCookCountOfMealsCooked);
                    }
                    if (this.Actor.HasTrait(TraitNames.Vegetarian))
                    {
                        TraitTipsManager.ShowTraitTip(13271263770231522928uL, this.Actor, TraitTipsManager.TraitTipCounterIndex.Vegetarian, TraitTipsManager.kVegetarianCountOfMealsCooked);
                    }
                    this.PushNextInteraction(removableFromFridgeAsInitialRecipeStep, gameObject);
                    base.AnimateSim("Exit - Standing");
                }
                else
                {
                    flag = false;
                }

                base.StandardExit();
                if (flag)
                {
                    ActiveTopic.AddToSim(this.Actor, "Has Made Food");
                }
                return(flag);
            }
            catch (Exception ex)
            {
                CommonMethods.PrintMessage("Fridge: " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 11
0
        public override bool InRabbitHole()
        {
            string msg = "HaveAlienBabyHospital.InRabbitHole" + Common.NewLine;

            bool result;

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript) && !BabyShouldBeBorn)
                {
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    result = false;
                }
                else
                {
                    msg += "B";

                    AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy);

                    if (Actor.IsSelectable)
                    {
                        Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                    }

                    mNewborns = pregnancy.CreateNewborns(Pregnancy.HaveBabyHospital.kBonusMoodPointsForHospitalBirth, Actor.IsSelectable, false);

                    for (int i = 0; i < mNewborns.Count; i++)
                    {
                        Relationship.Get(Actor, mNewborns[i], true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    }

                    msg += "C";

                    Actor.SimDescription.SetPregnancy(0f);
                    List <Sim> followers = SimFollowers;
                    pregnancy.PregnancyComplete(mNewborns, followers);

                    msg += "D";

                    SpeedTrap.Sleep(0u);
                    List <Sim> list2 = new List <Sim>();
                    list2.Add(Actor);

                    if (followers != null)
                    {
                        foreach (Sim sim in followers)
                        {
                            if (sim.SimDescription.TeenOrAbove && sim.GetObjectInRightHand() == null)
                            {
                                list2.Add(sim);
                            }
                        }
                    }

                    msg += "E";

                    if (mNewborns.Count <= list2.Count)
                    {
                        for (int i = 0; i < mNewborns.Count; i++)
                        {
                            Sim     target  = list2[i];
                            Posture posture = target.Posture;
                            target.Posture = null;
                            Sim actor = mNewborns[i];
                            InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor,
                                                                                                                           new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                            actor.InteractionQueue.Add(entry);

                            while (actor.CurrentInteraction != entry && actor.InteractionQueue.HasInteraction(entry))
                            {
                                SpeedTrap.Sleep();
                            }

                            try
                            {
                                ChildUtils.CarryChild(target, actor, false);
                            }
                            catch (Exception e)
                            {
                                Common.Exception(actor, target, e);
                            }

                            target.Posture = posture;
                            AddFollower(mNewborns[i]);
                        }
                    }
                    else
                    {
                        BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0, Vector3.UnitZ) as BabyBasket;
                        basket.AddBabiesToBasket(mNewborns);
                        CarrySystem.EnterWhileHolding(Actor, basket);
                        CarrySystem.VerifyAnimationParent(basket, Actor);
                    }

                    msg += "F";

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                    }

                    result = true;
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                result = false;
            }

            Common.DebugNotify(msg);

            return(result);
        }
Ejemplo n.º 12
0
        public override bool InRabbitHole()
        {
            string msg = "HaveAlienBabyHosptial:InRabbitHole" + "\n";

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript))
                {
                    if (BabyShouldBeBorn)
                    {
                        break;
                    }
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    return(false);
                }

                msg += "B";

                Pregnancy pregnancy    = Actor.SimDescription.Pregnancy;
                bool      isSelectable = Actor.IsSelectable;
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                mNewborns = new PregnancyProxy(pregnancy).CreateNewborns(Pregnancy.HaveBabyHospital.kBonusMoodPointsForHospitalBirth, isSelectable, false);

                msg += "C";

                Actor.SimDescription.SetPregnancy(0f);
                List <Sim> simFollowers = SimFollowers;
                new PregnancyProxy(pregnancy).PregnancyComplete(mNewborns, simFollowers);

                /*
                 * if (mNewborns.Count == 4)
                 * {
                 *  Actor.BuffManager.RemoveElement(BuffNames.ItsABoy);
                 *  Actor.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);
                 * }
                 */

                msg += "D";

                Simulator.Sleep(0u);
                //SpeedTrap.Sleep(0x0);

                List <Sim> list2 = new List <Sim>();
                list2.Add(Actor);

                if (simFollowers != null)
                {
                    foreach (Sim sim in simFollowers)
                    {
                        if (sim.SimDescription.TeenOrAbove && sim.GetObjectInRightHand() == null)
                        {
                            list2.Add(sim);
                        }
                    }
                }

                msg += "E";

                if (mNewborns.Count <= list2.Count)
                {
                    for (int i = 0; i < mNewborns.Count; i++)
                    {
                        Sim     target  = list2[i];
                        Posture posture = target.Posture;
                        target.Posture = null;
                        Sim actor = mNewborns[i];
                        InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor,
                                                                                                                       new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                        actor.InteractionQueue.Add(entry);

                        while (actor.CurrentInteraction != entry && actor.InteractionQueue.HasInteraction(entry))
                        {
                            Simulator.Sleep(0u);
                            //SpeedTrap.Sleep();
                        }

                        try
                        {
                            ChildUtils.CarryChild(target, actor, false);
                        }
                        catch (Exception e)
                        {
                            Logger.WriteExceptionLog(e, this, "HaveAlienBabyHospital.Run() Error - CarryChild()");
                        }

                        target.Posture = posture;
                        AddFollower(mNewborns[i]);
                    }
                }
                else
                {
                    BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0, Vector3.UnitZ) as BabyBasket;
                    basket.AddBabiesToBasket(mNewborns);
                    CarrySystem.EnterWhileHolding(Actor, basket);
                    CarrySystem.VerifyAnimationParent(basket, Actor);
                }

                msg += "F";

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Logger.WriteExceptionLog(e, this, "HaveAlienBabyHospital.Run() Error");
                return(false);
            }
        }
Ejemplo n.º 13
0
        public override bool InRabbitHole()
        {
            string msg = "HaveBabyHospitalEx:InRabbitHole" + Common.NewLine;

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript))
                {
                    if (BabyShouldBeBorn && (((mDad == null) || !(mDad.CurrentInteraction is Pregnancy.GoToHospital)) || ((SimFollowers != null) && SimFollowers.Contains(mDad))))
                    {
                        break;
                    }
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    return(false);
                }

                msg += "B";

                Pregnancy pregnancy = Actor.SimDescription.Pregnancy;
                if (pregnancy != null)
                {
                    // Custom
                    HaveBabyHomeEx.EnsureForeignFather(pregnancy);
                }

                bool isSelectable = Actor.IsSelectable;
                //if (isSelectable)
                //{
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                //mNewborns = CreateNewborns(new HaveBabyHomeEx.PregnancyProxy(pregnancy), kBonusMoodPointsForHospitalBirth, isSelectable, false);
                mNewborns = new Proxies.PregnancyProxy(pregnancy).CreateNewborns(kBonusMoodPointsForHospitalBirth, isSelectable, false);
                // }
                // else
                // {
                //   try
                // {
                //   Simulator.YieldingDisabled = true;
                //mNewborns = CreateNewborns(new HaveBabyHomeEx.PregnancyProxy(pregnancy), kBonusMoodPointsForHospitalBirth, isSelectable, false); - was commented
                // mNewborns = new Proxies.PregnancyProxy(pregnancy).CreateNewborns(kBonusMoodPointsForHospitalBirth, isSelectable, false);
                // }
                //// finally
                // {
                //     Simulator.YieldingDisabled = false;
                // }
                // }

                msg += "C";

                Sim dad = Actor.SimDescription.Pregnancy.mDad;

                Actor.SimDescription.SetPregnancy(0f);
                List <Sim> simFollowers = SimFollowers;
                Actor.SimDescription.Pregnancy.PregnancyComplete(mNewborns, simFollowers);

                if (mNewborns.Count == 4)
                {
                    Actor.BuffManager.RemoveElement(BuffNames.ItsABoy);
                    Actor.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);

                    if (dad != null)
                    {
                        dad.BuffManager.RemoveElement(BuffNames.ItsABoy);
                        dad.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);
                    }
                }

                msg += "D";

                SpeedTrap.Sleep(0x0);

                List <Sim> list2 = new List <Sim>();
                list2.Add(Actor);

                if (simFollowers != null)
                {
                    foreach (Sim sim in simFollowers)
                    {
                        if (sim.SimDescription.TeenOrAbove && (sim.GetObjectInRightHand() == null))
                        {
                            list2.Add(sim);
                        }
                    }
                }

                msg += "E";

                if (mNewborns.Count <= list2.Count)
                {
                    for (int i = 0x0; i < mNewborns.Count; i++)
                    {
                        Sim     target  = list2[i];
                        Posture posture = target.Posture;
                        target.Posture = null;
                        Sim actor = mNewborns[i];
                        InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor, new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                        actor.InteractionQueue.Add(entry);

                        while ((actor.CurrentInteraction != entry) && actor.InteractionQueue.HasInteraction(entry))
                        {
                            SpeedTrap.Sleep();
                        }

                        try
                        {
                            ChildUtils.CarryChild(target, actor, false);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(actor, target, e);
                        }

                        target.Posture = posture;
                        AddFollower(mNewborns[i]);
                    }
                }
                else
                {
                    BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0x0, Vector3.UnitZ) as BabyBasket;
                    basket.AddBabiesToBasket(mNewborns);
                    CarrySystem.EnterWhileHolding(Actor, basket);
                    CarrySystem.VerifyAnimationParent(basket, Actor);
                }

                msg += "F";

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                return(false);
            }
        }
Ejemplo n.º 14
0
        public override bool Run()
        {
            try
            {
                BuffInstance element = Actor.BuffManager.GetElement(BuffNames.ReallyHasToPee);
                if ((element != null) && (element.mTimeoutCount <= Urinal.kTimeoutRemainingForBladderEmergency))
                {
                    RequestWalkStyle(Sim.WalkStyle.Run);
                }
                if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.DefaultAllowSubstitution, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), Urinal.kTimeToWaitInLine))
                {
                    return(false);
                }
                if (!Target.RouteToUrinalAndCheckInUse(Actor))
                {
                    return(false);
                }
                ClearRequestedWalkStyles();

                if (Shooless.Settings.GetPrivacy(Target))
                {
                    mSituation = Urinal.UrinalSituation.Create(Actor, Actor.LotCurrent);
                }

                if (mSituation != null)
                {
                    if (!mSituation.Start())
                    {
                        return(false);
                    }
                    if (!Target.RouteToUrinalAndCheckInUse(Actor))
                    {
                        return(false);
                    }
                }
                CancellableByPlayer = false;
                StandardEntry();
                mCurrentStateMachine = Target.GetStateMachine(Actor);
                Glass.CarryingGlassPosture posture = Actor.Posture as Glass.CarryingGlassPosture;
                if (posture != null)
                {
                    mDrinkInHand = posture.ObjectBeingCarried as Glass;
                    CarrySystem.ExitCarry(Actor);
                    mDrinkInHand.FadeOut(true);
                    mDrinkInHand.UnParent();
                    Actor.PopPosture();
                    SetParameter("hasDrink", true);
                    SetActor("drink", mDrinkInHand);
                    if (Target.HasDrinkSlot && (Target.GetContainedObject(Slot.ContainmentSlot_0) == null))
                    {
                        mDrinkInHand.ParentToSlot(Target, Slot.ContainmentSlot_0);
                        mDrinkInHand.FadeIn();
                    }
                }
                mCensorEnabled = true;
                Actor.EnableCensor(Sim.CensorType.LowerBody);
                AddOneShotScriptEventHandler(0x78, OnAnimationEvent);
                AnimateSim("use");
                if (element != null)
                {
                    element.mTimeoutPaused = true;
                }
                if (Actor.HasTrait(TraitNames.Inappropriate))
                {
                    mWillFart = RandomUtil.RandomChance01(Urinal.kChanceInappropriateFart);
                    if (mWillFart)
                    {
                        mFartTime = RandomUtil.RandomFloatGaussianDistribution(0.1f, 0.9f);
                    }
                }
                BeginCommodityUpdate(CommodityKind.Bladder, 0f);
                BeginCommodityUpdates();
                bool succeeded = false;

                try
                {
                    Actor.Motives.LerpToFill(this, CommodityKind.Bladder, Urinal.kMaxLengthUseToilet);
                    StartStages();

                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.BuffFailureState | ExitReason.MaxSkillPointsReached | ExitReason.HigherPriorityNext), new Interaction <Sim, Urinal> .InsideLoopFunction(LoopFunc), mCurrentStateMachine);
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                if (succeeded)
                {
                    Motive motive = Actor.Motives.GetMotive(CommodityKind.Bladder);
                    if (motive != null)
                    {
                        motive.PotionBladderDecayOverride = false;
                    }
                }

                if (element != null)
                {
                    element.mTimeoutPaused = false;
                }

                if (Target.IsCleanable)
                {
                    Target.Cleanable.DirtyInc(Actor);
                }

                bool flag2 = Target.Line.MemberCount() > 0x1;
                InteractionInstance instance = null;
                if ((mSituation == null) || !mSituation.SomeoneDidIntrude)
                {
                    if (Target.AutoFlushes)
                    {
                        Target.FlushToilet(Actor, mCurrentStateMachine, false);
                    }
                    else
                    {
                        Target.ToiletVolume++;
                        if (Target.ShouldFlush(Actor, Autonomous))
                        {
                            Target.FlushToilet(Actor, mCurrentStateMachine, true);
                        }
                    }
                    if (((mDrinkInHand == null) && Urinal.ShouldWashHands(Actor)) && !flag2)
                    {
                        Sink target = Toilet.FindClosestSink(Actor);
                        if (target != null)
                        {
                            instance = Sink.WashHands.Singleton.CreateInstance(target, Actor, GetPriority(), false, true);
                        }
                    }
                }
                AddOneShotScriptEventHandler(0x68, OnAnimationEvent);
                AddOneShotScriptEventHandler(0x64, OnAnimationEvent);
                AnimateSim("exit");
                if (mSituation != null)
                {
                    mSituation.ExitUrinalSituation();
                }
                if (mDrinkInHand != null)
                {
                    CarrySystem.EnterWhileHolding(Actor, mDrinkInHand);
                    Actor.Posture = new Glass.CarryingGlassPosture(Actor, mDrinkInHand);
                    mDrinkInHand.FadeIn();
                }
                if (flag2)
                {
                    PrivacySituation.RouteToAdjacentRoom(Actor);
                }
                StandardExit();
                if (instance != null)
                {
                    Actor.InteractionQueue.PushAsContinuation(instance, true);
                }
                if (!flag2 && (instance == null))
                {
                    Actor.RouteAway(Urinal.kMinDistanceToMoveAwayAfterUsingUrinal, Urinal.kMaxDistanceToMoveAwayAfterUsingUrinal, false, GetPriority(), true, true, true, RouteDistancePreference.NoPreference);
                }
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
        public override bool Run()
        {
            if (this.CheckForCancelAndCleanup())
            {
                return(false);
            }
            if (!Target.RouteToOpen(this, true))
            {
                return(false);
            }
            if (Target.InUse)
            {
                this.Actor.AddExitReason(ExitReason.RouteFailed);
                return(false);
            }
            this.mImpassableRegion.AddMember(this.Actor);
            this.mImpassableRegion.AddMember(this.Target);
            this.mImpassableRegion.UpdateFootprint();
            base.StandardEntry();

            bool flag = true;
            List <Ingredient> ingredientsUsed = new List <Ingredient>();

            if (this.ChosenRecipe.UseUpIngredientsFrom(this.Actor, ref ingredientsUsed, Recipe.MealQuantity.Single) || this.Actor.IsNPC)
            {
                Fridge.EnterStateMachine(this);
                TrueBlood  trueBlood  = GlobalFunctions.CreateObjectOutOfWorld(this.ChosenRecipe.ObjectToCreateInFridge, this.ChosenRecipe.CodeVersion) as TrueBlood;
                GameObject gameObject = trueBlood as GameObject;
                gameObject.AddToUseList(this.Actor);
                try
                {
                    this.Target.PutOnFridgeShelf(gameObject);
                    trueBlood.InitializeForRecipe(this.ChosenRecipe);
                    Recipe.MealDestination destination = Recipe.MealDestination.SurfaceOrEat;
                    CookingProcess         process     = new CookingProcess(ChosenRecipe, new List <Ingredient>(), Target, Actor.LotCurrent, destination,
                                                                            Recipe.MealQuantity.Single, Recipe.MealRepetition.MakeOne, "Tru Blood", new String[] { }, trueBlood, Actor, false);
                    trueBlood.CookingProcess = process;
                    CookingProcess.MoveToNextStep(trueBlood, Actor);
                    base.SetActor(trueBlood.ActorNameForFridge, gameObject);

                    base.AnimateSim("Remove - " + trueBlood.ActorNameForFridge);
                }
                catch
                {
                    gameObject.Destroy();
                    throw;
                }
                CarrySystem.EnterWhileHolding(this.Actor, trueBlood, false);
                if (this.CheckForCancelAndCleanup())
                {
                    return(false);
                }
                if (this.Actor.HasTrait(TraitNames.NaturalCook))
                {
                    TraitTipsManager.ShowTraitTip(13271263770231522448uL, this.Actor, TraitTipsManager.TraitTipCounterIndex.NaturalCook, TraitTipsManager.kNaturalCookCountOfMealsCooked);
                }

                InteractionDefinition warmUp = PutBloodToMicrowave.Singleton;
                Actor.InteractionQueue.PushAsContinuation(warmUp, gameObject, true);
                base.AnimateSim("Exit - Standing");
            }
            else
            {
                flag = false;
            }
            base.StandardExit();
            if (flag)
            {
                ActiveTopic.AddToSim(this.Actor, "Has Made Food");
            }
            return(flag);
        }