Example #1
0
        public static void UnloadCargo(bool force)
        {
            if (_mCargo == null)
            {
                NFinalizeDeath.Assert("UnloadCargo: _mCargo is null.");
                return;
            }

            if (force || GameStates.IsTravelling)
            {
                foreach (FieldInfo item in new List <FieldInfo>(_mCargo.Keys))
                {
                    if (item == null)
                    {
                        continue;
                    }

                    try
                    {
                        item.SetValue(null, _mCargo[item]);
                    }
                    catch (Exception)
                    {
                        niec_native_func.OutputDebugString("Failed to SetValue() Type: " + typeof(T).ToString() + " | T: " + item.FieldType + " | Name: " + item.Name);
                    }

                    _mCargo[item] = null;
                }
            }
        }
Example #2
0
        public static bool niecmod_script_set_custom_native_function2(MethodInfo internal_function, uint p_func_address)
        {
            if (NFinalizeDeath.GameIs64Bit(false))
            {
                return(false);
            }
#if GameVersion_0_Release_2_0_209
            var vfunc = internal_function as MonoMethod;
            if (vfunc == null)
            {
                return(false);
            }

            if (vfunc.mhandle == emtpyptr)
            {
                return(false);
            }

            uint func_address = ((uint)vfunc.mhandle.ToInt32()) + 0x20u;
            global::System.Runtime.InteropServices.Marshal.WriteInt32(new IntPtr((int)func_address), (int)p_func_address);
            return(true);
#else
            return(false);
#endif // GameVersion_0_Release_2_0_209
        }
Example #3
0
        public static object GetFuncNROnErrorTrap()
        {
            var p = Type.GetType("NRaas.ErrorTrap, NRaasErrorTrap");

            if (p == null)
            {
                return(null);
            }

            var r = (MethodInfo)NFinalizeDeath.GetGoodMethods(
                p,
                new Type[] { typeof(ScriptCore.ScriptProxy), typeof(Exception) },
                "OnScriptError",
                BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic
                );

            if (r == null)
            {
                return(null);
            }

            // Required if no create method pointer.
            Delegate.CreateDelegate(typeof(SCOSR._SafeScriptError), r);

            return(r);
        }
Example #4
0
        public unsafe static IntPtr niecmod_script_get_type_ptr2 <T>()
        {
            if (NFinalizeDeath.GameIs64Bit(false))
            {
                return(new IntPtr(0));
            }
#if GameVersion_0_Release_2_0_209
            var type = typeof(T);
            if (type == null || type._impl.value == null)
            {
                return(new IntPtr(0));
            }

            uint t = *(uint *)((uint)type._impl.value + 0x18);
            if (t == 0x00000000) // not created
            {
                return(new IntPtr(0));
            }

            uint y = *(uint *)(t + 0x4);

            if (y == 0xFFFF0000)
            {
                return(new IntPtr(0));
            }

            return(new IntPtr()
            {
                value = (void *)y
            });
#else
            return(new IntPtr(0));
#endif
        }
Example #5
0
        public static uint niecmod_script_get_func_ptr2(MethodInfo internal_function)
        {
            if (NFinalizeDeath.GameIs64Bit(false))
            {
                return(0);
            }
#if GameVersion_0_Release_2_0_209
            var vfunc = internal_function as MonoMethod;
            if (vfunc == null)
            {
                return(0);
            }

            if (vfunc.mhandle == emtpyptr)
            {
                return(0);
            }

            uint func_address = ((uint)vfunc.mhandle.ToInt32()) + 0x20u;

            try
            {
                return((uint)global::System.Runtime.InteropServices.Marshal.ReadInt32(new IntPtr((int)func_address)));
            }
            catch (NullReferenceException)
            {
                return(0);
            }
#else
            return(0);
#endif // GameVersion_0_Release_2_0_209
        }
