コード例 #1
0
ファイル: Urnstones.cs プロジェクト: yakoder/NRaas
        public static Urnstone CreateGrave(SimDescription me, SimDescription.DeathType deathType, bool ignoreExisting, bool report)
        {
            Urnstone urnstone = FindGhostsGrave(me);

            if ((urnstone != null) && (!ignoreExisting))
            {
                if ((urnstone.InInventory) || (urnstone.InWorld))
                {
                    return(urnstone);
                }
            }

            Household originalHousehold = me.Household;

            bool addOnly = false;

            if (urnstone == null)
            {
                urnstone = PrivateCreateGrave(me);
                if (urnstone == null)
                {
                    return(null);
                }
            }
            else
            {
                addOnly = true;
            }

            bool success = MoveToMausoleum(urnstone);

            if (!success)
            {
                if (me.CreatedSim != null)
                {
                    if (Inventories.TryToMove(urnstone, me.CreatedSim.Inventory))
                    {
                        success = true;
                    }
                }

                if ((!success) && (Sim.ActiveActor != null))
                {
                    if (Inventories.TryToMove(urnstone, Sim.ActiveActor.Inventory))
                    {
                        success = true;
                    }
                }

                if (!success)
                {
                    return(null);
                }
            }

            if (report)
            {
                Common.Notify(Common.Localize("ForceKill:Success", me.IsFemale, new object[] { me }));
            }

            if ((addOnly) && (!ignoreExisting))
            {
                return(urnstone);
            }

            if ((originalHousehold == Household.ActiveHousehold) && (me.CreatedSim != null))
            {
                HudModel model = HudController.Instance.Model as HudModel;

                foreach (SimInfo info in model.mSimList)
                {
                    if (info.mGuid == me.CreatedSim.ObjectId)
                    {
                        model.RemoveSimInfo(info);
                        model.mSimList.Remove(info);
                        break;
                    }
                }
            }

            if (me.CreatedSim != null)
            {
                me.CreatedSim.Destroy();
            }

            if (originalHousehold != null)
            {
                originalHousehold.Remove(me, !originalHousehold.IsSpecialHousehold);
            }

            if (me.DeathStyle == SimDescription.DeathType.None)
            {
                if (me.IsHuman)
                {
                    switch (deathType)
                    {
                    case SimDescription.DeathType.None:
                    case SimDescription.DeathType.PetOldAgeBad:
                    case SimDescription.DeathType.PetOldAgeGood:
                        deathType = SimDescription.DeathType.OldAge;
                        break;
                    }
                }
                else
                {
                    switch (deathType)
                    {
                    case SimDescription.DeathType.None:
                    case SimDescription.DeathType.OldAge:
                        deathType = SimDescription.DeathType.PetOldAgeGood;
                        break;
                    }
                }

                me.SetDeathStyle(deathType, true);
            }

            me.IsNeverSelectable = true;
            me.Contactable       = false;
            me.Marryable         = false;

            if (me.CreatedSim == PlumbBob.SelectedActor)
            {
                LotManager.SelectNextSim();
            }

            if (me.CareerManager != null)
            {
                me.CareerManager.LeaveAllJobs(Sims3.Gameplay.Careers.Career.LeaveJobReason.kDied);
            }

            urnstone.OnHandToolMovement();
            Urnstone.FinalizeSimDeath(me, originalHousehold);
            int num = ((int)Math.Floor((double)SimClock.ConvertFromTicks(SimClock.CurrentTime().Ticks, TimeUnit.Minutes))) % 60;

            urnstone.MinuteOfDeath = num;

            return(urnstone);
        }