Exemplo n.º 1
0
            public override bool Run()
            {
                if (!Target.SetCoffinActive(true))
                {
                    return(false);
                }
                StandardEntry();

                bool createsimdesc = false; // custom


                SimDescription BonehildaDesc = null;

                if (Target.mBonehilda == null)
                {
                    Target.mBonehilda =
                        Instantiator.RootIsOpenDGSInstalled ?
                        Genetics.MakeSim(CASAgeGenderFlags.Adult, CASAgeGenderFlags.Female, GameUtils.GetCurrentWorld(), uint.MaxValue)
                        : null;

                    if (Target.mBonehilda == null)
                    {
                        BonehildaCoffin[] blist = NFinalizeDeath.SC_GetObjects <BonehildaCoffin>();

                        Household ActiveHousehold  = NFinalizeDeath.ActiveHousehold;
                        Household ActiveHouseholdX = Household.ActiveHousehold;

                        List <SimDescription> sSimDescriptionList = new List <SimDescription>();

                        //if (!Instantiator.RootIsOpenDGSInstalled)
                        //{
                        //    foreach (var item in NFinalizeDeath.TattoaX())
                        //    {
                        //        global::NiecMod.Helpers.Create.
                        //            AddNiecSimDescription(item);
                        //        Simulator.Sleep(0);
                        //    }
                        //}


                        int isleep = 0;

                        foreach (SimDescription item in NFinalizeDeath.UpdateNiecSimDescriptions(false, false, true))
                        {
                            if (item == null)
                            {
                                continue;
                            }



                            if (!item.mIsValidDescription)
                            {
                                continue;
                            }

                            if (item.IsPet)
                            {
                                continue;
                            }

                            if (Instantiator.RootIsOpenDGSInstalled && item.mSim != null)
                            {
                                continue;
                            }

                            isleep++;
                            if (isleep > 20)
                            {
                                isleep = 0;
                                Simulator.Sleep(0);
                            }


                            if (item.LotHome != null)
                            {
                                continue;
                            }

                            //if (item.Household == null)
                            //    continue;

                            if (item.mHousehold == ActiveHousehold)
                            {
                                continue;
                            }
                            if (item.mHousehold == ActiveHouseholdX)
                            {
                                continue;
                            }
                            if (NFinalizeDeath.FindBonehildaCoffinSimDesc(blist, item) != null)
                            {
                                continue;
                            }

                            if ((item.Service ?? item.CreatedByService) is GrimReaper)
                            {
                                continue;
                            }

                            if (item.TeenOrAbove)
                            {
                                sSimDescriptionList.Add(item);
                            }
                        }
                        if (sSimDescriptionList.Count > 0)
                        {
                            SimDescription simd = RandomUtil.GetRandomObjectFromList <SimDescription>(sSimDescriptionList, ListCollon.SafeRandom);
                            sSimDescriptionList.Clear();
                            if (simd != null)
                            {
                                Target.mBonehilda = simd;
                                simd.IsBonehilda  = true;
                            }
                        }

                        BonehildaDesc = Target.mBonehilda;

                        if (BonehildaDesc == null)
                        {
                            //EndCommodityUpdates(false);
                            Simulator.Sleep(10);
                            Target.SetCoffinActive(false);
                            StandardExit();
                            return(false);
                        }

                        if (BonehildaDesc.Household == null)
                        {
                            BonehildaDesc.IsGhost     = false;
                            BonehildaDesc.mDeathStyle = 0;

                            (Household.NpcHousehold ?? Actor.Household ?? Household.ActiveHousehold).Add(BonehildaDesc);
                        }
                    }
                    else
                    {
                        BonehildaDesc = Target.mBonehilda;

                        BonehildaDesc.Marryable        = false;
                        BonehildaDesc.CanBeKilledOnJob = false;
                        BonehildaDesc.AgingEnabled     = false;
                        BonehildaDesc.Contactable      = false;
                        BonehildaDesc.FirstName        = "Gameplay/Actors/Sim:BonehildaName"; //Localization.LocalizeString("Gameplay/Actors/Sim:BonehildaName");
                        BonehildaDesc.LastName         = "";
                        BonehildaDesc.TraitManager.RemoveAllElements();
                        BonehildaDesc.TraitManager.AddElement(TraitNames.Brave);
                        BonehildaDesc.TraitManager.AddElement(TraitNames.Neat);
                        BonehildaDesc.TraitManager.AddElement(TraitNames.Workaholic);
                        BonehildaDesc.TraitManager.AddElement(TraitNames.Athletic);
                        BonehildaDesc.TraitManager.AddElement(TraitNames.Perfectionist);
                        BonehildaDesc.TraitManager.AddHiddenElement(TraitNames.ImmuneToFire);
                        BonehildaDesc.VoiceVariation     = VoiceVariationType.B;
                        BonehildaDesc.VoicePitchModifier = 0f;

                        if (BonehildaDesc.Household == null)
                        {
                            (Household.NpcHousehold ?? Actor.Household ?? Household.ActiveHousehold).Add(BonehildaDesc);
                        }

                        createsimdesc = true;
                    }
                }


                BonehildaDesc = Target.mBonehilda;

                if (BonehildaDesc.Household == null)
                {
                    BonehildaDesc.IsGhost     = false;
                    BonehildaDesc.mDeathStyle = 0;

                    (Household.NpcHousehold ?? Actor.Household ?? Household.ActiveHousehold).Add(BonehildaDesc);
                }

                if (BonehildaDesc.CreatedSim == null)
                {
                    Target.mBonehildaSim = BonehildaDesc.Instantiate(Vector3.OutOfWorld, Instantiator.RootIsOpenDGSInstalled);
                }
                else
                {
                    Target.mBonehildaSim = BonehildaDesc.CreatedSim;
                }

                BonehildaDesc = null;

                if (Target.mBonehildaSim == null)
                {
                    Simulator.Sleep(10);
                    Target.SetCoffinActive(false);
                    StandardExit();
                    return(false);
                }

                Target.mBonehildaSim.GreetSimOnLot(Target.LotCurrent);

                if (!AssemblyCheckByNiec.IsInstalled("OpenDGS") && Target.mBonehildaSim.Inventory != null)
                {
                    Target.mBonehildaSim.Inventory.DestroyItems(true);
                }

                Target.mBonehildaSim.SetOpacity(0f, 0f);

                if (createsimdesc) // custom
                {
                    Target.SetUpBonehildaOutfit();
                }

                AcquireStateMachine("BonehildaAwaken");
                SetActor("x", Actor);
                SetActor("coffin", Target);
                EnterState("x", "Enter");
                BeginCommodityUpdates();
                AnimateSim("Exit_Awaken");
                bool ok = Target.SpawnBonehilda(); // custom

                EndCommodityUpdates(ok);
                StandardExit();
                return(ok);
            }