public static Courtesan clone(Role toClone, SimDescription actor)
        {
            Courtesan newRole = new Courtesan(toClone.Data, actor, toClone.RoleGivingObject);
            newRole.StartRole();

            return newRole;
        }
Example #2
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (me.CreatedSim != null)
            {
                bool reset = false;
                if (me.CreatedSim.Motives == null)
                {
                    reset = true;
                }
                else
                {
                    foreach (KeyValuePair<int, Motive> motive in me.CreatedSim.Motives.mMotives)
                    {
                        if ((motive.Value == null) || (motive.Value.Tuning == null))
                        {
                            reset = true;
                            break;
                        }
                    }
                }

                if (reset)
                {
                    me.CreatedSim.mAutonomy.RecreateAllMotives();
                }

                foreach (CommodityKind kind in sCommodities)
                {
                    ForceSetMax(me.CreatedSim.Motives, kind);
                }
            }
            return true;
        }
Example #3
0
        public bool Satisfies(ManagerCareer manager, SimDescription sim, Lot newLot, bool inspecting)
        {
            if (!inspecting)
            {
                Occupation career = CareerManager.GetStaticOccupation(mCareer);
                if (career == null) return false;

                if ((GameUtils.IsFutureWorld()) && (!career.AvailableInFutureWorld)) return false;

                if (sim.IsEP11Bot)
                {
                    if (!sim.HasTrait(TraitNames.ProfessionalChip))
                    {
                        return false;
                    }
                }

                if (sim.CreatedSim != null)
                {
                    if ((sim.Occupation == null) || (sim.Occupation.Guid != mCareer))
                    {
                        GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                        if (!career.CanAcceptCareer(sim.CreatedSim.ObjectId, ref greyedOutTooltipCallback)) return false;
                    }
                }
            }

            return PrivateSatisfies(manager, sim, newLot, inspecting);
        }
Example #4
0
 protected KillScenario(KillScenario scenario)
     : base (scenario)
 {
     mKiller = scenario.mKiller;
     mDeathType = scenario.mDeathType;
     mStoryName = scenario.mStoryName;
 }
Example #5
0
 public KillScenario(SimDescription sim, SimDescription killer, SimDescription.DeathType deathType, string storyName)
     : base (sim)
 {
     mKiller = killer;
     mDeathType = deathType;
     mStoryName = storyName;
 }
Example #6
0
 public SimID(SimDescription sim)
 {
     if (sim != null)
     {
         mID = sim.SimDescriptionId;
     }
 }
        protected override bool AllowSpecies(SimDescription sim, SimDescription target)
        {
            if (!sim.IsHuman) return true;

            // The FirstAction pushes require that the initiator be the non-human
            return target.IsHuman;
        }
Example #8
0
        protected override bool Run(SimDescription a, SimDescription b)
        {
            if (!base.Run(a, b)) return false;

            Relationship.Get(a, b, true).MakeAcquaintances();
            return true;
        }
Example #9
0
        protected override bool Allow(SimDescription sim)
        {
            if (sim.CreatedSim == null)
            {
                IncStat("Hibernating");
                return false;
            }
            else if (sim.CareerManager == null)
            {
                IncStat("No Manager");
                return false;
            }
            else if (sim.Household == null)
            {
                IncStat("No Home");
                return false;
            }
            else if (SimTypes.IsSpecial(sim))
            {
                IncStat("Special");
                return false;
            }
            else if (sim.CareerManager.School == null)
            {
                IncStat("No School");
                return false;
            }

            return base.Allow(sim);
        }
Example #10
0
        protected void PrivateAddBandMember(RockBand ths, SimDescription otherSimDesc)
        {
            if (ths.mBandInfo == null)
            {
                ths.mBandInfo = new RockBandInfo();
                ths.mBandInfo.AddBandMember(ths.SkillOwner.SimDescriptionId);
                Sim createdSim = ths.SkillOwner.CreatedSim;
                if (createdSim != null)
                {
                    ActiveTopic.AddToSim(createdSim, "Rock Band");
                }
            }

            //if (ths.mBandInfo.NumBandMembers < 0x4)
            {
                ths.mBandInfo.AddBandMember(otherSimDesc.SimDescriptionId);
                Sim sim = otherSimDesc.CreatedSim;
                if (sim != null)
                {
                    ActiveTopic.AddToSim(sim, "Rock Band");
                }

                SkillManager skillManager = otherSimDesc.SkillManager;
                RockBand skill = skillManager.GetSkill<RockBand>(SkillNames.RockBand);
                if (skill == null)
                {
                    skillManager.AddAutomaticSkill(SkillNames.RockBand);
                    skill = skillManager.GetSkill<RockBand>(SkillNames.RockBand);
                }

                skill.mBandInfo = ths.mBandInfo;
                skill.BandNameUpdate(ths.mBandInfo.BandName);
            }
        }
Example #11
0
        protected override bool Run(SimDescription a, SimDescription b)
        {
            RockBand skill = a.SkillManager.GetSkill<RockBand>(SkillNames.RockBand);

            PrivateAddBandMember(skill, b);
            return true;
        }
        protected override bool CommonAllow(SimDescription sim)
        {
            if (Sims.HasEnough(this, sim))
            {
                IncStat("Maximum Reached");
                return false;
            }
            else if (sim.IsPregnant)
            {
                IncStat("Couple Pregnant");
                return false;
            }
            else if (!Pregnancies.Allow(this, sim))
            {
                IncStat("User Denied");
                return false;
            }

            if (GetValue<MaximumNumberOfChildrenOption, int>(sim) > 0)
            {
                if (AddScoring("PreferredBabyCount", sim) <= Relationships.GetChildren(sim).Count)
                {
                    IncStat("Enough");
                    return false;
                }
            }

            return base.CommonAllow(sim);
        }
Example #13
0
 // Exported to Traveler
 public static void Restore(SimDescription sim)
 {
     foreach (ITransition setting in Common.DerivativeSearch.Find<ITransition>())
     {
         setting.Restore(sim);
     }
 }
Example #14
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                List<PreferenceColor.Item> allOptions = new List<PreferenceColor.Item>();

                foreach (CASCharacter.NameColorPair color in CASCharacter.kColors)
                {
                    allOptions.Add(new PreferenceColor.Item(color.mColor, (me.FavoriteColor == color.mColor) ? 1 : 0));
                }

                PreferenceColor.Item choice = new CommonSelection<PreferenceColor.Item>(Name, me.FullName, allOptions).SelectSingle();
                if (choice == null) return false;

                mFavoriteColor = choice.Value;
            }

            me.FavoriteColor = mFavoriteColor;

            if (PlumbBob.SelectedActor == me.CreatedSim)
            {
                (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId);
            }

            return true;
        }
Example #15
0
 protected static void CommonCorrections(SimDescription sim)
 {
     if (sim.AgingState == null)
     {
         AgingManager.Singleton.AddSimDescription(sim);
     }
 }
Example #16
0
        protected static OccultTypes FirstOccult(SimDescription sim)
        {
            List<OccultTypes> types = OccultTypeHelper.CreateList(sim);
            if (types.Count == 0) return OccultTypes.None;

            return types[0];
        }
 public ManualCashTransferScenario(SimDescription sim, SimDescription target, int delta, string accountingKey, int minimum, int maximum)
     : base(sim, target, delta)
 {
     mAccountingKey = accountingKey;
     mMinimum = minimum;
     mMaximum = maximum;
 }
