Example #1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            foreach (Situation situation in Situation.sAllSituations)
            {
                SocialWorkerAdoptionSituation adoption = situation as SocialWorkerAdoptionSituation;
                if (adoption == null)
                {
                    continue;
                }

                if (adoption.mAdoptingParent != Event.mActor)
                {
                    continue;
                }

                SocialWorkerAdoptionSituation.InstantiateNewKid childSit = adoption.Child as SocialWorkerAdoptionSituation.InstantiateNewKid;
                if (childSit == null)
                {
                    continue;
                }

                Sim oldChild = childSit.mAdoptedChild;

                using (SimFromBin <ManagerLot> simBin = new SimFromBin <ManagerLot>(this, Lots))
                {
                    SimDescription newChild = simBin.CreateNewSim(oldChild.SimDescription.Age, oldChild.SimDescription.Gender, CASAgeGenderFlags.Human);
                    if (newChild == null)
                    {
                        IncStat("Creation Failure");
                        return(false);
                    }

                    newChild.WasAdopted = true;

                    adoption.mAdoptingParent.Household.Remove(oldChild.SimDescription);

                    adoption.mAdoptingParent.Household.Add(newChild);
                    adoption.mAdoptingParent.Genealogy.AddChild(newChild.Genealogy);

                    newChild.FirstName = oldChild.FirstName;
                    newChild.LastName  = oldChild.LastName;

                    childSit.mAdoptedChild = newChild.Instantiate(Vector3.Zero);

                    Deaths.CleansingKill(oldChild.SimDescription, true);

                    return(true);
                }
            }

            IncStat("Situation Not Found");
            return(false);
        }
Example #2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (Deaths.CleansingKill(Sim, SimDescription.DeathType.OldAge, false))
            {
                mPartner = Sim.Partner;

                if (Sim.Partner != null)
                {
                    Deaths.CleansingKill(Sim.Partner, SimDescription.DeathType.OldAge, false);
                }
                return(true);
            }
            return(false);
        }
Example #3
0
        public bool EliminateHousehold(string storyName, Household me)
        {
            if (SimTypes.IsService(me))
            {
                return(false);
            }

            if (!GameStates.IsLiveState)
            {
                IncStat("Mode Save");
                return(false);
            }

            if (AlarmManager.Global == null)
            {
                IncStat("No Alarm Manager");
                return(false);
            }

            if (Deaths == null)
            {
                IncStat("No Death Manager");
                return(false);
            }

            foreach (SimDescription sim in new List <SimDescription>(me.AllSimDescriptions))
            {
                Deaths.CleansingKill(sim, false);
            }

            me.Destroy();

            try
            {
                me.Dispose();
            }
            catch (Exception e)
            {
                Common.DebugException(me.Name, e);

                Household.sHouseholdList.Remove(me);
            }

            AddSuccess("Household Eliminated");

            IncStat("Household Eliminated: " + me.Name + Common.NewLine + "Story: " + storyName, Common.DebugLevel.High);

            ManagerSim.ForceRecount();
            return(true);
        }
Example #4
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            foreach (SimDescription sim in new List <SimDescription>(HouseholdsEx.All(House)))
            {
                string reason = null;
                if (!ManagerSim.ValidSim(sim, out reason))
                {
                    Deaths.CleansingKill(sim, false);
                }
            }

            if (HouseholdsEx.NumSims(House) == 0)
            {
                return(true);
            }

            return(false);
        }
