Esempio n. 1
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            //if (!UIUtils.IsOkayToStartModalDialog()) return false;

            bool hasExclusiveAccess;
            Lot  partyVenue = GetVenue(parameters.mActor, out hasExclusiveAccess);

            float            num2;
            OutfitCategories formalwear;

            Sims3.Gameplay.Situations.Party party = null;
            bool isPartyAtHome = (partyVenue == parameters.mActor.LotHome);

            if (partyVenue == null)
            {
                return(OptionResult.Failure);
            }
            if (!parameters.mActor.IsSelectable)
            {
                return(OptionResult.Failure);
            }

            PartyPickerDialog.PartyType partyTypes = PartyPickerDialog.PartyType.kAll;

            // Keep as GameUtils
            if (GameUtils.IsOnVacation())
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kBirthday;
            }

            if (partyVenue.LastDiedSim == null)
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kFuneral;
            }

            Sim actorSim = parameters.mActor as Sim;

            Political job = actorSim.Occupation as Political;

            if ((job == null) || (!job.HasCampaignMoneyMetric()))
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kCampaign;
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kWedding;

            foreach (Sim sim in CommonSpace.Helpers.Households.AllSims(parameters.mActor.Household))
            {
                if (sim.IsEngaged)
                {
                    partyTypes |= PartyPickerDialog.PartyType.kWedding;
                    break;
                }
            }

            if (!GameUtils.IsInstalled(ProductVersion.EP4))
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kBachelorParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
            }
            else
            {
                if (isPartyAtHome)
                {
                    if (!actorSim.SimDescription.Child)
                    {
                        partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                    }

                    if (!actorSim.SimDescription.Teen)
                    {
                        partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                        partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
                    }
                }
                else
                {
                    partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                    partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                    partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
                }
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kPoolParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kFeastParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kCostumeParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kGiftGivingParty;
            if (GameUtils.IsInstalled(ProductVersion.EP8) /*&& isPartyAtHome*/)
            {
                partyTypes |= PartyPickerDialog.PartyType.kFeastParty;
                partyTypes |= PartyPickerDialog.PartyType.kCostumeParty;
                partyTypes |= PartyPickerDialog.PartyType.kGiftGivingParty;
                //if (PoolParty.CanSimThrowPoolParty(actorSim))
                if (partyVenue.GetSwimmingPoolCount() > 0)
                {
                    partyTypes |= PartyPickerDialog.PartyType.kPoolParty;
                }
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kJuiceKeggerParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kBonfire;
            partyTypes &= ~PartyPickerDialog.PartyType.kTailgatingParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kVideoGameLANParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kMasqueradeBall;
            partyTypes &= ~PartyPickerDialog.PartyType.kVictoryParty;

            if (GameUtils.IsInstalled(ProductVersion.EP9))
            {
                partyTypes |= PartyPickerDialog.PartyType.kTailgatingParty;
                partyTypes |= PartyPickerDialog.PartyType.kVideoGameLANParty;
                partyTypes |= PartyPickerDialog.PartyType.kMasqueradeBall;
                partyTypes |= PartyPickerDialog.PartyType.kVictoryParty;

                if (JuiceKeggerParty.CanSimThrowJuiceKeggerParty(actorSim))
                {
                    partyTypes |= PartyPickerDialog.PartyType.kJuiceKeggerParty;
                }

                if (BonfireParty.CanSimThrowBonfire(actorSim))
                {
                    partyTypes |= PartyPickerDialog.PartyType.kBonfire;
                }
            }

            bool         criteriaCanceled;
            SimSelection list = SimSelection.Create(Common.Localize("Party:SelectTitle"), actorSim.SimDescription, this, GetCriteria(parameters), false, false, out criteriaCanceled);

            if (list.IsEmpty)
            {
                SimpleMessageDialog.Show(Common.LocalizeEAString("Gameplay/Objects/Electronics/Phone/CallThrowParty:NoSimsWT"), Common.LocalizeEAString(parameters.mActor.IsFemale, "Gameplay/Objects/Electronics/Phone/CallThrowParty:NoSims", new object[] { parameters.mActor }), ModalDialog.PauseMode.PauseSimulator);
                return(OptionResult.Failure);
            }

            float openHour    = -1f;
            float closingHour = -1f;

            PartyPickerDialog.PartyInfo info = PartyPickerDialogEx.Show(partyTypes, list.GetPickerInfo(), parameters.mActor.GetThumbnailKey(), isPartyAtHome, 25, -1, openHour, closingHour, PartyPickerDialog.ClothingType.kNone, actorSim.IsFemale);
            if ((info == null) || (info.PartyType == PartyPickerDialog.PartyType.kNone))
            {
                return(OptionResult.Failure);
            }

            float hoursPassedOfDay = SimClock.HoursPassedOfDay;

            if (hoursPassedOfDay > info.Time)
            {
                num2 = 24f - (hoursPassedOfDay - info.Time);
            }
            else
            {
                num2 = info.Time - hoursPassedOfDay;
            }
            if (num2 < 1f)
            {
                num2 += 24f;
            }
            long        ticks            = SimClock.ConvertToTicks(num2, TimeUnit.Hours);
            DateAndTime startTime        = SimClock.CurrentTime() + new DateAndTime(ticks);
            bool        bHostIsLegendary = actorSim.HasTrait(TraitNames.LegendaryHost);
            float       fMaxLTR          = 0f;
            LTRData     data             = LTRData.Get(LongTermRelationshipTypes.Friend);

            if (data != null)
            {
                fMaxLTR = data.Liking - 1;
            }
            List <SimDescription> simList = new List <SimDescription>();

            foreach (object obj2 in info.SimList)
            {
                SimDescription simDescription = obj2 as SimDescription;
                if ((simDescription != null) && CanSimBeInvitedToParty(simDescription, partyVenue, actorSim, fMaxLTR, bHostIsLegendary, true))
                {
                    if (!simList.Contains(simDescription))
                    {
                        simList.Add(simDescription);
                        if (simDescription.TraitManager.HasElement(TraitNames.PartyAnimal))
                        {
                            Sim createdSim = simDescription.CreatedSim;
                            if (createdSim != null)
                            {
                                TraitTipsManager.ShowTraitTip(13271263770231522640L, createdSim, TraitTipsManager.TraitTipCounterIndex.PartyAnimal, TraitTipsManager.kPartyAnimalCountOfParties);
                            }
                        }
                        if (simDescription.IsCelebrity)
                        {
                            EventTracker.SendEvent(EventTypeId.kPartyInviteCeleb, parameters.mActor);
                        }
                    }

                    bool bShouldMatchAge = (simDescription.Age == actorSim.SimDescription.Age) && ((simDescription.Teen) || (simDescription.Child));
                    if (!hasExclusiveAccess && RandomUtil.RandomChance(HouseParty.HousePartyParams.PercentageChanceOfBringingAFriend))
                    {
                        SimDescription friend = SocialComponent.FindFriendNotInList(simDescription, simList, parameters.mActor.LotHome, bShouldMatchAge);
                        if ((friend != null) && CanSimBeInvitedToParty(friend, partyVenue, null, 0f, false, false))
                        {
                            simList.Add(friend);
                        }
                    }
                }
            }

            DateAndTime time = startTime;

            time.Ticks -= SimClock.ConvertToTicks(Sims3.Gameplay.Situations.Party.HoursToStartRentBeforePartyStart, TimeUnit.Hours);
            if (time.CompareTo(SimClock.CurrentTime()) < 0)
            {
                time = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Minutes, 2f);
            }

            if ((partyVenue != parameters.mActor.LotHome) && !RentScheduler.Instance.RentLot(partyVenue, actorSim, time, simList, hasExclusiveAccess))
            {
                SimpleMessageDialog.Show(string.Empty, Phone.Call.LocalizeCallString("ThrowParty", "CantRent", new object[] { parameters.mActor }), ModalDialog.PauseMode.PauseSimulator);
                return(OptionResult.Failure);
            }

            switch (info.ClothingType)
            {
            case PartyPickerDialog.ClothingType.kFormal:
                formalwear = OutfitCategories.Formalwear;
                break;

            case PartyPickerDialog.ClothingType.kCasual:
                formalwear = OutfitCategories.Everyday;
                break;

            case PartyPickerDialog.ClothingType.kSwimwear:
                formalwear = OutfitCategories.Swimwear;
                break;

            case PartyPickerDialog.ClothingType.kCostumes:
                formalwear = OutfitCategories.Everyday;
                break;

            default:
                formalwear = OutfitCategories.Everyday;
                break;
            }

            float infoTime = info.Time;

            switch (info.PartyType)
            {
            case PartyPickerDialog.PartyType.kCampaign:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FundraiserTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FundraiserStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new CampaignFundraiser(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewFundraiser, parameters.mActor);
                break;

            case PartyPickerDialog.PartyType.kBirthday:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BirthdayTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BirthdayStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BirthdayParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kWedding:
                string messageText = string.Empty;
                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    messageText = Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingStartWithArch", new object[] { infoTime });
                }
                else
                {
                    messageText = Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingStart", new object[] { infoTime });
                }

                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingTitle"), messageText, ModalDialog.PauseMode.PauseSimulator);

                EnsureFianceeIsInvitedToWeddingParty(actorSim, simList);

                party = new WeddingParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kFuneral:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FuneralTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FuneralStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new Funeral(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kBachelorParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BachelorPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BachelorStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BachelorParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewBachelorParty, actorSim);
                actorSim.SimDescription.SetHadBachelorParty();
                break;

            case PartyPickerDialog.PartyType.kTeenParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:TeenPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:TeenStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new TeenParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kChildSlumberParty:
            case PartyPickerDialog.PartyType.kTeenSlumberParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:SlumberPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:SlumberStart", new object[] { infoTime, actorSim }), ModalDialog.PauseMode.PauseSimulator);
                party = new SlumberParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kCostumeParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:CostumePartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:CostumePartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new CostumeParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kCostumePartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kGiftGivingParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:GiftGivingPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:GiftGivingPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new GiftGivingParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kGiftGivingPartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kPoolParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:PoolPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:PoolPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new PoolParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kSchedulePoolParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kFeastParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:FeastPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:FeastPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new FeastParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kFeastPartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kJuiceKeggerParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:JuiceKeggerPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:JuiceKeggerStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new JuiceKeggerParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewJuiceKeggerParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kTailgatingParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:TailgatingPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:TailgatingStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new TailgatingParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewTailgatingParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kBonfire:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:BonfireTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:BonfireStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BonfireParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewBonfireParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kVideoGameLANParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VideoGameLANPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VideoGameLANStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new VideoGameLANParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewVideoGameLANParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kMasqueradeBall:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:MasqueradeBallTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:MasqueradeStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new MasqueradeBall(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewMasqueradeBall, actorSim);
                break;

            case PartyPickerDialog.PartyType.kVictoryParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VictoryPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VictoryStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new VictoryParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewVictoryParty, actorSim);
                break;

            default:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:GenericTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:HouseStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new HouseParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;
            }

            if (party == null)
            {
                return(OptionResult.Failure);
            }

            foreach (SimDescription sim in party.GuestDescriptions)
            {
                Instantiation.EnsureInstantiate(sim, party.Lot);
            }

            EventTracker.SendEvent(new PartyEvent(EventTypeId.kThrewParty, actorSim, actorSim.SimDescription, party));
            if (actorSim.HasTrait(TraitNames.PartyAnimal))
            {
                TraitTipsManager.ShowTraitTip(13271263770231522640L, actorSim, TraitTipsManager.TraitTipCounterIndex.PartyAnimal, TraitTipsManager.kPartyAnimalCountOfParties);
            }
            return(OptionResult.SuccessClose);
        }