Example #18
0
        protected override List<Item> PrivateRun(SimDescription me, IEnumerable<Item> choices)
        {
            string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":MinPrompt", false, new object[0]), "0");
            if (string.IsNullOrEmpty(text)) return null;

            float min;
            if (!float.TryParse(text, out min))
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                return null;
            }

            text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":MaxPrompt", false, new object[0]), "0");
            if (string.IsNullOrEmpty(text)) return null;

            float max;
            if (!float.TryParse(text, out max))
            {
                SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                return null;
            }

            Vector2 range = new Vector2(min, max);

            List<Item> selection = new List<Item>();
            foreach (Item choice in choices)
            {
                if (choice == null) continue;

                selection.Add(new RandomItem(choice, range));
            }

            return selection;
        }
Example #19
0
 // Methods             
 public static void HandlePayments(int price, SimDescription sim)
 {           
    
     //Return lot owner
     Household household = null;
     if (((sim.CreatedSim != null) && (sim.CreatedSim.LotCurrent != null)) && sim.CreatedSim.LotCurrent.IsCommunityLot)
     {
         household = ReturnLotOwner(sim.CreatedSim.LotCurrent);
     }
  
     if ((household == null) || ((household != null) && (sim.Household != household)))
     {
         if (sim.Household.FamilyFunds >= price)
         {
             sim.Household.ModifyFamilyFunds(-price);
         }
         else if (price > 0)
         {
             Household household1 = sim.Household;
             household1.UnpaidBills += price;
             StyledNotification.Show(new StyledNotification.Format(LocalizeString("CantAffordToPay", new object[] { sim.FullName }), StyledNotification.NotificationStyle.kGameMessagePositive));
         }
     }
     //Pay Lot owner
     if ((household != null) && (sim.Household != household))
     {
         household.ModifyFamilyFunds(price);
         StyledNotification.Show(new StyledNotification.Format(LocalizeString("LotOwnerEarned", new object[] { household.Name, price }), StyledNotification.NotificationStyle.kGameMessagePositive));
     }
   //  StyledNotification.Show(new StyledNotification.Format(LocalizeString("ItemsPurchased", new object[] { sim.FullName, itemCount.ToString(), num * itemCount }), StyledNotification.NotificationStyle.kGameMessagePositive));
 }
        public static Anysim clone(Role toClone, SimDescription actor)
        {
            Anysim newRole = new Anysim(toClone.Data, actor, toClone.RoleGivingObject);
            newRole.StartRole();

            return newRole;
        }
Example #21
0
		protected override bool Run(SimDescription me, bool singleSelection)
		{
			PerformanceCareer performer = me.OccupationAsPerformanceCareer;
			if (performer != null)
			{
				//me.OccupationAsPerformanceCareer.GivePerformerName (me.CreatedSim, false);
				string text2;
				if (string.IsNullOrEmpty(performer.StageName))
				{
					string localizedString = StringTable.GetLocalizedString((!me.IsFemale) ? (performer.MaleGivenNameKeyBase + RandomUtil.GetInt(performer.GetNumberOfMaleGivenNames - 1).ToString()) : (performer.FemaleGivenNameKeyBase + RandomUtil.GetInt(performer.GetNumberFemaleGivenNames - 1).ToString()));
					string text = Common.LocalizeEAString(me.IsFemale, performer.FamilyNameKeyBase + RandomUtil.GetInt(performer.GetNumberOfFamilyNames - 1).ToString());
					if (StringTable.GetLocale() == "ja-jp")
						text2 = text + " " + localizedString;
					else
						text2 = localizedString + " " + text;
				}
				else
				{
					text2 = performer.StageName;
				}
				string text3 = StringInputDialogRandom.Show(Common.LocalizeEAString("Ui/CreateNameUI:Title"), me.FullName + " (" + performer.CareerName + ")", text2, 27, StringInputDialog.Validation.TextOnly, false, new StringInputDialogRandom.RandomDelegate(performer.GetRandomStageName));
				if (!string.IsNullOrEmpty (text3))
				{
					me.OccupationAsPerformanceCareer.StageName = text3;
					me.CareerManager.UpdateCareerUI ();
					return true;
				}
			}
			return false;
		}
Example #22
0
        public static bool Restore(SimDescription sim)
        {
            foreach (CrossWorldData data in sData)
            {
                if (data.mName == sim.FullName)
                {
                    data.Restore(sim);

                    foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                    {
                        try
                        {
                            //if (!assembly.GetName().Name.StartsWith("NRaas")) continue;

                            Type common = assembly.GetType("NRaas.CommonSpace.Helpers.Transition");
                            if (common == null) continue;

                            MethodInfo restore = common.GetMethod("Restore", BindingFlags.Public | BindingFlags.Static);
                            if (restore == null) continue;

                            restore.Invoke(null, new object[] { sim });
                        }
                        catch (Exception e)
                        {
                            Common.Exception(assembly.GetName().Name, e);
                        }
                    }

                    return true;
                }
            }

            return false;
        }
 public ExistingFriendManualScenario(SimDescription sim, SimDescription target, int delta, int reportChance, string storyName)
     : base(sim, target, delta, false)
 {
     mInitialReportChance = reportChance;
     mContinueReportChance = reportChance;
     mStoryName = storyName;
 }
Example #24
0
 protected RemovePartsOutfitTask(SimDescription sim, ICollection<BodyTypes> types, bool currentOnly, PostPerform onPostPerform)
 {
     mSim = sim;
     mTypes = new List<BodyTypes>(types).ToArray();
     mCurrentOnly = currentOnly;
     mPostPerform = onPostPerform;
 }
        public override void SetActors(SimDescription actor, SimDescription target)
        {
            Sim = actor;
            mLoser = target;

            base.SetActors(actor, target);
        }
Example #26
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("BabyMultiple:Prompt", me.IsFemale, new object[] { me, Pregnancy.kMaxBabyMultiplier }), me.Pregnancy.mMultipleBabiesMultiplier.ToString());
                if (string.IsNullOrEmpty(text)) return false;

                mMultiple = 0;
                if (!float.TryParse(text, out mMultiple))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return false;
                }

                if (mMultiple < 0)
                {
                    mMultiple = 0;
                }
                else if (mMultiple > Pregnancy.kMaxBabyMultiplier)
                {
                    mMultiple = Pregnancy.kMaxBabyMultiplier;
                }
            }

            me.Pregnancy.mMultipleBabiesMultiplier = mMultiple;
            return true;
        }
Example #27
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("Performance:Prompt"), GetValue(me).ToString(), 256, StringInputDialog.Validation.None);
                if ((text == null) || (text == "")) return false;

                if (!float.TryParse(text, out mValue))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return false;
                }

                if (mValue > 100f)
                {
                    mValue = 100f;
                }
                else if (mValue < -100f)
                {
                    mValue = -100f;
                }
            }

            SetValue (me, mValue);
            return true;
        }
