Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModificationEventArgs" /> class.
        /// </summary>
        /// <param name="scintilla">The <see cref="Scintilla" /> control that generated this event.</param>
        /// <param name="source">The source of the modification.</param>
        /// <param name="bytePosition">The zero-based byte position within the document where text was modified.</param>
        /// <param name="byteLength">The length in bytes of the inserted or deleted text.</param>
        /// <param name="text">>A pointer to the text inserted or deleted.</param>
        /// <param name="linesAdded">The number of lines added or removed (delta).</param>
        public ModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text, int linesAdded) : base(scintilla, source, bytePosition, byteLength, text)
        {
            this.scintilla    = scintilla;
            this.bytePosition = bytePosition;
            this.byteLength   = byteLength;
            this.textPtr      = text;

            LinesAdded = linesAdded;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BeforeModificationEventArgs" /> class.
        /// </summary>
        /// <param name="scintilla">The <see cref="Scintilla" /> control that generated this event.</param>
        /// <param name="source">The source of the modification.</param>
        /// <param name="bytePosition">The zero-based byte position within the document where text is being modified.</param>
        /// <param name="byteLength">The length in bytes of the text being modified.</param>
        /// <param name="text">A pointer to the text being inserted.</param>
        public BeforeModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text)
        {
            this.scintilla    = scintilla;
            this.bytePosition = bytePosition;
            this.byteLength   = byteLength;
            this.textPtr      = text;

            Source = source;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ModificationEventArgs" /> class.
        /// </summary>
        /// <param name="scintilla">The <see cref="Scintilla" /> control that generated this event.</param>
        /// <param name="source">The source of the modification.</param>
        /// <param name="bytePosition">The zero-based byte position within the document where text was modified.</param>
        /// <param name="byteLength">The length in bytes of the inserted or deleted text.</param>
        /// <param name="text">>A pointer to the text inserted or deleted.</param>
        /// <param name="linesAdded">The number of lines added or removed (delta).</param>
        public ModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text, int linesAdded) : base(scintilla, source, bytePosition, byteLength, text)
        {
            this.scintilla = scintilla;
            this.bytePosition = bytePosition;
            this.byteLength = byteLength;
            this.textPtr = text;

            LinesAdded = linesAdded;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BeforeModificationEventArgs" /> class.
        /// </summary>
        /// <param name="Scintilla">The <see cref="Scintilla" /> control that generated this event.</param>
        /// <param name="source">The source of the modification.</param>
        /// <param name="bytePosition">The zero-based byte position within the document where text is being modified.</param>
        /// <param name="byteLength">The length in bytes of the text being modified.</param>
        /// <param name="text">A pointer to the text being inserted.</param>
        public BeforeModificationEventArgs(ZeroitCodeExplorer Scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text)
        {
            this.Scintilla    = Scintilla;
            this.bytePosition = bytePosition;
            this.byteLength   = byteLength;
            this.textPtr      = text;

            Source = source;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BeforeModificationEventArgs" /> class.
        /// </summary>
        /// <param name="scintilla">The <see cref="Scintilla" /> control that generated this event.</param>
        /// <param name="source">The source of the modification.</param>
        /// <param name="bytePosition">The zero-based byte position within the document where text is being modified.</param>
        /// <param name="byteLength">The length in bytes of the text being modified.</param>
        /// <param name="text">A pointer to the text being inserted.</param>
        public BeforeModificationEventArgs(Scintilla scintilla, ModificationSource source, int bytePosition, int byteLength, IntPtr text)
        {
            this.scintilla = scintilla;
            this.bytePosition = bytePosition;
            this.byteLength = byteLength;
            this.textPtr = text;

            Source = source;
        }
 public override void LightBlock(int x, int y, int z, ModificationSource source)
 {
     if (source == ModificationSource.InternalOrSystem)
     {
         m_BlocksToLightQueue.Push(new Vector3Int(x, y, z));
     }
     else
     {
         m_ImportantBlocksToLightQueue.Push(new Vector3Int(x, y, z));
     }
 }
Beispiel #7
0
        private void UpdateSkyLightData(int x, int z, ModificationSource source)
        {
            int skyLight = SkyLight;

            for (int y = ChunkHeight - 1; y >= 0; y--)
            {
                int index = GetNibbleArrayIndex(x, y, z);

                if (m_SkyLights[index] != skyLight)
                {
                    m_SkyLights[index] = (byte)skyLight;
                    World.MarkBlockMeshDirty(x, y, z, source);
                }

                skyLight = GetBlockedLight(skyLight, m_Blocks[x, y, z]);
            }
        }
        private void LightBlocks(Stack <Vector3Int> queue, ref int limit, ModificationSource source)
        {
            while (limit-- > 0 && queue.Count > 0)
            {
                Vector3Int blockPos = queue.Pop();

                if (blockPos.y < 0 || blockPos.y >= ChunkHeight)
                {
                    continue;
                }

                if (!ChunkManager.GetChunk(ChunkPos.GetFromAny(blockPos.x, blockPos.z), false, out _))
                {
                    // 我不想管这个了,如果有人有好的算法请告诉我!
                    // m_BlocksToLightQueue.Push(blockPos);
                    // break;
                    continue;
                }

                int x = blockPos.x;
                int y = blockPos.y;
                int z = blockPos.z;

                BlockData block      = RWAccessor.GetBlock(x, y, z);
                int       opacity    = Mathf.Max(block.LightOpacity, 1);
                int       finalLight = 0;

                if (opacity < MaxLight || block.LightValue > 0) // 不然就是0
                {
                    int max = RWAccessor.GetAmbientLight(x + 1, y, z);
                    int temp;

                    if ((temp = RWAccessor.GetAmbientLight(x - 1, y, z)) > max)
                    {
                        max = temp;
                    }

                    if ((temp = RWAccessor.GetAmbientLight(x, y + 1, z)) > max)
                    {
                        max = temp;
                    }

                    if ((temp = RWAccessor.GetAmbientLight(x, y - 1, z)) > max)
                    {
                        max = temp;
                    }

                    if ((temp = RWAccessor.GetAmbientLight(x, y, z + 1)) > max)
                    {
                        max = temp;
                    }

                    if ((temp = RWAccessor.GetAmbientLight(x, y, z - 1)) > max)
                    {
                        max = temp;
                    }

                    finalLight = max - opacity;

                    if (block.LightValue > finalLight)
                    {
                        finalLight = block.LightValue; // 假设这个值一定是合法的(不过确实应该是合法的)
                    }
                    else if (finalLight < 0)
                    {
                        finalLight = 0;
                    }
                    //else if (finalLight > MaxLight)
                    //{
                    //    finalLight = MaxLight;
                    //}
                }

                if (RWAccessor.SetAmbientLightLevel(x, y, z, finalLight, source))
                {
                    queue.Push(new Vector3Int(x - 1, y, z));
                    queue.Push(new Vector3Int(x, y - 1, z));
                    queue.Push(new Vector3Int(x, y, z - 1));
                    queue.Push(new Vector3Int(x + 1, y, z));
                    queue.Push(new Vector3Int(x, y + 1, z));
                    queue.Push(new Vector3Int(x, y, z + 1));
                }
            }
        }
Beispiel #9
0
        public bool SetBlock(int x, int y, int z, BlockData value, Quaternion rotation, ModificationSource source)
        {
            if (!Accessible)
            {
                throw new InvalidOperationException("Chunk is not accessible.");
            }

            if (y < 0 || y >= ChunkHeight)
            {
                return(false);
            }

            ref BlockData blockData = ref m_Blocks[x, y, z];