Example #6
0
        public unsafe static uint niecmod_safecall_script_get_func_ptr(IntPtr funcHandle)
        {
            if (NFinalizeDeath.GameIs64Bit(false))
            {
                return(0);
            }

#if GameVersion_0_Release_2_0_209
            if (funcHandle.value == null)
            {
                return(0);
            }

            uint r = 0;

            NFinalizeDeath.SafeCall(() =>
            {
                r = *(uint *)((uint)funcHandle.value) + 0x20u;
            });

            return(r);
#else
            return(0);
#endif // GameVersion_0_Release_2_0_209
        }
Example #7
0
        void PrintMessagePro(string Message, bool NoNiecModText, float TimeOut) // Bypass if (Responder.Instance.TutorialModel.IsTutorialRunning())
        {
            try
            {
                niec_native_func.OutputDebugString("NMPrint: " + Message);

                if (NotificationManager.sNotificationManager == null)
                {
                    return;
                }
                StyledNotification.Format format =
                    (!NoNiecModText) ? new StyledNotification.Format("NiecMod\n" + (Message == "" ? "No Message" : Message ?? "No Message"), StyledNotification.NotificationStyle.kGameMessagePositive)
                    : new StyledNotification.Format((Message == "" ? "No Message" : Message ?? "No Message"), StyledNotification.NotificationStyle.kGameMessagePositive);

                format.mConnectionType = StyledNotification.ConnectionType.kSpeech;
                format.mTNSCategory    =
                    Instantiator.RootIsOpenDGSInstalled ?
                    NotificationManager.TNSCategory.Information
                    : NotificationManager.TNSCategory.Store;


                StyledNotification styledNotification = new StyledNotification(format, TimeOut, null, null, ProductVersion.BaseGame, ProductVersion.BaseGame);
                NFinalizeDeath.StyledNotification__Add(NotificationManager.sNotificationManager, styledNotification, format.mTNSCategory);
            }
            catch
            { }
        }
Example #8
0
        public static object niecmod_script_get_obj_adderess(object obj)
        {
            bool gameIs64 = NFinalizeDeath.GameIs64Bit(false);

            try
            {
                throw new Exception("");
            }
            catch (Exception ex)
            {
                var s  = "niecmod_script_get_obj_adderess (object) ([";
                var st = ex.StackTrace;
                if (st == null || st.Length == 0)
                {
                    return(0);
                }

                int index = st.IndexOf(s);
                if (index == -1)
                {
                    return(0);
                }

                if ((index + s.Length) > st.length - (gameIs64 ? 16 : 8))
                {
                    return(0);
                }

                return(gameIs64 ?
                       ulong.Parse(st.Substring(index + s.Length, 16) ?? "0", System.Globalization.NumberStyles.AllowHexSpecifier) :
                       uint.Parse(st.Substring(index + s.Length, 8) ?? "0", System.Globalization.NumberStyles.AllowHexSpecifier));
            }
        }
Example #9
0
            public override void PopulatePieMenuPicker(ref InteractionInstanceParameters parameters, out List <ObjectPicker.TabInfo> listObjs, out List <ObjectPicker.HeaderInfo> headers, out int NumSelectableRows)
            {
                NumSelectableRows = 1;
                Sim        actor = parameters.Target as Sim;
                List <Sim> sims  = new List <Sim>();

                if (actor.LotCurrent != null)
                {
                    foreach (Sim sim in NFinalizeDeath.SC_GetObjectsOnLot <Sim>(actor.LotCurrent))
                    {
                        if (sim.mSimDescription == null || sim.mSimDescription.mOutfits == null)
                        {
                            continue;
                        }
                        sims.Add(sim);
                    }
                }

                try
                {
                    base.PopulateSimPicker(ref parameters, out listObjs, out headers, sims, true);
                    return;
                }
                catch (ResetException)
                { throw; }
                catch (Exception)
                {  }
                listObjs = new List <ObjectPicker.TabInfo>();
                headers  = new List <ObjectPicker.HeaderInfo>();
            }
