public static bool RegisterInRegions(Thing thing, Map map)
        {
            if (!ListerThings.EverListable(thing.def, ListerThingsUse.Region))
            {
                return(false);
            }
            int tID = Thread.CurrentThread.ManagedThreadId;

            if (!tmpRegionsLists.TryGetValue(tID, out List <Region> tmpRegions))
            {
                tmpRegions           = new List <Region>();
                tmpRegionsLists[tID] = tmpRegions;
            }
            else
            {
                tmpRegions.Clear();
            }
            RegionListersUpdater.GetTouchableRegions(thing, map, tmpRegions, false);
            for (int i = 0; i < tmpRegions.Count; i++)
            {
                ListerThings listerThings = tmpRegions[i].ListerThings;
                lock (listerThings)
                {
                    if (!listerThings.Contains(thing))
                    {
                        listerThings.Add(thing);
                    }
                }
            }
            return(false);
        }
        public static void RegisterInRegions(Thing thing, Map map)
        {
            ThingDef def = thing.def;

            if (!ListerThings.EverListable(def, ListerThingsUse.Region))
            {
                return;
            }
            newRegionListersUpdater.GetTouchableRegions(thing, map, newRegionListersUpdater.tmpRegions, false);
            for (int i = 0; i < newRegionListersUpdater.tmpRegions.Count; i++)
            {
                ListerThings listerThings = newRegionListersUpdater.tmpRegions[i].ListerThings;
                if (!listerThings.Contains(thing))
                {
                    listerThings.Add(thing);
                }
            }
        }
Ejemplo n.º 3
0
        public static void DeregisterInRegions(Thing thing, Map map)
        {
            ThingDef def = thing.def;

            if (!ListerThings.EverListable(def, ListerThingsUse.Region))
            {
                return;
            }
            GetTouchableRegions(thing, map, tmpRegions, true);
            for (int i = 0; i < tmpRegions.Count; i++)
            {
                ListerThings listerThings = tmpRegions[i].ListerThings;
                if (listerThings.Contains(thing))
                {
                    listerThings.Remove(thing);
                }
            }
            tmpRegions.Clear();
        }
Ejemplo n.º 4
0
        public static bool DeregisterInRegions(Thing thing, Map map)
        {
            if (!ListerThings.EverListable(thing.def, ListerThingsUse.Region))
            {
                return(false);
            }
            List <Region> tmpRegions = new List <Region>();

            RegionListersUpdater.GetTouchableRegions(thing, map, tmpRegions, true);
            for (int i = 0; i < tmpRegions.Count; i++)
            {
                ListerThings listerThings = tmpRegions[i].ListerThings;
                lock (listerThings)
                {
                    if (listerThings.Contains(thing))
                    {
                        listerThings.Remove(thing);
                    }
                }
            }
            return(false);
        }