Example #28
0
        protected override bool Allow(SimDescription sim)
        {
            Occupation job = Occupation;

            if (!ManagerCareer.ValidCareer(job))
            {
                IncStat("Invalid");
                return false;
            }
            else if (sim.Service != null)
            {
                IncStat("On Call");
                return false;
            }
            else if (sim.Genealogy == null)
            {
                IncStat("No Gene");
                return false;
            }
            else if (SimTypes.IsDead(sim))
            {
                IncStat("Dead");
                return false;
            }

            return base.Allow(sim);
        }
Example #29
0
        protected override void Process(SimDescription sim)
        {
            List<BodyTypes> types = new List<BodyTypes>(CASParts.BodyHairTypes);
            types.Add(BodyTypes.Beard);

            RemovePartsOutfitTask.Perform(sim, types, false, null);
        }
Example #30
0
        public static bool EnsureInstantiate(SimDescription sim, Lot lot)
        {
            if (sim.CreatedSim == null)
            {
                if (sim.Household == null)
                {
                    if (!sim.IsValidDescription)
                    {
                        sim.Fixup();
                    }

                    Urnstone urnstone = Urnstones.CreateGrave(sim, SimDescription.DeathType.OldAge, false, true);
                    if (urnstone != null)
                    {
                        Common.Sleep();

                        if (!Urnstones.GhostSpawn(urnstone, lot))
                        {
                            return false;
                        }
                    }
                }
                else
                {
                    Instantiation.Perform(sim, null);
                }
            }

            return (sim.CreatedSim != null);
        }
Example #31
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("RepairImaginaryFriends");

            Trait trait;
            if (TraitManager.sDictionary.TryGetValue((ulong)TraitNames.ImaginaryFriendHiddenTrait, out trait))
            {
                trait.mNonPersistableData.mCanBeLearnedRandomly = false;
            }

            foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects<ImaginaryDoll>())
            {
                if (doll.mLiveStateSimDescId == 0) continue;

                if (doll.GetLiveFormSimDescription() != null) continue;

                doll.CreateLiveStateForm();

                Overwatch.Log("Missing Imaginary Doll Repaired");
            }

            foreach (SimDescription sim in Households.All(Household.NpcHousehold))
            {
                if (sim.OccultManager == null) continue;

                OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;
                if (occult == null) continue;

                Overwatch.Log(sim.FullName);

                if (occult.IsReal) continue;

                SimDescription owner = SimDescription.Find(occult.OwnerSimDescriptionId);
                if (owner == null) continue;

                if (owner.LotHome == null) continue;

                IScriptProxy proxy = Simulator.GetProxy(occult.mDollId);
                if (proxy == null)
                {
                    IGameObject obj = GlobalFunctions.CreateObjectOutOfWorld("ImaginaryFriendDoll", ProductVersion.EP4);
                    if (obj != null)
                    {
                        ImaginaryDoll doll = obj as ImaginaryDoll;
                        if (doll == null)
                        {
                            obj.Destroy();
                        }
                        else
                        {
                            occult.UpdateDollGuid(obj.ObjectId);

                            doll.SetOwner(owner);

                            doll.mLiveStateSimDescId = sim.SimDescriptionId;
                            doll.mIsFemale = sim.IsFemale;
                            doll.mGenderSet = true;
                            doll.EstablishState(ImaginaryDoll.OwnershipState.Live);

                            Sim ownerSim = owner.CreatedSim;
                            if (ownerSim != null)
                            {
                                if (Inventories.TryToMove(obj, ownerSim))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Sim Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                            else
                            {
                                if (Inventories.TryToMove(obj, ownerSim.Household.SharedFamilyInventory.Inventory))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Family Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                        }
                    }
                }
            }
        }
Example #32
0
 public ActiveCareerToneScenario(SimDescription sim)
     : base(sim)
 {
 }
Example #33
0
            public void Dispose(bool postLoad, bool isReset)
            {
                try
                {
                    if (mWasFutureSim)
                    {
                        mSim.TraitManager.AddHiddenElement(TraitNames.FutureSim);
                    }

                    if (mSim.CreatedSim != null)
                    {
                        BuffManager buffManager = mSim.CreatedSim.BuffManager;
                        if ((buffManager != null) && (mBuffs != null))
                        {
                            foreach (BuffInstance buff in mBuffs)
                            {
                                buffManager.AddBuff(buff.Guid, buff.mEffectValue, buff.mTimeoutCount, buff.mTimeoutPaused, buff.mAxisEffected, buff.mBuffOrigin, false);
                            }
                        }

                        if ((mInventory != null) && (mSim.CreatedSim.Inventory != null))
                        {
                            Inventories.RestoreInventoryFromList(mSim.CreatedSim.Inventory, mInventory, true);
                        }

                        if (mDreamStore != null)
                        {
                            mDreamStore.Restore(mSim.CreatedSim);
                        }

                        if (mSafeStore != null)
                        {
                            mSafeStore.Dispose();
                        }

                        if (mSim.DeathStyle != SimDescription.DeathType.None)
                        {
                            Urnstone stone = Urnstones.FindGhostsGrave(mSim);
                            if (stone != null)
                            {
                                stone.GhostSetup(mSim.CreatedSim, true);
                            }
                        }

                        mSim.CreatedSim.ReservedVehicle = mReservedVehicle;
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mSim, null, "Inventory", e);
                }

                // Must be after the opportunities are restored
                if ((mOpportunitiesChanged != null) && (OpportunityTrackerModel.gSingleton != null))
                {
                    OpportunityTrackerModel.gSingleton.OpportunitiesChanged = mOpportunitiesChanged;
                }

                try
                {
                    if (!postLoad)
                    {
                        if ((mSim.CreatedSim != null) &&
                            (mSim.CreatedSim.OpportunityManager != null) &&
                            (mSim.CreatedSim.OpportunityManager.Count > 0))
                        {
                            OpportunityTrackerModel.FireOpportunitiesChanged();
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mSim, null, "FireOpportunitiesChanged", e);
                }

                EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false;

                mSim.mGenealogy = mGenealogy;

                if (mDoll != null)
                {
                    mDoll.mOwner = mSim;

                    if (SimTypes.IsSelectable(mSim))
                    {
                        try
                        {
                            mDoll.OnOwnerBecameSelectable();
                        }
                        catch (Exception e)
                        {
                            Common.Exception(mSim, e);

                            SimDescription sim = mDoll.GetLiveFormSimDescription();
                            if (sim != null)
                            {
                                new FixInvisibleTask(sim).AddToSimulator();
                            }
                        }
                    }
                }

                if ((mSim.CreatedSim != null) && (mSim.CreatedSim.Motives != null))
                {
                    if (mAcademicPerformance != -101)
                    {
                        mSim.CreatedSim.Motives.CreateMotive(CommodityKind.AcademicPerformance);
                        Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.AcademicPerformance);
                        if (motive != null)
                        {
                            motive.Value = mAcademicPerformance;
                        }
                    }

                    if (mUniversityStudy != -101)
                    {
                        mSim.CreatedSim.Motives.CreateMotive(CommodityKind.UniversityStudy);
                        Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.UniversityStudy);
                        if (motive != null)
                        {
                            motive.Value = mUniversityStudy;
                        }
                    }
                }

                Relationships.RestoreRelations(mSim, mRelations);

                if ((mSim.TraitChipManager != null) && (mChips != null))
                {
                    for (int i = 0; i < mChips.Length; i++)
                    {
                        if (mChips[i] == null)
                        {
                            continue;
                        }

                        Common.StringBuilder name = new Common.StringBuilder();
                        try
                        {
                            name.Append(mChips[i].GetLocalizedName());

                            mSim.TraitChipManager.AddTraitChip(mChips[i], i);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(mSim, null, name, e);
                        }
                    }
                }

                sChangingWorldsSuppression.Pop();

                if ((mChangedHousehold != null) && (mChangedCallback != null))
                {
                    mChangedHousehold.HouseholdSimsChanged = mChangedCallback;
                }
            }
