Exemplo n.º 1
0
        public AreaOverlap OverlapWith(Area a)
        {
            if (a.TrueCount == 0)
            {
                return(AreaOverlap.None);
            }
            if (this.Map != a.Map)
            {
                return(AreaOverlap.None);
            }
            if (this.cachedAreaOverlaps == null)
            {
                this.cachedAreaOverlaps = new Dictionary <Area, AreaOverlap>();
            }
            AreaOverlap areaOverlap = default(AreaOverlap);

            if (!this.cachedAreaOverlaps.TryGetValue(a, out areaOverlap))
            {
                int num  = 0;
                int num2 = 0;
                foreach (IntVec3 cell in this.Cells)
                {
                    num2++;
                    if (a[cell])
                    {
                        num++;
                    }
                }
                areaOverlap = (AreaOverlap)((num != 0) ? ((num == num2) ? 1 : 2) : 0);
                this.cachedAreaOverlaps.Add(a, areaOverlap);
            }
            return(areaOverlap);
        }
Exemplo n.º 2
0
        public static bool OverlapWith(Region __instance, ref AreaOverlap __result, Area a)
        {
            if (a.TrueCount == 0)
            {
                __result = AreaOverlap.None;
                return(false);
            }

            if (__instance.Map != a.Map)
            {
                __result = AreaOverlap.None;
                return(false);
            }

            if (cachedAreaOverlaps(__instance) == null)
            {
                cachedAreaOverlaps(__instance) = new Dictionary <Area, AreaOverlap>();
            }
            Dictionary <Area, AreaOverlap> cao = cachedAreaOverlaps(__instance);
            AreaOverlap value;

            lock (cao)
            {
                bool valueExists = cao.TryGetValue(a, out value);
                if (!valueExists)
                {
                    int num  = 0;
                    int num2 = 0;
                    foreach (IntVec3 cell in __instance.Cells)
                    {
                        num2++;
                        if (a[cell])
                        {
                            num++;
                        }
                    }

                    value = ((num != 0) ? ((num == num2) ? AreaOverlap.Entire : AreaOverlap.Partial) : AreaOverlap.None);

                    cao.Add(a, value);
                }
            }

            __result = value;
            return(false);
        }