コード例 #1
0
        //=====================================================================================================\\

        public OgreStackMod(ModContentPack content) : base(content)
        {
            //Verse.Log.Message("No Impact No Idea");
            this.settings = base.GetSettings <OgreStackSettings>();

            this.settings.ReModify = () =>
            {
                Verse.Log.Message("[OgreStack]: Remodify From Settings Change");

                _activeThings = new Dictionary <string, List <Thing> >();
                List <Map> maps = Verse.Find.Maps;
                // this can be done from the game load screen
                // with no active save loaded, which will
                // make maps null
                if (maps != null)
                {
                    foreach (Map m in maps)
                    {
                        if (m != null && m.listerThings != null)
                        {
                            List <Thing> things = m.listerThings.AllThings;
                            foreach (Thing t in things)
                            {
                                if (t != null && t.def != null && !string.IsNullOrEmpty(t.def.defName) && this.isStackIncreaseAllowed(t.def))
                                {
                                    if (!_activeThings.ContainsKey(t.def.defName))
                                    {
                                        _activeThings.Add(t.def.defName, new List <Thing>());
                                    }

                                    _activeThings[t.def.defName].Add(t);
                                }
                            }
                        }
                    }
                }
                this.ModifyStackSizes();

                _activeThings.Clear();
                _activeThings = null;
            };

            // this appears to be a technique to attempt
            // processing after other mods have loaded
            // its not a guarantee though
            Verse.LongEventHandler.QueueLongEvent(() => {
                Verse.LongEventHandler.QueueLongEvent(() => {
                    this.ModifyStackSizes();
                }, "OgreStack_Init_Execute", true, null);
            }, "OgreStack_Init_Reg", true, null);
        }
コード例 #2
0
ファイル: OgreStackMod.cs プロジェクト: Proxyer/OgreStack
        //=====================================================================================================\\

        public OgreStackMod(ModContentPack content) : base(content)
        {
            //Verse.Log.Message("No Impact No Idea");
            this.settings = base.GetSettings <OgreStackSettings>();

            this.settings.ReModify = () =>
            {
                Verse.Log.Message("[OgreStack]: Remodify From Settings Change");

                _activeThings = new Dictionary <string, List <Thing> >();
                foreach (Map m in Verse.Find.Maps)
                {
                    foreach (Thing t in m.listerThings.AllThings)
                    {
                        if (t != null && t.def != null && !string.IsNullOrEmpty(t.def.defName) && this.isStackIncreaseAllowed(t.def))
                        {
                            List <Thing> things = null;
                            if (!_activeThings.TryGetValue(t.def.defName, out things))
                            {
                                things = new List <Thing>();
                                _activeThings.Add(t.def.defName, things);
                            }
                            things.Add(t);
                        }
                    }
                }

                this.ModifyStackSizes();

                _activeThings.Clear();
                _activeThings = null;
            };

            // this appears to be a technique to attempt
            // processing after other mods have loaded
            // its not a guarantee though

            Verse.LongEventHandler.QueueLongEvent(() => {
                this.ModifyStackSizes();
            }, "OgreStack_Init", false, null);
        }