Example #10
0
        public override bool Run() // Run
        {
            if (Autonomous || Actor.IsNPC || !Actor.IsInActiveHousehold)
            {
                return(false);
            }
            if (!NFinalizeDeath.CheckAccept("Are You Sure All Pause?"))
            {
                return(false);
            }
            List <Sim> list = new List <Sim>();

            foreach (Sim sim in NFinalizeDeath.SC_GetObjects <Sim>())
            {
                if (!sim.IsInActiveHousehold && !(sim.Service is GrimReaper))
                {
                    list.Add(sim);
                }
            }
            if (list.Count > 0)
            {
                foreach (Sim nlist in list)
                {
                    try
                    {
                        nlist.EnableInteractions();
                        nlist.InteractionQueue.Add(AllPauseNiecDone.Singleton.CreateInstance(nlist, nlist, new InteractionPriority((InteractionPriorityLevel)999, 999f), isAutonomous: false, cancellableByPlayer: false));
                    }
                    catch (Exception exception)
                    {
                        NiecException.PrintMessage(exception.Message + NiecException.NewLine + exception.StackTrace);
                        try
                        {
                            nlist.InteractionQueue.CancelAllInteractions();
                        }
                        catch
                        { }
                        return(true);
                    }

                    /*
                     * finally
                     * {
                     * try
                     * {
                     *  nlist.InteractionQueue.CancelAllInteractions();
                     * }
                     * catch (Exception exception)
                     * {
                     *  NiecException.PrintMessage(exception.Message + NiecException.NewLine + exception.StackTrace);
                     *  nlist.EnableInteractions();
                     *  nlist.InteractionQueue.Add(AllPauseNiecDone.Singleton.CreateInstance(nlist, nlist, new InteractionPriority((InteractionPriorityLevel)999, 999f), isAutonomous: false, cancellableByPlayer: false));
                     * }
                     * }
                     * */
                }
            }
            return(true);
        }
Example #11
0
 public static uint niecmod_script_get_str_data_address(string str)
 {
     if (NFinalizeDeath.GameIs64Bit(false))
     {
         return(0);
     }
     return((uint)str.obj_address() + (uint)System.Runtime.CompilerServices.RuntimeHelpers.OffsetToStringData);
 }
Example #12
0
 public static void _CleanUp()
 {
     if (runI)
     {
         return;
     }
     NFinalizeDeath.Household_CleanUp();
 }
Example #13
0
        public static void InitClass()
        {
            var p = GetStatic();

            NFinalizeDeath.M(p.IsNSufficientlyOnScreenForHighLODSimulation);
            NFinalizeDeath.M(p.IsNRunningHighLODSimulation);
            NFinalizeDeath.M(p.NShouldRunLocalAutonomy);
        }
Example #14
0
        public static void InitClass()
        {
            var g = GetStatic();

            runI = true;
            NFinalizeDeath.M(g.NAllSimDescriptions);
            _CleanUp();
            runI = false;
        }
Example #15
0
        private static ListenerAction OnObjectChanged(Event e)
        {
            var o = e.TargetObject;

            if (o is Computer || o is CityHall)
            {
                NFinalizeDeath.GO_AddInteraction(o as GameObject, NiecMod.Interactions.Objects.NRCODImmediateInteraction.Singleton, true);
            }
            return(ListenerAction.Keep);
        }
Example #16
0
 public static void NRUrnstones_CreateGrave(SimDescription me, SimDescription.DeathType deathType, bool ignoreExisting, bool report)
 {
     //if (!isnraasloaded) { NFinalizeDeath.GetKillNPCSimToGhost(me.CreatedSim, deathType); return; }
     //NiecNraTask.NraFunction temp = delegate {
     //    Urnstones.CreateGrave(me, deathType, ignoreExisting, report);
     //};
     //// Delegate sdfsde = temp as Delegate;
     ////Delegate.Remove(temp, sdfsde);
     //temp();
     NFinalizeDeath.GetKillNPCSimToGhost(me.CreatedSim, deathType);
 }
Example #17
0
 public static uint niecmod_script_str_safe_maxaddress(string str)
 {
     if (NFinalizeDeath.GameIs64Bit(false))
     {
         throw new InvalidOperationException("Sims 3 (64 bit)!");
     }
     if (str.Length == 0)
     {
         throw new ArgumentException();
     }
     return((uint)((niecmod_script_get_str_data_address(str) + (uint)(str.Length * 2)) - System.Runtime.CompilerServices.RuntimeHelpers.OffsetToStringData));
 }