Example #34
0
            public CreationProtection(SimDescription sim, Sim createdSim, bool performLoadFixup, bool performSelectable, bool performUnselectable)
            {
                try
                {
                    mSim = sim;

                    Corrections.RemoveFreeStuffAlarm(sim);

                    // Stops an issue in "GrantFutureObjects" regarding the use of sIsChangingWorlds=true
                    mWasFutureSim = sim.TraitManager.HasElement(TraitNames.FutureSim);
                    sim.TraitManager.RemoveElement(TraitNames.FutureSim);

                    if (SimTypes.IsSelectable(mSim))
                    {
                        Corrections.CleanupBrokenSkills(mSim, null);
                    }

                    if (OpportunityTrackerModel.gSingleton != null)
                    {
                        mOpportunitiesChanged = OpportunityTrackerModel.gSingleton.OpportunitiesChanged;
                        OpportunityTrackerModel.gSingleton.OpportunitiesChanged = null;
                    }

                    if (mSim.TraitChipManager != null)
                    {
                        mChips = mSim.TraitChipManager.GetAllTraitChips();
                        mSim.TraitChipManager.mTraitChipSlots = new TraitChip[7];
                        mSim.TraitChipManager.mValues.Clear();
                    }

                    if (createdSim != null)
                    {
                        if (createdSim.BuffManager != null)
                        {
                            mBuffs = new List <BuffInstance>();

                            foreach (BuffInstance buff in createdSim.BuffManager.List)
                            {
                                mBuffs.Add(buff);
                            }
                        }

                        if (createdSim.Motives != null)
                        {
                            Motive motive = createdSim.Motives.GetMotive(CommodityKind.AcademicPerformance);
                            if (motive != null)
                            {
                                mAcademicPerformance = motive.Value;
                            }

                            motive = createdSim.Motives.GetMotive(CommodityKind.UniversityStudy);
                            if (motive != null)
                            {
                                mUniversityStudy = motive.Value;
                            }
                        }

                        if (createdSim.Inventory != null)
                        {
                            mInventory = createdSim.Inventory.DestroyInventoryAndStoreInList();
                        }

                        mDreamStore = new DreamCatcher.DreamStore(createdSim, false, false);

                        mReservedVehicle           = createdSim.GetReservedVehicle();
                        createdSim.ReservedVehicle = null;
                    }

                    SafeStore.Flag flags = SafeStore.Flag.None;

                    if (performSelectable)
                    {
                        flags |= SafeStore.Flag.Selectable;
                    }

                    if (performLoadFixup)
                    {
                        flags |= SafeStore.Flag.LoadFixup;
                    }

                    if (performUnselectable)
                    {
                        flags |= SafeStore.Flag.Unselectable;
                    }

                    mSafeStore = new SafeStore(mSim, flags);

                    // Stops the startup errors when the imaginary friend is broken
                    mDoll = GetDollForSim(sim);
                    if (mDoll != null)
                    {
                        mDoll.mOwner = null;
                    }

                    mGenealogy = sim.mGenealogy;

                    mRelations = Relationships.StoreRelations(sim, null);

                    // Stops all event processing during the creation process
                    EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = true;

                    // Stops the interface from updating during OnCreation
                    if (sim.Household != null)
                    {
                        mChangedCallback  = sim.Household.HouseholdSimsChanged;
                        mChangedHousehold = sim.Household;

                        sim.Household.HouseholdSimsChanged = null;
                    }

                    sChangingWorldsSuppression.Push();

                    // Stops SetGeneologyRelationshipBits()
                    sim.mGenealogy = new Genealogy(sim);
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }
        private string GetId(object item)
        {
            string id = null;

            if (item != null)
            {
                SimDescription simD = item as SimDescription;
                if (simD != null)
                {
                    id = simD.FullName;
                }

                if (id == null)
                {
                    Sim sim = item as Sim;
                    if (sim != null)
                    {
                        id = sim.FullName;
                    }
                }

                if (id == null)
                {
                    Role roleItem = item as Role;
                    if (roleItem != null)
                    {
                        id = GetId(roleItem.SimInRole);
                    }
                }

                if (id == null)
                {
                    IRoleGiver roleItem = item as IRoleGiver;
                    if (roleItem != null && roleItem.CurrentRole != null)
                    {
                        id = GetId(roleItem.CurrentRole.mSim);
                    }
                }

                if (id == null)
                {
                    IInteractionInstance roleItem = item as IInteractionInstance;
                    if (roleItem != null)
                    {
                        id = GetId(roleItem.IInstanceActor);
                    }
                }

                if (item as String != null)
                {
                    id = item as String;
                }

                if (id == null)
                {
                    id = item.GetHashCode().ToString();
                }
            }
            else
            {
                id = "null";
            }

            return(id);
        }
Example #36
0
 public abstract bool Get(SimDescription me, IMiniSimDescription actor, Dictionary <TStoreType, TDataType> results);
Example #37
0
        protected string GetDetails(List <IMiniSimDescription> sims)
        {
            long lNoSchool = 0, lNoPerf = 0, lTotalSchool = 0;

            List <long> negPerfCount = new List <long>();
            List <long> posPerfCount = new List <long>();

            for (int perf = 0; perf < 10; perf++)
            {
                negPerfCount.Add(0);
                posPerfCount.Add(0);
            }

            foreach (IMiniSimDescription miniSim in sims)
            {
                SimDescription member = miniSim as SimDescription;
                if (member == null)
                {
                    continue;
                }

                if (SimTypes.IsSpecial(member))
                {
                    continue;
                }

                if ((!member.Child) && (!member.Teen))
                {
                    continue;
                }

                if ((member.CareerManager == null) || (member.CareerManager.School == null))
                {
                    if (!member.IsPet)
                    {
                        lNoSchool++;
                    }
                }
                else
                {
                    Sims3.Gameplay.Careers.School school = member.CareerManager.School;
                    if (school.Performance == 0)
                    {
                        lNoPerf++;
                    }
                    else if (school.Performance > 0)
                    {
                        int iPerf = (int)Math.Ceiling(school.Performance / 10f);
                        if (iPerf > 9)
                        {
                            iPerf = 9;
                        }
                        posPerfCount[iPerf]++;
                    }
                    else
                    {
                        int iPerf = (int)Math.Ceiling(-school.Performance / 10f);
                        if (iPerf > 9)
                        {
                            iPerf = 9;
                        }
                        negPerfCount[iPerf]++;
                    }

                    lTotalSchool++;
                }
            }

            string posBody = null, negBody = null;

            for (int perf = negPerfCount.Count - 1; perf >= 1; perf--)
            {
                negBody += Common.Localize("SchoolByPerf:Element1", false, new object[] { (perf * 10) });
                if (negPerfCount[perf] == 0)
                {
                    negBody += "-";
                }
                else
                {
                    negBody += Common.Localize("SchoolByPerf:Element3", false, new object[] { negPerfCount[perf] });
                }
            }

            for (int perf = 1; perf < posPerfCount.Count; perf++)
            {
                posBody += Common.Localize("SchoolByPerf:Element2", false, new object[] { (perf * 10) });
                if (posPerfCount[perf] == 0)
                {
                    posBody += "-";
                }
                else
                {
                    posBody += Common.Localize("SchoolByPerf:Element3", false, new object[] { posPerfCount[perf] });
                }
            }

            return(Common.Localize("SchoolByPerf:Body", false, new object[] { lNoSchool, negBody, lNoPerf, posBody, lTotalSchool }));
        }
Example #38
0
 protected MoveOutScenario(MoveOutScenario scenario)
     : base(scenario)
 {
     mStay = scenario.mStay;
 }
Example #39
0
 protected MoveOutScenario(SimDescription sim, SimDescription stay)
     : base(sim)
 {
     mStay = stay;
 }
Example #40
0
 protected override ICollection <SimDescription> GetTargets(SimDescription sim)
 {
     return(null);
 }
Example #41
0
        public void update_motive_buffs(Sim sim, CommodityKind commodity, int currentValue)
        {
            if (currentValue == -333)
            {
                return;
            }

            BuffManager    buffManager  = sim.BuffManager;
            SimDescription simd         = sim.SimDescription;
            TraitManager   traitManager = simd.TraitManager;

            MotiveTuning motiveTuning = sim.GetMotiveTuning(commodity);

            if (motiveTuning != null)
            {
                List <MotiveTuning.MotiveBuffTrigger> buffTriggers = motiveTuning.BuffTriggers;
                foreach (MotiveTuning.MotiveBuffTrigger item in buffTriggers)
                {
                    if ((float)currentValue <= Math.Max(item.mTriggerValueStart, item.mTriggerValueEnd) && (float)currentValue >= Math.Min(item.mTriggerValueStart, item.mTriggerValueEnd))
                    {
                        foreach (BuffNames item2 in item.mRemoveBuff)
                        {
                            if (item2 == BuffNames.Hungry)
                            {
                                buffManager.RemoveElement(BuffNames.HungryLikeTheWolf);
                            }
                            buffManager.RemoveElement(item2);
                        }
                        if (item.mAddBuff != BuffNames.Undefined)
                        {
                            if (item.mAddBuff == BuffNames.VeryHungry && simd.IsWerewolf && !buffManager.HasElement(BuffNames.HungryLikeTheWolf))
                            {
                                buffManager.AddElement(BuffNames.HungryLikeTheWolf, Origin.None);
                            }
                            if (!buffManager.HasElement(item.mAddBuff))
                            {
                                buffManager.AddElement(item.mAddBuff, Origin.None);
                            }
                        }
                        if (item.mCustomClass != null)
                        {
                            item.mCustomClass.Invoke(null, new object[1]
                            {
                                sim
                            });
                        }
                    }
                    else if (buffManager.IsPermaMoodlet(item.mAddBuff) && commodity != CommodityKind.Hygiene && commodity != CommodityKind.CatScratch && commodity != CommodityKind.MermaidDermalHydration)
                    {
                        buffManager.RemoveElement(item.mAddBuff);
                    }
                }
            }
            if ((float)currentValue == Tuning.Min || (commodity == CommodityKind.Temperature && (float)currentValue == Tuning.Max))
            {
                MotiveDistress(sim, commodity);
            }
            if (traitManager.HasElement(TraitNames.BroodingTrait))
            {
                if (commodity == CommodityKind.Social && (float)currentValue <= kMisunderstoodSocialMotiveAddValue && !buffManager.HasElement(BuffNames.Misunderstood) && !buffManager.HasElement(BuffNames.NeedToBrood))
                {
                    buffManager.AddElement(BuffNames.Misunderstood, Origin.FromBeingBroodingTrait);
                }
                if (commodity == CommodityKind.Social && (float)currentValue >= kMisunderstoodSocialMotiveRemoveValue)
                {
                    buffManager.RemoveElement(BuffNames.Misunderstood);
                }
            }
            if ((commodity == CommodityKind.Hygiene || commodity == CommodityKind.Energy) && (buffManager.HasElement(BuffNames.SickAndTired) || buffManager.HasElement(BuffNames.PestilencePlague)))
            {
                BuffSickAndTired.CheckForStartStopFlySwarmEffect(sim, commodity, currentValue);
            }
            if (Commodity == CommodityKind.AuraPower)
            {
                BuffFairyAuraProjecting.BuffAuraInstanceBase buffAuraInstanceBase = buffManager.GetElement(BuffNames.FairyAuraProjectingSoothe) as BuffFairyAuraProjecting.BuffAuraInstanceBase;
                if (buffAuraInstanceBase == null)
                {
                    buffAuraInstanceBase = (buffManager.GetElement(BuffNames.FairyAuraProjectingCreative) as BuffFairyAuraProjecting.BuffAuraInstanceBase);
                }
                if (buffAuraInstanceBase == null)
                {
                    buffAuraInstanceBase = (buffManager.GetElement(BuffNames.FairyAuraProjectingMind) as BuffFairyAuraProjecting.BuffAuraInstanceBase);
                }
                if (buffAuraInstanceBase != null)
                {
                    buffAuraInstanceBase.UpdateColor();
                }
            }
        }
Example #42
0
        public void motive_motive_distress(Sim sim, CommodityKind commodity)
        {
            if (commodity == (CommodityKind)0x44440444)
            {
                return;
            }

            SimDescription simd        = sim.SimDescription;
            BuffManager    buffManager = sim.BuffManager;
            Motives        moves       = sim.Motives;

            switch (commodity)
            {
            case CommodityKind.Bladder:
            {
                bool flag = true;
                InteractionDefinition interactionDefinition;
                switch (simd.Species)
                {
                case CASAgeGenderFlags.Horse:
                    interactionDefinition = Sim.HorsePee.Singleton;
                    break;

                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    interactionDefinition = (InteractionDefinition)Sim.DogPeeStart.Singleton;
                    break;

                case CASAgeGenderFlags.Cat:
                    interactionDefinition = (InteractionDefinition)Sim.CatPeeStart.Singleton;
                    break;

                default:
                    interactionDefinition = Sim.BladderFailure.Singleton;
                    break;
                }

                foreach (InteractionInstance interaction in sim.InteractionQueue.InteractionList)
                {
                    if (interaction is Sim.DogPee || interaction is Sim.CatPee || interaction.InteractionDefinition == interactionDefinition)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    SwimmingInPool swimmingInPool = sim.Posture as SwimmingInPool;
                    if (swimmingInPool == null)
                    {
                        InteractionInstance interactionInstance = interactionDefinition.CreateInstance(sim, sim, new InteractionPriority(InteractionPriorityLevel.High), false, false);
                        Sim.DogPeeStart     dogPeeStart         = interactionInstance as Sim.DogPeeStart;
                        if (dogPeeStart != null)
                        {
                            dogPeeStart.DoNotRoute = true;
                        }
                        else
                        {
                            Sim.CatPeeStart catPeeStart = interactionInstance as Sim.CatPeeStart;
                            if (catPeeStart != null)
                            {
                                catPeeStart.DoNotRoute = true;
                            }
                        }
                        if (sim.InteractionQueue.AddNext(interactionInstance) && simd.IsRaccoon)
                        {
                            sim.AddExitReason(ExitReason.BuffFailureState);
                        }
                        else
                        {
                            BuffInstance buffOfSolveCommodity = buffManager.GetBuffOfSolveCommodity(commodity);
                            if (buffOfSolveCommodity != null && buffOfSolveCommodity.EffectValue <= 0)
                            {
                                ThoughtBalloonManager.BalloonData balloonData = new ThoughtBalloonManager.BalloonData(buffOfSolveCommodity.ThumbString);
                                if (balloonData.IsValid)
                                {
                                    balloonData.BalloonType = ThoughtBalloonTypes.kScreamBalloon;
                                    balloonData.mCoolDown   = ThoughtBalloonCooldown.None;
                                    sim.ThoughtBalloonManager.ShowBalloon(balloonData);
                                }
                            }

                            moves.SetMax(CommodityKind.Bladder);

                            if (!simd.IsPet)
                            {
                                PuddleManager.AddPuddle(sim.Position);
                                moves.SetValue(CommodityKind.Hygiene, -100f);
                                if (GlobalFunctions.AreOtherSimsNearby(sim, BuffEmbarrassed.DistanceForEmbarrassedBuff))
                                {
                                    buffManager.AddElement(BuffNames.Embarrassed, Origin.FromPeeingSelf);
                                }
                                ActiveTopic.AddToSim(sim, "Embarrassment");
                            }
                            else
                            {
                                MetaAutonomyVenueType metaAutonomyVenueType = sim.LotCurrent.GetMetaAutonomyVenueType();
                                if ((!simd.IsADogSpecies || metaAutonomyVenueType != MetaAutonomyVenueType.DogPark) && World.GetTerrainType(sim.Position) == TerrainType.LotFloor)
                                {
                                    PuddleManager.AddPuddle(sim.Position);
                                }
                            }
                            EventTracker.SendEvent(EventTypeId.kBladderFailure, sim);
                        }
                        Motive motive = moves.GetMotive(CommodityKind.Bladder);
                        if (motive != null)
                        {
                            motive.PotionBladderDecayOverride = false;
                        }
                    }
                    else
                    {
                        swimmingInPool.ContainerPool.PeeInPool(sim);
                    }
                }
                break;
            }

            case CommodityKind.Hunger:
            case CommodityKind.VampireThirst:

                if (simd.IsFrankenstein)
                {
                    OccultFrankenstein.PushFrankensteinShortOut(sim);
                }
                else if (!simd.IsGhost && !simd.IsDead && !IsCheckKillSimInteraction(sim))
                {
                    if (sim.Posture.Satisfies(CommodityKind.ScubaDiving, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.ScubaDrown);
                    }
                    else if (sim.Posture.Satisfies(CommodityKind.SwimmingInPool, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.Drown);
                    }
                    else if (SimTemperature.HasFrozenSolidInteraction(sim))
                    {
                        sim.Kill(SimDescription.DeathType.Freeze, null, false);
                    }
                    else if (OccultMermaid.IsDehydrated(sim))
                    {
                        sim.Kill(SimDescription.DeathType.MermaidDehydrated, null, false);
                    }
                    else
                    {
                        sim.Kill(sim.SimDescription.IsVampire ? SimDescription.DeathType.Thirst : SimDescription.DeathType.Starve);
                    }
                }
                break;

            case CommodityKind.Temperature:
            {
                float value = moves.GetValue(CommodityKind.Temperature);
                if (value > 0f)
                {
                    SimTemperature.PushSpontaneouslyCombustInteraction(sim);
                }
                else
                {
                    SimTemperature.PushFreezeInteraction(sim);
                }
                break;
            }

            case CommodityKind.MermaidDermalHydration:
                OccultMermaid.CollapseFromDehydration(sim);
                break;
            }
        }
Example #43
0
 protected PropagateEnemyScenario(SimDescription primary, SimDescription enemy, BuffNames buff, Origin origin, int delta)
     : base(primary, buff, origin)
 {
     mEnemy = enemy;
     mDelta = delta;
 }
        public override bool Run()
        {
            try
            {
                if (!Target.RouteToPedestal(Actor, true))
                {
                    return(false);
                }

                Definition interactionDefinition = InteractionDefinition as Definition;
                if (Responder.Instance.OptionsModel.SaveGameInProgress)
                {
                    return(false);
                }

                Target.DisplayAge    = interactionDefinition.mAge;
                Target.DisplayGender = interactionDefinition.mGender;
                StandardEntry();
                BeginCommodityUpdates();
                EnterStateMachine("ShoppingPedestal", "Enter", "x");
                SetParameter("x:Age", Actor.SimDescription.Age);
                AnimateSim("Change Item");
                SimDescription simDesc = new SimDescription();
                if (simDesc == null)
                {
                    throw new Exception("ChangeOutfit:  sim doesn't have a description!");
                }

                Target.PedestalOutfitsSaveTo(simDesc);
                Household.CreateTouristHousehold();
                Household.TouristHousehold.AddTemporary(simDesc);
                try
                {
                    if (GameUtils.IsInstalled(ProductVersion.EP2))
                    {
                        new Sims.Stylist(Sims.CASBase.EditType.Mannequin, Target.DisplayCategory).Perform(new GameHitParameters <SimDescriptionObject>(Sim.ActiveActor, new SimDescriptionObject(simDesc), GameObjectHit.NoHit));
                    }
                    else
                    {
                        new Sims.Dresser(Sims.CASBase.EditType.Mannequin, Target.DisplayCategory).Perform(new GameHitParameters <SimDescriptionObject>(Sim.ActiveActor, new SimDescriptionObject(simDesc), GameObjectHit.NoHit));
                    }

                    while (GameStates.NextInWorldStateId != InWorldState.SubState.LiveMode)
                    {
                        SpeedTrap.Sleep(0x0);
                    }
                    Actor.InteractionQueue.CancelAllInteractionsByType(Singleton);
                }
                finally
                {
                    Household.TouristHousehold.RemoveTemporary(simDesc);
                }

                Target.PedestalOutfitsLoadFrom(simDesc, Actor);
                Target.ChangeOutfit();
                AnimateSim("Exit");
                EndCommodityUpdates(true);
                StandardExit();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
            }

            return(false);
        }
Example #45
0
 protected override Lot GetLot(SimDescription sim)
 {
     return(sim.LotHome);
 }
Example #46
0
 public PropagateEnemyScenario(SimDescription primary, SimDescription enemy, int delta)
     : this(primary, enemy, BuffNames.Upset, Origin.FromWatchingSimSuffer, delta)
 {
 }
Example #47
0
 public void SetElapsedTime <T>(SimDescription sim)
     where T : GenericOptionItem <int>, IElapsedSimLevelOption, IWriteSimLevelOption, new()
 {
     SetValue <T, int>(sim, SimClock.ElapsedCalendarDays());
 }
Example #48
0
 public void SetValue <T, R>(SimDescription sim, R value)
     where T : GenericOptionItem <R>, IWriteSimLevelOption, new()
 {
     Options.GetSim(sim).SetValue <T, R>(value);
 }
Example #49
0
 public T GetData <T>(SimDescription sim)
     where T : ElementalSimData, new()
 {
     return(Options.GetSim <T>(sim));
 }
Example #50
0
 public int TestElapsedTimeSim <T, R>(SimDescription sim)
     where T : GenericOptionItem <int>, IReadSimLevelOption, IElapsedSimLevelOption, new()
     where R : GenericOptionItem <int>, IReadSimLevelOption, new()
 {
     return(GetElapsedTime <T>(sim) - GetValue <R, int>(sim));
 }
Example #51
0
 protected ImmigrantCareerScenario(ImmigrantCareerScenario scenario)
     : base(scenario)
 {
     mCareerSim = scenario.mCareerSim;
 }
 public CaughtCheatingBreakupScenario(SimDescription sim, bool affair, bool relatedStay)
     : base(sim, affair, relatedStay)
 {
 }
Example #53
0
        public override bool Run()
        {
            SimDescription hooker = null;

            Definition def = base.InteractionDefinition as Definition;

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

            try
            {
                StandardEntry();
                if (!Target.StartComputing(this, SurfaceHeight.Table, true))
                {
                    StandardExit();
                    return(false);
                }

                Target.StartVideo(Computer.VideoType.Chat);
                base.AnimateSim("GenericTyping");

                bool succeeded = true;
                if (base.DoTimedLoop(Computer.CheckWeather.kTimeToBrowse, ~(ExitReason.Replan | ExitReason.PlayIdle | ExitReason.ObjectStateChanged | ExitReason.MidRoutePushRequested | ExitReason.MaxSkillPointsReached | ExitReason.BuffFailureState | ExitReason.MoodFailure)))
                {
                    Dictionary <int, SimDescription> potentials = GetPotentials(Actor);

                    if (potentials.Values.Count > 0)
                    {
                        if (!def.mRandom)
                        {
                            hooker = new SimSelection(Common.Localize("OrderServices:Title"), Actor.SimDescription, potentials.Values, SimSelection.Type.ProfessionalServices, -1000).SelectSingle();
                            if (hooker == null)
                            {
                                Common.Notify(Common.Localize("Rendezvous:NoSelect", Actor.IsFemale));
                                succeeded = false;
                            }
                        }
                        else
                        {
                            int val = 0;
                            if (Actor.IsSelectable)
                            {
                                string text = StringInputDialog.Show(Common.Localize("OrderServices:Title"), Common.Localize("OrderServices:Prompt"), val.ToString());
                                if (string.IsNullOrEmpty(text))
                                {
                                    succeeded = false;
                                }

                                if (!int.TryParse(text, out val))
                                {
                                    SimpleMessageDialog.Show(Common.Localize("OrderServices:Title"), Common.Localize("Numeric:Error"));
                                    succeeded = false;
                                }
                            }
                            else
                            {
                                val = Actor.FamilyFunds * 2 / 100;
                            }

                            if (val > Actor.FamilyFunds)
                            {
                                if (Actor.IsSelectable)
                                {
                                    Common.Notify(Common.Localize("OrderServices:NoFunds", Actor.IsFemale));
                                }
                                succeeded = false;
                            }

                            if (succeeded)
                            {
                                // how much sexy can we afford?
                                bool allAbove = false;
                                foreach (SimDescription sim in potentials.Values)
                                {
                                    KamaSimtra skill = sim.SkillManager.GetSkill <KamaSimtra>(KamaSimtra.StaticGuid);
                                    if (skill == null)
                                    {
                                        continue;
                                    }

                                    if (skill.GetPayment() > Actor.FamilyFunds)
                                    {
                                        allAbove = true;
                                    }
                                    else
                                    {
                                        allAbove = false;
                                    }

                                    if (skill.GetPayment() > val)
                                    {
                                        continue;
                                    }
                                    hooker = sim;
                                }

                                if (hooker == null)
                                {
                                    if (!allAbove)
                                    {
                                        if (Actor.IsSelectable)
                                        {
                                            Common.Notify(Common.Localize("OrderServices:StopBeingCheap"));
                                        }
                                        succeeded = false;
                                    }
                                    else
                                    {
                                        if (Actor.IsSelectable)
                                        {
                                            Common.Notify(Common.Localize("OrderServices:NoFunds", Actor.IsFemale));
                                        }
                                        succeeded = false;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Common.Notify(Common.Localize("OrderServices:NoChoices", Actor.IsFemale));
                        succeeded = false;
                    }
                }

                if (succeeded && hooker != null)
                {
                    GetSimToLotEx(hooker, Actor.LotHome, def.mRandom);
                }

                Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
                StandardExit();
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #54
0
 public ImmigrantCareerScenario(SimDescription sim, ManagerLot.ImmigrationRequirement requirement)
     : base(sim, requirement)
 {
 }
Example #55
0
 protected override Occupation GetOccupation(SimDescription me)
 {
     return(me.Occupation);
 }
Example #56
0
 public GetOffStreetsScenario(SimDescription sim)
     : base(sim, null)
 {
 }
Example #57
0
        public static Sim Perform(Sim sim, bool fadeOut)
        {
            if (sim == null)
            {
                return(null);
            }

            try
            {
                SimDescription simDesc = sim.SimDescription;

                if (Simulator.GetProxy(sim.ObjectId) == null)
                {
                    if (simDesc != null)
                    {
                        sim.Destroy();
                    }

                    //sim.mSimDescription = null;
                    return(null);
                }

                if (simDesc == null)
                {
                    sim.mSimDescription = new SimDescription();

                    sim.Destroy();
                    return(null);
                }

                if (sim.LotHome != null)
                {
                    simDesc.IsZombie = false;

                    if (simDesc.CreatedSim != sim)
                    {
                        sim.Destroy();

                        simDesc.CreatedSim = null;

                        return(null);
                    }
                    else
                    {
                        Bed     myBed     = null;
                        BedData myBedData = null;

                        foreach (Bed bed in sim.LotHome.GetObjects <Bed>())
                        {
                            myBedData = bed.GetPartOwnedBy(sim);
                            if (myBedData != null)
                            {
                                myBed = bed;
                                break;
                            }
                        }

                        ResetPosture(sim);

                        if (simDesc.TraitManager == null)
                        {
                            simDesc.mTraitManager = new TraitManager();
                        }

                        try
                        {
                            simDesc.Fixup();

                            Corrections.CleanupBrokenSkills(simDesc, null);

                            ResetCareer(simDesc);

                            simDesc.ClearSpecialFlags();

                            if (simDesc.Pregnancy == null)
                            {
                                try
                                {
                                    if (simDesc.mMaternityOutfits == null)
                                    {
                                        simDesc.mMaternityOutfits = new OutfitCategoryMap();
                                    }
                                    simDesc.SetPregnancy(0, false);

                                    simDesc.ClearMaternityOutfits();
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(sim, null, "Pregnancy", e);
                                }
                            }

                            if (sim.CurrentCommodityInteractionMap == null)
                            {
                                try
                                {
                                    LotManager.PlaceObjectOnLot(sim, sim.ObjectId);

                                    if (sim.CurrentCommodityInteractionMap == null)
                                    {
                                        sim.ChangeCommodityInteractionMap(sim.LotHome.Map);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(sim, null, "ChangeCommodityInteractionMap", e);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, null, "Fixup", e);
                        }

                        ResetSituations(sim);

                        CleanupSlots(sim);

                        ResetInventory(sim);

                        if (fadeOut)
                        {
                            bool active = (Sim.ActiveActor == sim);

                            if (sSimReset.Valid)
                            {
                                sSimReset.Invoke <bool>(new object[] { simDesc.SimDescriptionId });
                            }

                            ResetRouting(sim);

                            using (CreationProtection protection = new CreationProtection(simDesc, sim, false, true, false))
                            {
                                sim.Destroy();

                                Common.Sleep();

                                sim = FixInvisibleTask.InstantiateAtHome(simDesc, null);
                            }

                            if (sim != null)
                            {
                                if (active)
                                {
                                    try
                                    {
                                        foreach (Sim member in Households.AllSims(sim.Household))
                                        {
                                            if (member.CareerManager == null)
                                            {
                                                continue;
                                            }

                                            Occupation occupation = member.CareerManager.Occupation;
                                            if (occupation == null)
                                            {
                                                continue;
                                            }

                                            occupation.FormerBoss = null;
                                        }

                                        using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(sim.Household, true))
                                        {
                                            PlumbBob.DoSelectActor(sim, true);
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Common.Exception(sim, null, "DoSelectActor", e);
                                    }
                                }

                                if ((myBed != null) && (myBedData != null))
                                {
                                    if ((sim.Partner != null) && (sim.Partner.CreatedSim != null))
                                    {
                                        myBed.ClaimOwnership(sim, myBedData);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (sim.Inventory == null)
                            {
                                sim.AddComponent <InventoryComponent>(new object[0x0]);
                            }

                            if (Instantiation.AttemptToPutInSafeLocation(sim, false))
                            {
                                ResetRouting(sim);

                                sim.SetObjectToReset();

                                // This is necessary to clear certain types of interactions
                                //   (it is also called in SetObjectToReset(), though doesn't always work there)
                                if (sim.InteractionQueue != null)
                                {
                                    sim.InteractionQueue.OnReset();
                                }
                            }
                        }

                        ResetSkillModifiers(simDesc);

                        ResetRole(sim);

                        if (simDesc.IsEnrolledInBoardingSchool())
                        {
                            simDesc.BoardingSchool.OnRemovedFromSchool();
                        }

                        MiniSimDescription miniSim = MiniSimDescription.Find(simDesc.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                        }

                        UpdateInterface(sim);

                        return(sim);
                    }
                }
                else if (simDesc.Service is Butler)
                {
                    if (Instantiation.AttemptToPutInSafeLocation(sim, true))
                    {
                        sim.Motives.RecreateMotives(sim);
                        sim.SetObjectToReset();
                    }

                    return(sim);
                }
                else if (simDesc.IsImaginaryFriend)
                {
                    OccultImaginaryFriend friend;
                    if (OccultImaginaryFriend.TryGetOccultFromSim(sim, out friend))
                    {
                        if (Simulator.GetProxy(friend.mDollId) != null)
                        {
                            friend.TurnBackIntoDoll(OccultImaginaryFriend.Destination.Owner);

                            return(null);
                        }
                    }
                }
                else if (simDesc.IsBonehilda)
                {
                    foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>())
                    {
                        if (coffin.mBonehilda == simDesc)
                        {
                            coffin.mBonehildaSim = null;
                            break;
                        }
                    }
                }

                if (fadeOut)
                {
                    sim.Destroy();
                }

                return(null);
            }
            catch (Exception exception)
            {
                Common.Exception(sim, exception);
                return(sim);
            }
        }
Example #58
0
        public static void ResetSkillModifiers(SimDescription sim)
        {
            if (sim.SkillManager == null)
            {
                return;
            }

            Corrections.CorrectOverallSkillModifier(sim);

            sim.SkillManager.mSkillModifiers = new Dictionary <SkillNames, float>();

            TraitManager traitManager = sim.TraitManager;

            if (traitManager != null)
            {
                foreach (Trait trait in traitManager.List)
                {
                    traitManager.AddTraitSkillGainModifiers(sim, trait.Guid);
                }
            }

            Dictionary <GameObject, bool> inventory = new Dictionary <GameObject, bool>();

            if ((sim.CreatedSim != null) && (sim.CreatedSim.Inventory != null))
            {
                foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.CreatedSim.Inventory))
                {
                    inventory.Add(obj, true);
                }
            }

            ulong eventId = (ulong)EventTypeId.kSkillLearnedSkill;

            Dictionary <ulong, List <EventListener> > events;

            if (!EventTracker.Instance.mListeners.TryGetValue(eventId, out events))
            {
                events = null;
            }
            else
            {
                EventTracker.Instance.mListeners.Remove(eventId);
            }

            if ((sim.CreatedSim != null) && (!sim.CreatedSim.HasBeenDestroyed))
            {
                foreach (Skill skill in sim.SkillManager.List)
                {
                    bool isChangingWorlds = GameStates.sIsChangingWorlds;

                    // Workaround for issue in IsIdTravelling
                    GameStates.sIsChangingWorlds = false;
                    try
                    {
                        skill.OnSkillAddition(true);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, "Skill: " + skill.Guid.ToString(), e);
                    }
                    finally
                    {
                        GameStates.sIsChangingWorlds = isChangingWorlds;
                    }
                }
            }

            if (events != null)
            {
                EventTracker.Instance.mListeners.Add(eventId, events);
            }

            if ((sim.CreatedSim != null) && (sim.CreatedSim.Inventory != null))
            {
                foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.CreatedSim.Inventory))
                {
                    if (inventory.ContainsKey(obj))
                    {
                        continue;
                    }

                    try
                    {
                        sim.CreatedSim.Inventory.RemoveByForce(obj);
                        obj.Destroy(); // Do not use FadeOut(), it hangs the game
                    }
                    catch
                    { }
                }
            }

            if (sim.OccultManager != null)
            {
                OccultVampire vampire = sim.OccultManager.GetOccultType(OccultTypes.Vampire) as OccultVampire;
                if ((vampire != null) && (vampire.AppliedNightBenefits))
                {
                    try
                    {
                        if ((sim.CreatedSim != null) && (!sim.CreatedSim.HasBeenDestroyed))
                        {
                            vampire.SunsetCallback();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }
            }
        }
Example #59
0
 public abstract int GetSkillLevel(SimDescription sim);
Example #60
0
 public bool Allow(IHasSkill stats, SimDescription sim, AllowCheck check)
 {
     return(PrivateAllow(stats, sim, check));
 }