Example #5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (Sim.CreatedSim == null)
            {
                Sims.Instantiate(Sim, Sim.LotHome, false);
            }

            if (Target.CreatedSim == null)
            {
                Sims.Instantiate(Target, Target.LotHome, false);
            }

            if ((Sim.CreatedSim == null) || (Target.CreatedSim == null))
            {
                IncStat("Uninstantiated");
                return(false);
            }
            else
            {
                if (Sim.IsRobot)
                {
                    if ((Sim.LotHome == null) ||
                        ((Sim.LotHome.CountObjects <BotMakingStation> () + Sim.LotHome.CountObjects <InventionWorkbench>()) == 0))
                    {
                        IncStat("No Workbench");
                        return(false);
                    }

                    SimDescription child = null;
                    if (Sim.IsFrankenstein)
                    {
                        bool reward = Sim.OccultManager.mIsLifetimeReward;

                        if ((Target.IsFrankenstein) && (RandomUtil.CoinFlip()))
                        {
                            reward = Target.OccultManager.mIsLifetimeReward;
                        }

                        Sim childSim = OccultFrankenstein.CreateFrankenStein(Sim.CreatedSim, CASAgeGenderFlags.None, reward);
                        if (childSim == null)
                        {
                            IncStat("Creation Fail");
                            return(false);
                        }

                        child = childSim.SimDescription;
                    }
                    else
                    {
                        child = OccultRobot.MakeRobot(CASAgeGenderFlags.Adult, CASAgeGenderFlags.None, RobotForms.MaxType);
                        if (child == null)
                        {
                            IncStat("Creation Fail");
                            return(false);
                        }

                        CASRobotData supernaturalData = child.SupernaturalData as CASRobotData;
                        if (supernaturalData != null)
                        {
                            supernaturalData.CreatorSim = Sim.SimDescriptionId;

                            int quality = 0;
                            int count   = 0;

                            CASRobotData parentData = Sim.SupernaturalData as CASRobotData;
                            if (parentData != null)
                            {
                                quality = parentData.BotQualityLevel;
                                count++;
                            }

                            parentData = Target.SupernaturalData as CASRobotData;
                            if (parentData != null)
                            {
                                quality += parentData.BotQualityLevel;
                                count++;
                            }

                            if (count == 2)
                            {
                                quality /= count;
                            }

                            supernaturalData.BotQualityLevel = quality;
                        }
                    }

                    if (child.Genealogy.Parents.Count == 0)
                    {
                        Sim.Genealogy.AddChild(child.Genealogy);
                    }

                    Target.Genealogy.AddChild(child.Genealogy);

                    if (!Households.MoveSim(child, Sim.Household))
                    {
                        IncStat("Move Fail");

                        Deaths.CleansingKill(child, true);

                        return(false);
                    }

                    return(true);
                }
                else if (Target.IsRobot)
                {
                    IncStat("Simbot Partner");
                    return(false);
                }
                else
                {
                    if (CommonSpace.Helpers.Pregnancies.Start(Sim.CreatedSim, Target, false) != null)
                    {
                        ManagerSim.ForceRecount();

                        if (Sim.IsHuman)
                        {
                            if (OnGatheringScenario != null)
                            {
                                OnGatheringScenario(this, frame);
                            }
                        }

                        if ((!Sim.IsHuman) && (Sim.Partner != Target))
                        {
                            if ((GetValue <AllowMarriageOption, bool>(Sim)) && (GetValue <AllowMarriageOption, bool>(Target)))
                            {
                                if ((Romances.AllowBreakup(this, Sim, Managers.Manager.AllowCheck.None)) && (Romances.AllowBreakup(this, Target, Managers.Manager.AllowCheck.None)))
                                {
                                    RemoveAllPetMateFlags(Sim);
                                    RemoveAllPetMateFlags(Target);
                                    Relationship.Get(Sim, Target, false).LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry);
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
        }
Example #6
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            SimDescription newSim = null;

            using (SimFromBin <ManagerSim> bin = new SimFromBin <ManagerSim>(this, Sims))
            {
                CASAgeGenderFlags gender = Sim.Gender;

                switch (GetValue <GenderOption, BabyGenderScenario.FirstBornGender>())
                {
                case BabyGenderScenario.FirstBornGender.Male:
                    gender = CASAgeGenderFlags.Male;
                    break;

                case BabyGenderScenario.FirstBornGender.Female:
                    gender = CASAgeGenderFlags.Female;
                    break;
                }

                newSim = bin.CreateNewSim(Sim.Age, gender, CASAgeGenderFlags.Human);
                if (newSim == null)
                {
                    IncStat("Creation Fail");
                    return(false);
                }
            }

            bool genderChanged = (Sim.Gender != newSim.Gender);

            bool result = FacialBlends.CopyGenetics(newSim, Sim, false, false);

            Sim.VoiceVariation     = newSim.VoiceVariation;
            Sim.VoicePitchModifier = newSim.VoicePitchModifier;

            Sim.FirstName = newSim.FirstName;

            if (genderChanged)
            {
                Sim.Gender = newSim.Gender;

                SavedOutfit.Cache cache = new SavedOutfit.Cache(newSim);

                Dictionary <OutfitCategories, bool> replaced = new Dictionary <OutfitCategories, bool>();

                Sim.RemoveOutfits(OutfitCategories.Career, true);

                SimOutfit geneOutfit = CASParts.GetOutfit(Sim, CASParts.sPrimary, false);

                foreach (SavedOutfit.Cache.Key outfit in cache.Outfits)
                {
                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, outfit.mKey, geneOutfit))
                    {
                        builder.Builder.Gender = Sim.Gender;

                        outfit.Apply(builder, false, null, null);

                        if (!replaced.ContainsKey(outfit.Category))
                        {
                            replaced.Add(outfit.Category, true);

                            CASParts.RemoveOutfits(Sim, outfit.Category, false);
                        }
                    }
                }

                if (Sim.CreatedSim != null)
                {
                    Sim.CreatedSim.UpdateOutfitInfo();

                    Sim.CreatedSim.RefreshCurrentOutfit(true);

                    SwitchOutfits.SwitchNoSpin(Sim.CreatedSim, new CASParts.Key(OutfitCategories.Everyday, 0));
                }
            }
            else
            {
                new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);
            }

            if (newSim.OccultManager.CurrentOccultTypes != OccultTypes.None)
            {
                if (Instantiation.PerformOffLot(Sim, Household.ActiveHousehold.LotHome, null) != null)
                {
                    List <OccultTypes> occults = OccultTypeHelper.CreateList(newSim, true);

                    foreach (OccultTypes occult in occults)
                    {
                        switch (occult)
                        {
                        case OccultTypes.Frankenstein:
                            Sim.TraitManager.AddElement(TraitNames.Brave);
                            Sim.TraitManager.AddElement(TraitNames.Hydrophobic);
                            break;
                        }
                    }

                    Sims.ApplyOccultChance(this, Sim, occults, 100, int.MaxValue);
                }

                if (Sim.GetOutfitCount(OutfitCategories.Everyday) > 1)
                {
                    Sim.RemoveOutfit(OutfitCategories.Everyday, 1, true);
                }

                SimOutfit currentOutfit = Sim.GetOutfit(OutfitCategories.Everyday, 0);
                if (currentOutfit != null)
                {
                    try
                    {
                        ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, Sim.AgeGenderSpecies);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(Sim, e);
                    }
                }
            }

            Deaths.CleansingKill(newSim, true);

            if (!result)
            {
                return(false);
            }

            if (Common.kDebugging)
            {
                Common.DebugNotify(GetTitlePrefix(PrefixType.Pure) + ": " + Sim.FullName, Sim.CreatedSim);
            }

            SpeedTrap.Sleep();

            return(true);
        }