Example #18
0
            public override bool Run()
            {
                try
                {
                    if (!Target.SetCoffinActive(isActive: false))
                    {
                        return(false);
                    }

                    StandardEntry();

                    AcquireStateMachine("BonehildaAwaken");
                    SetActor("x", Actor);
                    SetActor("coffin", Target);

                    EnterState("x", "Enter");

                    BeginCommodityUpdates();
                    AnimateSim("Exit_Dismiss");

                    bool ok = ___ReturnBonehildaToCoffin(Target); // custom

                    Actor.LoopIdle();
                    for (int i = 0; i < 25; i++)
                    {
                        Simulator.Sleep(0);
                    }

                    EndCommodityUpdates(succeeded: ok);
                    StandardExit();
                    return(ok);
                }
                catch (ResetException) { throw; }
                catch (Exception)
                {
                    if (Target != null && Target.mBonehildaSim != null)
                    {
                        NFinalizeDeath.ForceDestroyObject(Target.mBonehildaSim);
                        Target.mBonehildaSim = null;
                        //throw new ArgumentException("None", ex);
                    }
                    return(true);
                }
                finally
                {
                    if (Target != null && Target.mBonehildaSim != null && Target.mBonehildaSim.InteractionQueue != null && !Target.mBonehildaSim.InteractionQueue.HasInteractionOfType(BonehildaCoffin.BonehildaReturnToCoffin.Singleton))
                    {
                        NFinalizeDeath.ForceDestroyObject(Target.mBonehildaSim);
                        Target.mBonehildaSim = null;
                    }
                }
            }
Example #19
0
        private static void OnObjectPlacedInLot(object sender, EventArgs e)
        {
            var args = e as World.OnObjectPlacedInLotEventArgs;

            if (args != null)
            {
                var gameObject = NFinalizeDeath.GetObject_internalFast(args.ObjectId.mValue);
                if (gameObject is Computer || gameObject is CityHall)
                {
                    NFinalizeDeath.GO_AddInteraction(gameObject, NiecMod.Interactions.Objects.NRCODImmediateInteraction.Singleton, true);
                }
            }
        }
Example #20
0
            public bool ___ReturnBonehildaToCoffin(BonehildaCoffin target)
            {
                if (target == null || target.mBonehildaSim == null)  // custom
                {
                    return(false);
                }
                InteractionQueue tInteractionQueue = target.mBonehildaSim.InteractionQueue;

                if (tInteractionQueue != null && !tInteractionQueue.HasInteractionOfType(BonehildaCoffin.BonehildaReturnToCoffin.Singleton))
                {
                    Sim targetsim = target.mBonehildaSim;

                    try
                    {
                        tInteractionQueue.CancelAllInteractions();
                    }
                    catch (Exception)
                    {
                        NFinalizeDeath.ForceCancelAllInteractionsWithoutCleanup(targetsim);
                        NFinalizeDeath.ForceDestroyObject(targetsim);

                        target.mBonehildaSim = null;

                        return(true);
                    }

                    targetsim = target.mBonehildaSim;

                    if (targetsim == null || targetsim.SimDescription == null || targetsim.HasBeenDestroyed)
                    {
                        target.mBonehildaSim = null;
                        return(true);
                    }

                    var entry =
                        BonehildaCoffin.BonehildaReturnToCoffin
                        .Singleton.CreateInstance(target, targetsim,
                                                  new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior),
                                                  isAutonomous: false,
                                                  cancellableByPlayer: true)
                        as BonehildaCoffin.BonehildaReturnToCoffin;

                    tInteractionQueue.AddNext(entry);
                }
                if (tInteractionQueue == null)
                {
                    target.mBonehildaSim = null;
                }
                return(true);
            }
Example #21
0
 private void XPruneSelectedObjects()
 {
     if (mSelectedObjects == null || mSelectedObjects.Count == 0)
     {
         return;
     }
     for (int num = mSelectedObjects.Count - 1; num >= 0; num--)
     {
         GameObject gameObject = mSelectedObjects[num] as GameObject;
         if (gameObject != null && !NFinalizeDeath.GameObjectIsValid(gameObject.ObjectId.mValue))
         {
             niec_std.list_remove(mSelectedObjects, gameObject);
         }
     }
 }
