Exemple #1
0
            public CreationProtection(SimDescription sim, Sim createdSim, bool performLoadFixup, bool performSelectable, bool performUnselectable)
            {
                try
                {
                    mSim = sim;

                    Corrections.RemoveFreeStuffAlarm(sim);

                    // Stops an issue in "GrantFutureObjects" regarding the use of sIsChangingWorlds=true
                    mWasFutureSim = sim.TraitManager.HasElement(TraitNames.FutureSim);
                    sim.TraitManager.RemoveElement(TraitNames.FutureSim);

                    if (SimTypes.IsSelectable(mSim))
                    {
                        Corrections.CleanupBrokenSkills(mSim, null);
                    }

                    if (OpportunityTrackerModel.gSingleton != null)
                    {
                        mOpportunitiesChanged = OpportunityTrackerModel.gSingleton.OpportunitiesChanged;
                        OpportunityTrackerModel.gSingleton.OpportunitiesChanged = null;
                    }

                    if (mSim.TraitChipManager != null)
                    {
                        mChips = mSim.TraitChipManager.GetAllTraitChips();
                        mSim.TraitChipManager.mTraitChipSlots = new TraitChip[7];
                        mSim.TraitChipManager.mValues.Clear();
                    }

                    if (createdSim != null)
                    {
                        if (createdSim.BuffManager != null)
                        {
                            mBuffs = new List<BuffInstance>();

                            foreach (BuffInstance buff in createdSim.BuffManager.List)
                            {
                                mBuffs.Add(buff);
                            }
                        }

                        if (createdSim.Motives != null)
                        {
                            Motive motive = createdSim.Motives.GetMotive(CommodityKind.AcademicPerformance);
                            if (motive != null)
                            {
                                mAcademicPerformance = motive.Value;
                            }

                            motive = createdSim.Motives.GetMotive(CommodityKind.UniversityStudy);
                            if (motive != null)
                            {
                                mUniversityStudy = motive.Value;
                            }
                        }

                        if (createdSim.Inventory != null)
                        {
                            mInventory = createdSim.Inventory.DestroyInventoryAndStoreInList();
                        }

                        mDreamStore = new DreamCatcher.DreamStore(createdSim, false, false);

                        mReservedVehicle = createdSim.GetReservedVehicle();
                        createdSim.ReservedVehicle = null;
                    }

                    SafeStore.Flag flags = SafeStore.Flag.None;

                    if (performSelectable)
                    {
                        flags |= SafeStore.Flag.Selectable;
                    }

                    if (performLoadFixup)
                    {
                        flags |= SafeStore.Flag.LoadFixup;
                    }

                    if (performUnselectable)
                    {
                        flags |= SafeStore.Flag.Unselectable;
                    }

                    mSafeStore = new SafeStore(mSim, flags);

                    // Stops the startup errors when the imaginary friend is broken
                    mDoll = GetDollForSim(sim);
                    if (mDoll != null)
                    {
                        mDoll.mOwner = null;
                    }

                    mGenealogy = sim.mGenealogy;

                    mRelations = Relationships.StoreRelations(sim, null);

                    // Stops all event processing during the creation process
                    EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = true;

                    // Stops the interface from updating during OnCreation
                    if (sim.Household != null)
                    {
                        mChangedCallback = sim.Household.HouseholdSimsChanged;
                        mChangedHousehold = sim.Household;

                        sim.Household.HouseholdSimsChanged = null;
                    }

                    sChangingWorldsSuppression.Push();

                    // Stops SetGeneologyRelationshipBits()
                    sim.mGenealogy = new Genealogy(sim);
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("RepairImaginaryFriends");

            Trait trait;
            if (TraitManager.sDictionary.TryGetValue((ulong)TraitNames.ImaginaryFriendHiddenTrait, out trait))
            {
                trait.mNonPersistableData.mCanBeLearnedRandomly = false;
            }

            foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects<ImaginaryDoll>())
            {
                if (doll.mLiveStateSimDescId == 0) continue;

                if (doll.GetLiveFormSimDescription() != null) continue;

                doll.CreateLiveStateForm();

                Overwatch.Log("Missing Imaginary Doll Repaired");
            }

            foreach (SimDescription sim in Households.All(Household.NpcHousehold))
            {
                if (sim.OccultManager == null) continue;

                OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;
                if (occult == null) continue;

                Overwatch.Log(sim.FullName);

                if (occult.IsReal) continue;

                SimDescription owner = SimDescription.Find(occult.OwnerSimDescriptionId);
                if (owner == null) continue;

                if (owner.LotHome == null) continue;

                IScriptProxy proxy = Simulator.GetProxy(occult.mDollId);
                if (proxy == null)
                {
                    IGameObject obj = GlobalFunctions.CreateObjectOutOfWorld("ImaginaryFriendDoll", ProductVersion.EP4);
                    if (obj != null)
                    {
                        ImaginaryDoll doll = obj as ImaginaryDoll;
                        if (doll == null)
                        {
                            obj.Destroy();
                        }
                        else
                        {
                            occult.UpdateDollGuid(obj.ObjectId);

                            doll.SetOwner(owner);

                            doll.mLiveStateSimDescId = sim.SimDescriptionId;
                            doll.mIsFemale = sim.IsFemale;
                            doll.mGenderSet = true;
                            doll.EstablishState(ImaginaryDoll.OwnershipState.Live);

                            Sim ownerSim = owner.CreatedSim;
                            if (ownerSim != null)
                            {
                                if (Inventories.TryToMove(obj, ownerSim))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Sim Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                            else
                            {
                                if (Inventories.TryToMove(obj, ownerSim.Household.SharedFamilyInventory.Inventory))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Family Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
            public CreationProtection(SimDescription sim, Sim createdSim, bool performLoadFixup, bool performSelectable, bool performUnselectable)
            {
                try
                {
                    mSim = sim;

                    Corrections.RemoveFreeStuffAlarm(sim);

                    // Stops an issue in "GrantFutureObjects" regarding the use of sIsChangingWorlds=true
                    mWasFutureSim = sim.TraitManager.HasElement(TraitNames.FutureSim);
                    sim.TraitManager.RemoveElement(TraitNames.FutureSim);

                    if (SimTypes.IsSelectable(mSim))
                    {
                        Corrections.CleanupBrokenSkills(mSim, null);
                    }

                    if (OpportunityTrackerModel.gSingleton != null)
                    {
                        mOpportunitiesChanged = OpportunityTrackerModel.gSingleton.OpportunitiesChanged;
                        OpportunityTrackerModel.gSingleton.OpportunitiesChanged = null;
                    }

                    if (mSim.TraitChipManager != null)
                    {
                        mChips = mSim.TraitChipManager.GetAllTraitChips();
                        mSim.TraitChipManager.mTraitChipSlots = new TraitChip[7];
                        mSim.TraitChipManager.mValues.Clear();
                    }

                    if (createdSim != null)
                    {
                        if (createdSim.BuffManager != null)
                        {
                            mBuffs = new List <BuffInstance>();

                            foreach (BuffInstance buff in createdSim.BuffManager.List)
                            {
                                mBuffs.Add(buff);
                            }
                        }

                        if (createdSim.Motives != null)
                        {
                            Motive motive = createdSim.Motives.GetMotive(CommodityKind.AcademicPerformance);
                            if (motive != null)
                            {
                                mAcademicPerformance = motive.Value;
                            }

                            motive = createdSim.Motives.GetMotive(CommodityKind.UniversityStudy);
                            if (motive != null)
                            {
                                mUniversityStudy = motive.Value;
                            }
                        }

                        if (createdSim.Inventory != null)
                        {
                            mInventory = createdSim.Inventory.DestroyInventoryAndStoreInList();
                        }

                        mDreamStore = new DreamCatcher.DreamStore(createdSim, false, false);

                        mReservedVehicle           = createdSim.GetReservedVehicle();
                        createdSim.ReservedVehicle = null;
                    }

                    SafeStore.Flag flags = SafeStore.Flag.None;

                    if (performSelectable)
                    {
                        flags |= SafeStore.Flag.Selectable;
                    }

                    if (performLoadFixup)
                    {
                        flags |= SafeStore.Flag.LoadFixup;
                    }

                    if (performUnselectable)
                    {
                        flags |= SafeStore.Flag.Unselectable;
                    }

                    mSafeStore = new SafeStore(mSim, flags);

                    // Stops the startup errors when the imaginary friend is broken
                    mDoll = GetDollForSim(sim);
                    if (mDoll != null)
                    {
                        mDoll.mOwner = null;
                    }

                    mGenealogy = sim.mGenealogy;

                    mRelations = Relationships.StoreRelations(sim, null);

                    // Stops all event processing during the creation process
                    EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = true;

                    // Stops the interface from updating during OnCreation
                    if (sim.Household != null)
                    {
                        mChangedCallback  = sim.Household.HouseholdSimsChanged;
                        mChangedHousehold = sim.Household;

                        sim.Household.HouseholdSimsChanged = null;
                    }

                    sChangingWorldsSuppression.Push();

                    // Stops SetGeneologyRelationshipBits()
                    sim.mGenealogy = new Genealogy(sim);
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }
Exemple #4
0
        public override bool Run()
        {
            Common.StringBuilder msg = new Common.StringBuilder(Common.LocalizeEAString("SimInteractions/DebugInteraction:WhoAmI"));

            msg += Common.NewLine + Target.GetType();

            try
            {
                msg += Common.NewLine + Common.NewLine;

                Common.StringBuilder noticeText = new Common.StringBuilder();
                Common.StringBuilder logText    = new Common.StringBuilder();
                Common.LoadLogger.Convert(Target, noticeText, logText);

                msg += logText;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, msg, exception);
            }

            try
            {
                if (Target.mObjComponents != null)
                {
                    msg += Common.NewLine + "mObjComponents";

                    foreach (ObjectComponent component in Target.mObjComponents)
                    {
                        msg += Common.NewLine + component.GetType();

                        msg += ComponentToString(component);
                    }
                }
                else
                {
                    msg += Common.NewLine + "mObjComponents: <null>";
                }

                if (Target.ActorsUsingMe != null)
                {
                    foreach (Sim sim in Target.ActorsUsingMe)
                    {
                        msg += Common.NewLine + "ActorsUsingMe: " + ((sim != null) ? sim.FullName : "null");
                    }
                }
                else
                {
                    msg += Common.NewLine + "ActorsUsingMe: <null>";
                }

                if (Target.RoutingReferenceList != null)
                {
                    foreach (Sim sim in Target.RoutingReferenceList)
                    {
                        msg += Common.NewLine + "RoutingReferenceList: " + ((sim != null) ? sim.FullName : "null");
                    }
                }
                else
                {
                    msg += Common.NewLine + "RoutingReferenceList: <null>";
                }

                if (Target.ReferenceList != null)
                {
                    foreach (Sim sim in Target.ReferenceList)
                    {
                        msg += Common.NewLine + "ReferenceList: " + ((sim != null) ? sim.FullName : "null");
                    }
                }
                else
                {
                    msg += Common.NewLine + "ReferenceList: <null>";
                }

                if (Target is ImaginaryDoll)
                {
                    ImaginaryDoll target = Target as ImaginaryDoll;

                    msg += Common.NewLine + "Gender Set: " + target.mGenderSet;
                    msg += Common.NewLine + "Is Female: " + target.mIsFemale;
                    msg += Common.NewLine + "Live State Id: " + target.mLiveStateSimDescId;
                    msg += Common.NewLine + "Days Since Reminder: " + target.mDaysSinceRemindingPlayerToLetDollTurnLive;
                    if (target.mOwner != null)
                    {
                        msg += Common.NewLine + "Owner: " + target.mOwner.FullName;
                    }
                    msg += Common.NewLine + "Relationship: " + target.mRelationship;
                    msg += Common.NewLine + "OwnershipState: " + target.mOwnershipState;
                    msg += Common.NewLine + "Start Neglect: " + target.mStartTimeOfNeglect;
                }
                else if (Target is Fish)
                {
                    Fish target = Target as Fish;

                    msg += Common.NewLine + "Fish Type: " + target.mFishType;
                    msg += Common.NewLine + "Fish Data: " + target.mData;
                }
                else if (Target is MountedFish)
                {
                    MountedFish target = Target as MountedFish;

                    msg += Common.NewLine + "Fish: " + target.mFish;
                    if (target.mFish != null)
                    {
                        msg += Common.NewLine + "Type: " + target.mFish.GetType();
                        msg += Common.NewLine + "Type: " + target.mFish.mFishType;
                        msg += Common.NewLine + "Data: " + target.mFish.Data;
                    }
                }
                else if (Target is Door)
                {
                    Door door = Target as Door;

                    msg += Common.NewLine + "mEventCounter: " + door.mEventCounter;
                    msg += Common.NewLine + "mIsNPCDoor: " + door.mIsNPCDoor;

                    uint numDoors = (uint)door.GetNumDoors();
                    for (uint i = 0; i < numDoors; i++)
                    {
                        msg += Common.NewLine + "Index: " + i;
                        msg += Common.NewLine + "State: " + door.GetDoorState(i);
                    }

                    if (door.mDoorOpenStates != null)
                    {
                        foreach (Door.DoorOpenState state in door.mDoorOpenStates)
                        {
                            msg += Common.NewLine + "mAlarm: " + state.mAlarm;
                            msg += Common.NewLine + "mFirstSideOpened: " + state.mFirstSideOpened;
                            msg += Common.NewLine + "mUseCount: " + state.mUseCount;
                        }
                    }
                    else
                    {
                        msg += Common.NewLine + "mDoorOpenStates: null";
                    }

                    if (door.mEventListDictionary != null)
                    {
                        foreach (KeyValuePair <DoorEvent.tEventType, List <DoorEvent> > pair in door.mEventListDictionary)
                        {
                            msg += Common.NewLine + "tEventType: " + pair.Key;

                            foreach (DoorEvent ev in pair.Value)
                            {
                                msg += Common.NewLine + " mDoorIndex: " + ev.mDoorIndex;
                                msg += Common.NewLine + " mDoorObjId: " + ev.mDoorObjId;
                                msg += Common.NewLine + " mDoorSide: " + ev.mDoorSide;
                                msg += Common.NewLine + " mLocalIndex: " + ev.mLocalIndex;
                                msg += Common.NewLine + " mSenderObjId: " + ev.mSenderObjId;
                                msg += Common.NewLine + " mType: " + ev.mType;
                            }
                        }
                    }
                    else
                    {
                        msg += Common.NewLine + "mEventListDictionary: null";
                    }
                }
                else if (Target is Sim)
                {
                }

                Common.Notify(msg);
                Common.WriteLog(msg);
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, msg, exception);
            }
            return(true);
        }