Exemple #1
0
        public static Urnstone SimToPlayableGhost(SimDescription me, SimDescription.DeathType deathType)
        {
            Urnstone urnstone = FindGhostsGrave(me);

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

            if (!Inventories.TryToMove(urnstone, me.CreatedSim))
            {
                MoveToMausoleum(urnstone);
            }

            me.IsGhost = true;
            me.SetDeathStyle(deathType, true);

            if (me.CreatedSim != null)
            {
                urnstone.GhostSetup(me.CreatedSim, true);
                if (!me.IsEP11Bot)
                {
                    me.AgingEnabled = true;
                    me.PushAgingEnabledToAgingManager();
                }
            }

            return(urnstone);
        }
Exemple #2
0
        public static bool MoveToMausoleum(IMausoleum mausoleum, Urnstone urnstone)
        {
            bool bOriginalValue = mausoleum.Inventory.IgnoreInventoryValidation;

            try
            {
                mausoleum.Inventory.IgnoreInventoryValidation = true;

                if (Inventories.TryToMove(urnstone, mausoleum.Inventory))
                {
                    return(true);
                }
            }
            finally
            {
                mausoleum.Inventory.IgnoreInventoryValidation = bOriginalValue;
            }

            return(false);
        }
Exemple #3
0
        public static Terrarium Create(InsectJig ths, Sim actor)
        {
            Terrarium terrarium = Terrarium.Create(ths.InsectType);

            if (Inventories.TryToMove(terrarium, actor))
            {
                InsectData data;
                if (InsectData.sData.TryGetValue(ths.InsectType, out data))
                {
                    bool flag;
                    bool flag2;
                    (actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting).Collected(ths.InsectType, actor, terrarium, out flag, out flag2);

                    /*
                     * string str = CatchInsect.GetLocalizedCatchSuccessTNS(this.InsectType, data.Rarity, terrarium.Value, actor);
                     * string message = str;
                     * if (flag)
                     * {
                     *  string str3 = CatchInsect.LocalizeString(actor.IsFemale, "TNSScienceLab", new object[0]);
                     *  message = CatchInsect.LocalizeString(actor.IsFemale, "TNSFullPlusScienceLab", new object[] { str, str3 });
                     * }
                     * actor.ShowTNSIfSelectable(message, StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid);
                     * if (!flag2)
                     * {
                     *  actor.Play3dStingIfSelectable("sting_collect_collection");
                     * }
                     */

                    EventTracker.SendEvent(EventTypeId.kCaughtBug, actor, terrarium);
                    ActiveTopic.AddToSim(actor, "Recently Collected Bugs");
                }

                return(terrarium);
            }
            else
            {
                terrarium.Destroy();
                return(null);
            }
        }
Exemple #4
0
        public static Pregnancy Start(Sim woman, SimDescription man, bool handlePlantSim)
        {
            if (handlePlantSim)
            {
                if ((SimTypes.IsSelectable(woman)) || (SimTypes.IsSelectable(man)))
                {
                    if (woman.SimDescription.IsPlantSim || man.IsPlantSim)
                    {
                        IGameObject obj2 = GlobalFunctions.CreateObjectOutOfWorld("forbiddenFruit", ProductVersion.EP9, "Sims3.Gameplay.Objects.Gardening.ForbiddenFruit", null);
                        if (obj2 != null)
                        {
                            Inventories.TryToMove(obj2, woman);
                            Audio.StartSound("sting_baby_conception");
                        }

                        return(null);
                    }
                }
            }

            AgingManager.Singleton.CancelAgingAlarmsForSim(woman.SimDescription.AgingState);
            Pregnancy p = null;

            if (woman.IsHuman)
            {
                p = new Pregnancy(woman, man);
            }
            else
            {
                p = new PetPregnancy(woman, man);
            }

            p.PreggersAlarm = woman.AddAlarmRepeating(1f, TimeUnit.Hours, p.HourlyCallback, 1f, TimeUnit.Hours, "Hourly Pregnancy Update Alarm", AlarmType.AlwaysPersisted);
            woman.SimDescription.Pregnancy = p;

            EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kGotPregnant, woman, man.CreatedSim, p, null));
            return(p);
        }