Example #22
0
 public static bool sAcceptCancelDialogWithoutCommonException(string message)
 {
     try
     {
         throw new NiecModException("AcceptCancelDialogWithoutCommonException: Not Error");
     }
     catch (ResetException)
     {
         throw;
     }
     catch (NiecModException ex)
     {
         WriteLog("AcceptCancelDialogWithoutCommonException: " + NiecException.NewLine + NiecException.LogException(ex), true, true, false);
     }
     return(NFinalizeDeath.CheckAccept(message));
 }
Example #23
0
        public static Lot GetCameraTargetLot()
        {
            if (LotManager.sLots == null)
            {
                return(LotManager.sActiveLot ?? LotManager.sWorldLot);
            }
            LotLocation LotLocation = default(LotLocation);
            ulong       Location    = World.GetLotLocation(NFinalizeDeath.Fast_SnapToFloor(ScriptCore.CameraController.Camera_GetTarget()), ref LotLocation);
            Lot         TargetLot   = LotManager.GetLot(Location);

            if (TargetLot == null)
            {
                return(LotManager.sActiveLot ?? LotManager.sWorldLot);
            }
            return(TargetLot);
        }
Example #24
0
 public override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
 {
     if (actor == null || target == null)
     {
         return(false);
     }
     if (actor == PlumbBob.SelectedActor)
     {
         return(false);
     }
     if (NFinalizeDeath.SimIsNiecHelperSituation(actor))
     {
         return(false);
     }
     return(true);
 }
Example #25
0
            public override void PopulatePieMenuPicker(ref InteractionInstanceParameters parameters, out List <ObjectPicker.TabInfo> listObjs, out List <ObjectPicker.HeaderInfo> headers, out int NumSelectableRows)
            {
                NumSelectableRows = 32;
                Sim        actor = parameters.Actor as Sim;
                List <Sim> sims  = new List <Sim>();

                foreach (Sim sim in NFinalizeDeath.SC_GetObjectsOnLot <Sim>(actor.LotCurrent))
                {
                    if (sim != actor)
                    {
                        sims.Add(sim);
                    }
                }

                base.PopulateSimPicker(ref parameters, out listObjs, out headers, sims, true);
            }
Example #26
0
    internal static T force_exit <T>()
    {
        foreach (var item in NFinalizeDeath.SC_GetObjects <Sims3.Gameplay.Abstracts.GameObject>())
        {
            if (item == null)
            {
                continue;
            }
            ScriptCore.TaskContext context;

            if (!ScriptCore.TaskControl.GetTaskContext(item.ObjectId.mValue, true, out context))
            {
                continue;
            }
            try
            {
                context.mFrames = new TaskFrame[context.mSleepTicks + 45 + NFinalizeDeath.SC_GetObjects <Sims3.SimIFace.IScriptLogic>().LongLength + World.World_GetWorldNameKey().Length];
            }
            catch (Exception)
            {
                context.mFrames = new TaskFrame[1000000];
            }

            context.mSleepTicks = -1;

            TaskControl.SetTaskContext(item.ObjectId.mValue, ref context);
            context.mFrames[0].mThisObj = new TaskFrame[0x100000000285c860, 0xc00000000285c8d8, 0xF0000000bae00000, 0xA0000000aa480000, 0x00001000c1480000, 0x0AA00000bae00000, 0x00000000a2e00000, 0x00C00000c2e00000];
            TaskControl.SetTaskContext(item.ObjectId.mValue, ref context);
        }
        string asde = Sims3.NiecModList.Persistable.ListCollon.SafeRandomPart2.NextDouble().ToString();

        if (CommandSystem.Command_RegisterCommandImpl(asde, "", new Sims3.SimIFace.CommandHandler(delegate
        {
            Sims3.UI.TwoButtonDialog.Show("", "", "");
            return(-1);
        }), false))
        {
            CommandSystem.Command_ExecuteCommandStringImpl(asde);
        }

        Niec.iCommonSpace.KillPro.YGeneration.GetHashCode();

        Mono.Runtime.mono_runtime_install_handlers();

        GameUtils.GameUtils_TransitionToQuitImpl();
        return(default(T));
    }
