コード例 #1
0
ファイル: CASGeneticsEx.cs プロジェクト: yakoder/NRaas
        private static void OnAcceptButtonClick(WindowBase sender, UIButtonClickEventArgs args)
        {
            try
            {
                CASGenetics ths = CASGenetics.gSingleton;
                if (ths == null)
                {
                    return;
                }

                if (!ths.mHourglassVisible)
                {
                    args.Handled = true;
                    if (ths.mSelectedOffspring != null)
                    {
                        if (CASPuck.Instance != null)
                        {
                            ths.mReturnState = ths.mSelectedOffspring.IsPet ? CASState.PetSummary : CASState.Summary;

                            CASPuck.Instance.AttemptingToAdd = true;
                            CASPuck.ShowInputBlocker();
                            Responder.Instance.CASModel.RequestLoadSim(ths.mSelectedOffspring, false);
                            Responder.Instance.CASModel.RequestAddSimToHousehold(false);
                            Responder.Instance.CASModel.RequestClearStack();
                            CASController.Singleton.SetCurrentState(ths.mReturnState);
                        }
                        else
                        {
                            FacialBlends.CopyGenetics(ths.mSelectedOffspring as SimDescription, sChoice, false, false);

                            new SavedOutfit.Cache(sChoice).PropagateGenetics(sChoice, CASParts.sPrimary);

                            SimOutfit currentOutfit = sChoice.CreatedSim.CurrentOutfit;
                            if (currentOutfit != null)
                            {
                                ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sChoice.AgeGenderSpecies);
                            }

                            DestroyHousehold();

                            CASGenetics.Unload();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnAcceptButtonClick", e);
            }
        }
コード例 #2
0
        protected override bool Run(SimDescription a, SimDescription b)
        {
            if (!ApplyAll)
            {
                List <Item> choices = new List <Item>();

                foreach (Style style in Enum.GetValues(typeof(Style)))
                {
                    choices.Add(new Item(style));
                }

                Item choice = new CommonSelection <Item>(Name, choices).SelectSingle();
                if (choice == null)
                {
                    return(false);
                }

                mStyle = choice.Value;
            }

            bool onlyNonZero = false;
            bool onlySliders = false;

            switch (mStyle)
            {
            case Style.NonZero:
                onlyNonZero = true;
                onlySliders = false;
                break;

            case Style.NonZeroOnlySliders:
                onlyNonZero = true;
                onlySliders = true;
                break;

            case Style.OnlySliders:
                onlyNonZero = false;
                onlySliders = true;
                break;
            }

            FacialBlends.CopyGenetics(a, b, onlyNonZero, onlySliders);

            new SavedOutfit.Cache(b).PropagateGenetics(b, CASParts.sPrimary);

            return(true);
        }
コード例 #3
0
ファイル: GeneticBlendScenario.cs プロジェクト: yakoder/NRaas
        protected bool PrivatePerform(SimDescription a, SimDescription b, SimDescription priorBaby)
        {
            if ((priorBaby != null) && (RandomUtil.RandomChance(GetValue <ChanceOfIdenticalTwinOption, int>())))
            {
                FacialBlends.CopyGenetics(priorBaby, Sim, false, false);

                new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);

                IncStat("Identical");
                return(true);
            }
            else
            {
                List <SimDescription> parents = new List <SimDescription>();

                List <WorldName> worlds = new List <WorldName>();
                if (a != null)
                {
                    SimDescription sim = Relationships.GetSim(a.Genealogy);
                    if (sim != null)
                    {
                        parents.Add(sim);

                        worlds.Add(a.HomeWorld);
                    }
                }

                if (b != null)
                {
                    SimDescription sim = Relationships.GetSim(b.Genealogy);
                    if (sim != null)
                    {
                        parents.Add(sim);

                        worlds.Add(b.HomeWorld);
                    }
                }

                if (GetValue <SkinOption, bool>())
                {
                    AlterSkinBlend(this, Sim, parents);
                }

                if (parents.Count == 2)
                {
                    List <SimDescription> allParents = new List <SimDescription>(parents);
                    foreach (SimDescription parent in parents)
                    {
                        foreach (SimDescription grandParent in Relationships.GetParents(parent))
                        {
                            allParents.Add(grandParent);
                        }
                    }

                    BlendWings(allParents);

                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, CASParts.sPrimary))
                    {
                        builder.Builder.Species        = CASAgeGenderFlags.Human;
                        builder.Builder.UseCompression = true;

                        if (!builder.OutfitValid)
                        {
                            IncStat("Skin Blend: Outfit Fail");
                            return(false);
                        }
                        else
                        {
                            InheritFacialBlends(builder.Builder, parents, new Random());

                            builder.Builder.SkinToneIndex = Sim.SkinToneIndex;
                            builder.Builder.SkinTone      = Sim.SkinToneKey;
                        }
                    }

                    new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);

                    IncStat("Blended");
                    return(true);
                }
                else
                {
                    IncStat("Not Two");
                    return(false);
                }
            }
        }
コード例 #4
0
ファイル: ReplaceSimScenario.cs プロジェクト: yakoder/NRaas
        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);
        }