Пример #1
0
            private static void FixRemovedGlowers(GlowGrid instance, GlowerPorperties prop)
            {
                if (prop.glower?.parent?.Destroyed ?? true)
                {
                    calculating = false;
                    instance.MarkGlowGridDirty(prop.position.ToIntVec3());
                    calculating = true;
                }
                var flooder  = instance.map.glowFlooder;
                var mapIndex = instance.map.Index;

                foreach (var otherGlower in instance.litGlowers)
                {
                    var other = GlowerPorperties.GetGlowerPorperties(otherGlower);
                    if (other != prop && other.drawen && other.Inersects(prop))
                    {
                        FloodGlow(other, tBufferedGrid, instance.map, flooder);
                    }
                }
                foreach (var index in prop.indices)
                {
                    instance.glowGrid[index] = tBufferedGrid[index];
#if DEBUG
                    if (Finder.drawGlowerUpdates)
                    {
                        instance.map.debugDrawer.FlashCell(
                            instance.map.cellIndices.IndexToCell(index), 0.05f, "_1_", 50);
                    }
#endif
                }
            }
Пример #2
0
 public bool Inersects(GlowerPorperties other)
 {
     if (Vector3.Distance(other.position, this.position) + 1 < other.glower.Props.glowRadius + this.glower.Props.glowRadius)
     {
         return(true);
     }
     return(false);
 }
Пример #3
0
 internal static void AddFloodGlowFor(CompGlower glower, Color32[] glowGrid)
 {
     GlowerPorperties.GetGlowerPorperties(glower);
     if (Finder.refreshGrid)
     {
         var flooder = glower.parent.Map.glowFlooder;
         flooder.AddFloodGlowFor(glower, tBufferedGrid);
     }
 }
Пример #4
0
 internal static void FloodGlow(GlowerPorperties prop, Color32[] grid, Map map, GlowFlooder flooder)
 {
     if (removedProps[map.Index].Contains(prop))
     {
         return;
     }
     if (prop.glower.parent.Destroyed || !prop.glower.parent.Spawned)
     {
         return;
     }
     flooder.AddFloodGlowFor(prop.glower, grid);
 }
Пример #5
0
            private static void FinalizeNewGlowers(GlowGrid instance)
            {
                var map     = instance.map;
                var flooder = map.glowFlooder;

                foreach (var glower in instance.litGlowers)
                {
                    var prop = GlowerPorperties.GetGlowerPorperties(glower);
                    if (!prop.drawen)
                    {
                        flooder.AddFloodGlowFor(prop.glower, instance.glowGrid);
                    }
                }
            }
Пример #6
0
            public static GlowerPorperties GetGlowerPorperties([NotNull] CompGlower comp)
            {
                if (comp == null)
                {
                    return(null);
                }
                if (props.TryGetValue(comp, out var prop))
                {
                    return(prop);
                }
                var result = new GlowerPorperties(comp);

                props[comp] = result;
                return(result);
            }
Пример #7
0
 internal static void Postfix(CompGlower theGlower)
 {
     if (currentProp == null && theGlower == null)
     {
         Log.Warning("ROCKETMAN: AddFloodGlow_Patch with null currentProp");
         return;
     }
     if (currentProp == null)
     {
         currentProp = GlowerPorperties.GetGlowerPorperties(theGlower);
         if (currentProp == null)
         {
             throw new InvalidDataException("ROCKETMAN: AddFloodGlow_Patch with null currentProp");
         }
     }
     currentProp.FinishUpdate();
     currentProp.drawen = true;
     currentProp        = null;
 }