Exemple #5
0
        // Lacks the "greater than eight" restriction
        public static bool GhostToPlayableGhost(Urnstone ths, Household newHousehold, Vector3 ghostPosition)
        {
            SimDescription simDescription = ths.DeadSimsDescription;

            if (!simDescription.IsValidDescription)
            {
                simDescription.Fixup();
            }

            if (simDescription.Household != null)
            {
                simDescription.Household.Remove(simDescription, !simDescription.Household.IsSpecialHousehold);
            }

            if (!newHousehold.Contains(simDescription))
            {
                newHousehold.Add(simDescription);
            }

            Sim ghost = Instantiation.Perform(simDescription, ghostPosition, null, null);

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

            ths.GhostSetup(ghost, true);

            ths.RemoveMourningRelatedBuffs(ghost);

            simDescription.ShowSocialsOnSim  = true;
            simDescription.IsNeverSelectable = false;
            simDescription.Marryable         = true;
            simDescription.Contactable       = true;

            if (!simDescription.IsEP11Bot)
            {
                simDescription.AgingEnabled = true;
                simDescription.AgingState.ResetAndExtendAgingStage(0f);
                simDescription.PushAgingEnabledToAgingManager();
            }

            string failureReason;

            if (!Inventories.TryToMove(ths, ghost.Inventory, true, out failureReason))
            {
                Common.DebugNotify(failureReason);
            }
            //Inventories.TryToMove(ths, ghost);

            if (simDescription.Child || simDescription.Teen)
            {
                simDescription.AssignSchool();
            }

            if (ghost.IsSelectable)
            {
                ghost.OnBecameSelectable();
            }

            return(true);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        protected static void Cleanup1 <TConsigned>(Logger log, string prefix, int maximumAge, ref Dictionary <ulong, List <TConsigned> > list)
            where TConsigned : ICancelSellableUIItem, ISellableUIItem, IShopItem
        {
            if (list == null)
            {
                list = new Dictionary <ulong, List <TConsigned> >();

                if (log != null)
                {
                    log(" " + prefix + ".sConsignedObjects Restarted");
                }
            }

            List <ulong> remove = new List <ulong>();

            foreach (KeyValuePair <ulong, List <TConsigned> > objects in list)
            {
                if ((objects.Value == null) || (objects.Value.Count == 0))
                {
                    remove.Add(objects.Key);
                }
                else
                {
                    SimDescription owner = null;

                    for (int i = objects.Value.Count - 1; i >= 0; i--)
                    {
                        TConsigned obj = objects.Value[i];

                        IGameObject consignedObj = null;
                        int         age          = 0;

                        if (obj is ConsignmentRegister.ConsignedObject)
                        {
                            ConsignmentRegister.ConsignedObject castObj = obj as ConsignmentRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is PotionShopConsignmentRegister.ConsignedObject)
                        {
                            PotionShopConsignmentRegister.ConsignedObject castObj = obj as PotionShopConsignmentRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is BotShopRegister.ConsignedObject)
                        {
                            BotShopRegister.ConsignedObject castObj = obj as BotShopRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is FruitVeggieStand.ConsignedObject)
                        {
                            FruitVeggieStand.ConsignedObject castObj = obj as FruitVeggieStand.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        try
                        {
                            if ((age < 0) || (age >= maximumAge))
                            {
                                if (owner == null)
                                {
                                    owner = SimDescription.Find(objects.Key);
                                }

                                bool success = false;
                                if (owner != null)
                                {
                                    if (owner.CreatedSim != null)
                                    {
                                        success = Inventories.TryToMove(consignedObj, owner.CreatedSim);
                                    }

                                    if ((!success) && (owner.Household != null) && (owner.Household.SharedFamilyInventory != null))
                                    {
                                        success = Inventories.TryToMove(consignedObj, owner.Household.SharedFamilyInventory.Inventory);
                                    }
                                }

                                if (!success)
                                {
                                    consignedObj.Destroy();

                                    if (log != null)
                                    {
                                        log(" Over Age Object deleted");
                                    }
                                }
                                else
                                {
                                    if (log != null)
                                    {
                                        log(" Over Age Object returned");
                                    }
                                }

                                objects.Value.RemoveAt(i);
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(consignedObj, e);
                        }
                    }
                }
            }

            foreach (ulong id in remove)
            {
                list.Remove(id);

                if (log != null)
                {
                    log(" Removed: " + id);
                }
            }
        }
Exemple #8
0
        public static void CreateSimInventories(List <SimDescription> sims, HouseholdContents contents, List <ulong> indexMap)
        {
            List <Sim> newborns = new List <Sim>();

            for (int i = 0x0; i < sims.Count; i++)
            {
                SimDescription description = sims[i];

                // Custom Try/Catch
                try
                {
                    if ((description != null) && (description.CreatedSim != null))
                    {
                        int index = i;
                        if (indexMap != null)
                        {
                            for (int j = 0x0; j < indexMap.Count; j++)
                            {
                                if (indexMap[j] == description.SimDescriptionId)
                                {
                                    index = j;
                                    break;
                                }
                            }
                        }
                        ulong id = contents.Inventories[index];
                        if (id != 0x0L)
                        {
                            Diploma diploma = description.CreatedSim.Inventory.Find <Diploma>();
                            if ((diploma != null) && !description.CreatedSim.Inventory.TryToRemove(diploma))
                            {
                                diploma = null;
                            }

                            IPhoneSmart smart = null;
                            if (GameUtils.IsInstalled(ProductVersion.EP9))
                            {
                                smart = description.CreatedSim.Inventory.Find <IPhoneSmart>();
                                if ((smart != null) && !description.CreatedSim.Inventory.TryToRemove(smart))
                                {
                                    smart = null;
                                }
                            }

                            DownloadContent.ImportInventory(id, new InventoryProxy(description.CreatedSim.Inventory));
                            DownloadContent.DeleteInventory(id);

                            if (diploma != null)
                            {
                                Inventories.TryToMove(diploma, description.CreatedSim.Inventory, false);
                            }

                            if (smart != null)
                            {
                                IPhoneCell cell = description.CreatedSim.Inventory.Find <IPhoneCell>();
                                if (cell != null)
                                {
                                    cell.Destroy();
                                }
                                description.CreatedSim.Inventory.TryToAdd(smart);
                            }
                        }
                        else
                        {
                            if (description.Toddler)
                            {
                                newborns.Add(description.CreatedSim);
                            }
                            description.CreatedSim.AddInitialObjects(false);
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(description, e);
                }
            }

            // Custom Try/Catch
            try
            {
                OccultImaginaryFriend.DeliverDollToHousehold(newborns, true);
            }
            catch (Exception e)
            {
                Common.Exception("DeliverDollToHousehold", e);
            }
        }