예제 #1
0
            internal bool TryAdd(TrixelEmplacement trixel)
            {
                bool flag = false;

                if (this.Boxes.Count > 0)
                {
                    foreach (TrixelCluster.Box box in Enumerable.ToArray <TrixelCluster.Box>(Enumerable.Where <TrixelCluster.Box>((IEnumerable <TrixelCluster.Box>) this.Boxes, (Func <TrixelCluster.Box, bool>)(b => b.IsNeighbor(trixel)))))
                    {
                        flag = true;
                        this.Dismantle(box);
                        this.Boxes.Remove(box);
                    }
                }
                if (!flag)
                {
                    foreach (TrixelEmplacement trixelEmplacement in this.Trixels)
                    {
                        if (trixelEmplacement.IsNeighbor(trixel))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if (flag)
                {
                    this.Trixels.Add(trixel);
                }
                TrixelCluster.Chunk chunk = this;
                int num = chunk.Dirty | flag ? 1 : 0;

                chunk.Dirty = num != 0;
                return(flag);
            }
예제 #2
0
        public void FillAsChunk(IEnumerable <TrixelEmplacement> trixels)
        {
            TrixelEmplacement firstTrixel = Enumerable.First <TrixelEmplacement>(trixels);

            TrixelCluster.Chunk chunk = Enumerable.FirstOrDefault <TrixelCluster.Chunk>((IEnumerable <TrixelCluster.Chunk>) this.Chunks, (Func <TrixelCluster.Chunk, bool>)(c => c.TryAdd(firstTrixel)));
            if (chunk == null)
            {
                chunk = new TrixelCluster.Chunk();
                this.Chunks.Add(chunk);
            }
            chunk.Trixels.UnionWith(trixels);
            chunk.ConsolidateTrixels();
        }
예제 #3
0
 public void Fill(IEnumerable <TrixelEmplacement> trixels)
 {
     using (IEnumerator <TrixelEmplacement> enumerator = trixels.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             TrixelEmplacement trixel = enumerator.Current;
             if (!Enumerable.Any <TrixelCluster.Chunk>((IEnumerable <TrixelCluster.Chunk>) this.Chunks, (Func <TrixelCluster.Chunk, bool>)(c => c.TryAdd(trixel))))
             {
                 TrixelCluster.Chunk chunk = new TrixelCluster.Chunk();
                 this.Chunks.Add(chunk);
                 chunk.Trixels.Add(trixel);
             }
         }
     }
     this.ConsolidateTrixels();
 }
예제 #4
0
            internal bool TryRemove(TrixelEmplacement trixel)
            {
                bool flag1 = false;

                foreach (TrixelCluster.Box box in Enumerable.Where <TrixelCluster.Box>((IEnumerable <TrixelCluster.Box>) this.Boxes, (Func <TrixelCluster.Box, bool>)(b =>
                {
                    if (!b.Contains(trixel))
                    {
                        return(b.IsNeighbor(trixel));
                    }
                    else
                    {
                        return(true);
                    }
                })))
                {
                    flag1 = true;
                    this.Dismantle(box);
                }
                if (flag1)
                {
                    this.Boxes.RemoveAll((Predicate <TrixelCluster.Box>)(b =>
                    {
                        if (!b.Contains(trixel))
                        {
                            return(b.IsNeighbor(trixel));
                        }
                        else
                        {
                            return(true);
                        }
                    }));
                }
                bool flag2 = flag1 | this.Trixels.Remove(trixel);

                TrixelCluster.Chunk chunk = this;
                int num = chunk.Dirty | flag2 ? 1 : 0;

                chunk.Dirty = num != 0;
                return(flag2);
            }
예제 #5
0
 public void OnDeserialization()
 {
     if (this.deserializedOrphans != null)
     {
         using (List <TrixelEmplacement> .Enumerator enumerator = this.deserializedOrphans.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 TrixelEmplacement   trixel = enumerator.Current;
                 TrixelCluster.Chunk chunk  = Enumerable.FirstOrDefault <TrixelCluster.Chunk>((IEnumerable <TrixelCluster.Chunk>) this.Chunks, (Func <TrixelCluster.Chunk, bool>)(c => c.IsNeighbor(trixel)));
                 if (chunk == null)
                 {
                     this.Chunks.Add(chunk = new TrixelCluster.Chunk());
                 }
                 chunk.Trixels.Add(trixel);
             }
         }
         this.deserializedOrphans = (List <TrixelEmplacement>)null;
     }
     if (this.deserializedBoxes == null)
     {
         return;
     }
     using (List <TrixelCluster.Box> .Enumerator enumerator = this.deserializedBoxes.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             TrixelCluster.Box   box   = enumerator.Current;
             TrixelCluster.Chunk chunk = Enumerable.FirstOrDefault <TrixelCluster.Chunk>((IEnumerable <TrixelCluster.Chunk>) this.Chunks, (Func <TrixelCluster.Chunk, bool>)(c => c.IsNeighbor(box)));
             if (chunk == null)
             {
                 this.Chunks.Add(chunk = new TrixelCluster.Chunk());
             }
             chunk.Boxes.Add(box);
         }
     }
     this.deserializedBoxes = (List <TrixelCluster.Box>)null;
 }