Esempio n. 2
0
 public override bool Run()
 {
     try{
         if (!Target.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.DefaultEvict,
                                         ~(ExitReason.Replan |
                                           ExitReason.MidRoutePushRequested |
                                           ExitReason.ObjectStateChanged |
                                           ExitReason.PlayIdle |
                                           ExitReason.MaxSkillPointsReached), Shower.kTimeToWaitToEvict))
         {
             return(false);
         }
         try{
             mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, Sim.ClothesChangeReason.GoingToBathe);
         }catch {
             return(false);
         }
         mSwitchOutfitHelper.Start();
         if (Actor.HasTrait(TraitNames.Hydrophobic))
         {
             Actor.PlayReaction(ReactionTypes.WhyMe, Target as GameObject, ReactionSpeed.ImmediateWithoutOverlay);
         }
         if (Actor.HasTrait(TraitNames.Daredevil))
         {
             TraitTipsManager.ShowTraitTip(0xb82d0015b9294260L, Actor, TraitTipsManager.TraitTipCounterIndex.Daredevil, TraitTipsManager.kDaredevilCountOfShowersTaken);
         }
         if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
         {
             return(false);
         }
         //    mSituation=new Shower.ShowerPrivacySituation(this);
         //if(!mSituation.Start()){
         //        return(false);
         //}
         StandardEntry();
         if (!Actor.RouteToSlot(Target, Slot.RoutingSlot_0))
         {
             if (mSituation != null)
             {
                 mSituation.Exit();
             }
             StandardExit();
             return(false);
         }
         if (Autonomous)
         {
             mPriority = new InteractionPriority(InteractionPriorityLevel.UserDirected);
         }
         mSwitchOutfitHelper.Wait(true);
         bool daredevilPerforming =
             Actor.DaredevilPerforming;
         bool flag2 = Actor.GetCurrentOutfitCategoryFromOutfitInGameObject() == OutfitCategories.Singed;
         EnterStateMachine("Shower", "Enter", "x");
         SetActor("Shower", Target);
         if (mSituation != null)
         {
             mSituation.StateMachine = mCurrentStateMachine;
         }
         SetParameter("IsShowerTub", Target.IsShowerTub);
         SetParameter("SimShouldCloseDoor", true);
         SetParameter("SimShouldClothesChange", ((!daredevilPerforming && !flag2) && !Actor.OccultManager.DisallowClothesChange()) && !Actor.BuffManager.DisallowClothesChange());
         bool paramValue = false;
         if ((Target.BoobyTrapComponent != null) && Target.BoobyTrapComponent.CanTriggerTrap(Actor.SimDescription))
         {
             paramValue = !Actor.OccultManager.DisallowClothesChange() && !Actor.BuffManager.DisallowClothesChange();
         }
         SimDescription description = ((Target.BoobyTrapComponent != null) && (Target.BoobyTrapComponent.TrapSetter != 0L)) ? SimDescription.Find(Target.BoobyTrapComponent.TrapSetter) : null;
         if (((description != null) && description.IsFairy) && Actor.BuffManager.HasElement(BuffNames.TrickedByAFairy))
         {
             paramValue = false;
         }
         SetParameter("isBoobyTrapped", paramValue);
         mSwitchOutfitHelper.AddScriptEventHandler(this);
         AddOneShotScriptEventHandler(0x3e9, EventCallbackStartShoweringSound);
         if (Actor.HasTrait(TraitNames.Virtuoso) || RandomUtil.RandomChance((float)Target.TuningShower.ChanceOfSinging))
         {
             AddOneShotScriptEventHandler(0xc8, EventCallbackStartSinging);
         }
         PetStartleBehavior.CheckForStartle(Target as GameObject, StartleType.ShowerOn);
         AnimateSim("Loop Shower");
         Actor.BuffManager.AddElement(BuffNames.SavingWater, Origin.FromShower, ProductVersion.EP2, TraitNames.EnvironmentallyConscious);
         mShowerStage.ResetCompletionTime(GetShowerTime());
         StartStages();
         if (Actor.HasTrait(TraitNames.EnvironmentallyConscious))
         {
             BeginCommodityUpdate(CommodityKind.Hygiene, Shower.kEnvironmentallyConsciousShowerSpeedMultiplier);
         }
         if (Actor.SimDescription.IsPlantSim)
         {
             ModifyCommodityUpdate(CommodityKind.Hygiene, Shower.kPlantSimHygieneModifier);
         }
         BeginCommodityUpdates();
         if (paramValue)
         {
             ApplyBoobyTrapOutfit();
             if ((description != null) && description.IsFairy)
             {
                 Actor.BuffManager.AddElement(BuffNames.TrickedByAFairy, Origin.FromFairy);
             }
         }
         bool succeeded = (false);
         try{
             try{
                 Target.SimInShower = Actor;
                 succeeded          = DoLoop(~(
                                                 ExitReason.Replan |
                                                 ExitReason.MidRoutePushRequested |
                                                 ExitReason.ObjectStateChanged |
                                                 ExitReason.PlayIdle |
                                                 ExitReason.MaxSkillPointsReached), DuringShower, null);
                 if (HavingWooHoo && Actor.HasExitReason(ExitReason.StageComplete))
                 {
                     succeeded = DoLoop(~(
                                            ExitReason.Replan |
                                            ExitReason.MidRoutePushRequested |
                                            ExitReason.ObjectStateChanged |
                                            ExitReason.PlayIdle |
                                            ExitReason.MaxSkillPointsReached |
                                            ExitReason.StageComplete), DuringShower, null);
                 }
             }finally{
                 Target.SimInShower = null;
             }
             while (HavingWooHoo)
             {
                 SpeedTrap.Sleep(10);
             }
         }finally{
             EndCommodityUpdates(succeeded);
         }
         Shower.WaitToLeaveShower(Actor, Target);
         if (succeeded)
         {
             Shower.ApplyPostShowerEffects(Actor, Target);
         }
         if (paramValue)
         {
             SetParameter("isBoobyTrapped", false);
             AddOneShotScriptEventHandler(0xc9, EventCallbackStopSinging);
             AddOneShotScriptEventHandler(0x3ea, EventCallbackStopShoweringSound);
             if ((description != null) && description.IsFairy)
             {
                 AnimateSim("TriggerFairyTrap");
             }
             else
             {
                 AnimateSim("Booby Trap Reaction");
             }
             AddOneShotScriptEventHandler(0x3e9, EventCallbackStartShoweringSound);
             AnimateSim("Loop Shower");
             RemoveBoobyTrapOutfit();
             SpeedTrap.Sleep(60);
         }
         try{
             if (flag2 && succeeded)
             {
                 mSwitchOutfitHelper.Dispose();
                 try{
                     mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, Sim.ClothesChangeReason.GoingToBathe);
                     mSwitchOutfitHelper.Start();
                     mSwitchOutfitHelper.Wait(false);
                     mSwitchOutfitHelper.ChangeOutfit();
                 }catch {}
             }
             bool flag5 = (false);
             if ((flag2 && succeeded) || (!flag2 && !daredevilPerforming))
             {
                 SetParameter("SimShouldClothesChange", !Actor.OccultManager.DisallowClothesChange());
                 mSwitchOutfitHelper.Dispose();
                 try{
                     mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, GetOutfitReason(Actor));
                     mSwitchOutfitHelper.Start();
                     mSwitchOutfitHelper.AddScriptEventHandler(this);
                     mSwitchOutfitHelper.Wait(false);
                 }catch {}
                 flag5 = (true);
             }
             Target.Cleanable.DirtyInc(Actor);
             AddOneShotScriptEventHandler(0xc9, EventCallbackStopSinging);
             AddOneShotScriptEventHandler(0x3ea, EventCallbackStopShoweringSound);
             if (flag5 && InventingSkill.IsBeingDetonated(Target as GameObject))
             {
                 SetParameter("SimShouldClothesChange", false);
                 mSwitchOutfitHelper.Abort();
                 mSwitchOutfitHelper.Dispose();
             }
             if (Target.Repairable.UpdateBreakage(Actor))
             {
                 Target.StartBrokenFXInAnim(mCurrentStateMachine);
                 AnimateSim("Exit Broken");
             }
             else
             {
                 AnimateSim("Exit Working");
             }
             if ((Actor.SimDescription.IsMummy || Actor.DaredevilPerforming) || (Actor.TraitManager.HasElement(TraitNames.Slob) && RandomUtil.RandomChance01(TraitTuning.SlobTraitChanceToLeavePuddle)))
             {
                 PuddleManager.AddPuddle(Actor.Position);
             }
             if (succeeded)
             {
                 Actor.BuffManager.RemoveElement(BuffNames.GotFleasHuman);
             }
         }finally{
             StandardExit();
         }
         return(succeeded);
     }catch (ResetException exception) {
         Alive.WriteLog(exception.Message + "\n\n" +
                        exception.StackTrace + "\n\n" +
                        exception.Source);
         return(false);
     }catch (Exception exception) {
         Alive.WriteLog(exception.Message + "\n\n" +
                        exception.StackTrace + "\n\n" +
                        exception.Source);
         return(false);
     }
 }
Esempio n. 3
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);
            }
        }
        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);
        }