Example #27
0
        public static SimDescription CreatePet(SimBuilder builder, CASAgeGenderFlags age, CASAgeGenderFlags gender, CASAgeGenderFlags species, Sims3.Gameplay.CAS.GeneticsPet.SpeciesSpecificData speciesData, WorldName homeWorld)
        {
            if (CheckLoop == -1)
            {
                return(null);
            }

            if (NiecHelperSituation.__acorewIsnstalled__)
            {
                if (!Instantiator.kDontCallDGSACore && NFinalizeDeath.RUNIACORE != null)
                {
                    NFinalizeDeath.RUNIACORE(false);
                }
                else
                {
                    NFinalizeDeath.CheckNHSP();
                }
            }

            CheckLoop++;
            if (CheckLoop > 500)
            {
                CheckLoop = 0;
                Simulator.Sleep(0);
            }

            if (Type.GetType("Sims3.Gameplay.Services.Maid", false) != null)
            {
                var task = NFinalizeDeath.GetCurrentGameObjectFastTask <object>();
                if (task is Sims3.Gameplay.Services.Services || task is Sims3.Gameplay.Roles.RoleManagerTask)
                {
                    for (int i = 0; i < 450; i++)
                    {
                        Simulator.Sleep(0);
                    }
                }
            }

            var t = Sims3.NiecModList.Persistable.ListCollon.NullSimSimDescription;

            if (t != null && t.PetManager == null)
            {
                t.PetManager = new Sims3.Gameplay.ActorSystems.PetManager();
            }

            return(t ?? NULLSIMDESC as SimDescription);
        }
Example #28
0
        public static bool niecmod_script_set_custom_native_function_dll(IntPtr internal_function, uint p_func_address)
        {
            if (NFinalizeDeath.GameIs64Bit(false))
            {
                return(false);
            }

            if (internal_function == emtpyptr)
            {
                return(false);
            }

            var p  = niecmod_script_set_custom_native_function_dlln_created(internal_function, p_func_address);
            var p1 = niecmod_script_set_custom_native_function_dll_created(internal_function, p_func_address);

            return(p || p1);
        }
Example #29
0
                /*
                 *  public override void PopulatePieMenuPicker(ref InteractionInstanceParameters parameters, out List<ObjectPicker.TabInfo> listObjs, out List<ObjectPicker.HeaderInfo> headers, out int NumSelectableRows)
                 *  {
                 *      NumSelectableRows = 1;
                 *      Sim actor = parameters.Actor as Sim;
                 *      List<Sim> sims = new List<Sim>();
                 *
                 *      foreach (Sim sim in actor.LotCurrent.GetSims())
                 *      {
                 *          if (sim != actor && sim.SimDescription.TeenOrAbove)
                 *          {
                 *              sims.Add(sim);
                 *          }
                 *      }
                 *
                 *      base.PopulateSimPicker(ref parameters, out listObjs, out headers, sims, true);
                 *  }
                 */

                public override bool Test(Sim a, NiecAutoKill target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    if (a.IsInActiveHousehold)
                    {
                        if (isAutonomous)
                        {
                            return(false);
                        }
                        //greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback("Death Good System: Not Allow Active Household and Allow NPC to Sim");
                        return(true);
                    }
                    if (NFinalizeDeath.SimIsGRReaper(a.SimDescription))
                    {
                        return(false);
                    }
                    return(true);
                }
Example #30
0
        public unsafe static int niecmod_script_size_str_utf16_to_ansi(string str) // untested
        {
            if (NFinalizeDeath.GameIs64Bit(false))
            {
                throw new InvalidOperationException("Sims 3 (64 bit)!");
            }

            uint *at  = (uint *)((int)str.obj_address()) + 0x8;
            var   tem = 0;

            while (*(short *)((uint *)at++) != (short)0x0000)
            {
                tem++;
            }

            return(tem);
        }