Пример #8
0
            public static void Prefix(GlowGrid __instance, IntVec3 loc)
            {
                if (Current.ProgramState == ProgramState.Playing)
                {
                    var map      = __instance.map;
                    var mapIndex = map.Index;
                    if (TryRegisterMap(map))
                    {
                        if (!loc.IsValid || !loc.InBounds(map))
                        {
                            return;
                        }
                        if (register || calculating || deregister)
                        {
                            return;
                        }
#if DEBUG
                        if (Finder.debug)
                        {
                            Log.Message(string.Format("ROCKETMAN: Map glow grid dirty at {0}", loc));
                        }
#endif
                        var changedPos = loc.ToVector3();
                        foreach (var glower in __instance.litGlowers)
                        {
                            var prop = GlowerPorperties.GetGlowerPorperties(glower);
                            if (prop.Contains(changedPos))
                            {
                                changedProps[mapIndex].Add(prop);
#if DEBUG
                                if (Finder.debug)
                                {
                                    Log.Message(string.Format("ROCKETMAN: Changed and glow grid dirty at {0} for {1}", loc, glower.parent));
                                }
#endif
                            }
                        }
                    }
                }
            }
Пример #9
0
            internal static void Prefix(GlowGrid __instance, CompGlower newGlow)
            {
                Map map = __instance.map;

                register = true;
                TryRegisterMap(map);

                GlowerPorperties prop = GlowerPorperties.GetGlowerPorperties(newGlow);

                if (props.ContainsKey(newGlow))
                {
                    if (Finder.debug)
                    {
                        Log.Warning(string.Format("ROCKETMAN: Double registering an registered glower {0}:{1}", newGlow, newGlow.parent));
                    }
                    return;
                }
                if (Finder.debug)
                {
                    Log.Warning(string.Format("ROCKETMAN: Registering an registered glower {0}:{1}", newGlow, newGlow.parent));
                }
            }
Пример #10
0
 internal static void Prefix(CompGlower theGlower)
 {
     currentProp = GlowerPorperties.GetGlowerPorperties(theGlower);
     currentProp.Update();
 }
Пример #11
0
            private static void FixChanged(GlowGrid instance)
            {
                var map      = instance.map;
                var mapIndex = map.Index;

                var queue = new Queue <GlowerPorperties>();

                foreach (var glower in instance.litGlowers)
                {
                    var prop = GlowerPorperties.GetGlowerPorperties(glower);
                    queue.Enqueue(prop);
                }
                while (true)
                {
                    var count        = changedProps[mapIndex].Count;
                    var tqueue       = new Queue <GlowerPorperties>();
                    var changedArray = changedProps[mapIndex].ToArray();
                    while (queue.Count > 0)
                    {
                        var prop = queue.Dequeue();
                        if (!prop.drawen || changedProps[mapIndex].Contains(prop))
                        {
                            continue;
                        }
                        var found = false;
                        foreach (var other in changedArray)
                        {
                            if (other != prop && other.Inersects(prop))
                            {
                                changedProps[mapIndex].Add(prop);
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            tqueue.Enqueue(prop);
                        }
                    }
                    if (count == changedProps[mapIndex].Count)
                    {
                        break;
                    }
                    queue = tqueue;
                }
                foreach (var prop in changedProps[mapIndex])
                {
                    foreach (var index in prop.indices)
                    {
                        instance.glowGrid[index] = new Color32(0, 0, 0, 0);
#if DEBUG
                        if (Finder.drawGlowerUpdates)
                        {
                            map.debugDrawer.FlashCell(map.cellIndices.IndexToCell(index), 0.6f, "000", 10);
                        }
#endif
                    }
                }
                foreach (var prop in changedProps[mapIndex])
                {
                    FloodGlow(prop, tBufferedGrid, map, map.glowFlooder);
                }
                foreach (var prop in changedProps[mapIndex])
                {
                    foreach (var index in prop.indices)
                    {
                        instance.glowGrid[index] = tBufferedGrid[index];
#if DEBUG
                        if (Finder.drawGlowerUpdates)
                        {
                            map.debugDrawer.FlashCell(map.cellIndices.IndexToCell(index), 0.6f, "1__", 50);
                        }
#endif
                    }
                }
            }