示例#1
0
 /// <summary>
 /// Creates a default <see cref="TileTick"/> record appropriate for the block.
 /// </summary>
 public void CreateTileTick()
 {
     _tileTick = new TileTick()
     {
         ID = _id,
     };
 }
示例#2
0
        internal void SetTileTick(int index, TileTick tt)
        {
            int x, y, z;

            _blocks.GetMultiIndex(index, out x, out y, out z);

            _tileTickManager.SetTileTick(x, y, z, tt);
            _dirty = true;
        }
示例#3
0
        /// <inheritdoc/>
        public void SetTileTick(int x, int y, int z, TileTick te)
        {
            cache = GetChunk(x, y, z);
            if (cache == null || !Check(x, y, z))
            {
                return;
            }

            cache.Blocks.SetTileTick(x & chunkXMask, y & chunkYMask, z & chunkZMask, te);
        }
示例#4
0
        /// <summary>
        /// Updates a block in this collection with values from a <see cref="AlphaBlock"/> object.
        /// </summary>
        /// <param name="x">Local X-coordinate of a block.</param>
        /// <param name="y">Local Y-coordinate of a block.</param>
        /// <param name="z">Local Z-coordinate of a block.</param>
        /// <param name="block">A <see cref="AlphaBlock"/> object to copy block data from.</param>
        public void SetBlock(int x, int y, int z, AlphaBlock block)
        {
            SetID(x, y, z, block.ID);
            SetData(x, y, z, block.Data);

            TileEntity te = block.GetTileEntity();

            if (te != null)
            {
                SetTileEntity(x, y, z, te.Copy());
            }

            TileTick tt = block.GetTileTick();

            if (tt != null)
            {
                SetTileTick(x, y, z, tt.Copy());
            }
        }
示例#5
0
        /// <summary>
        /// Updates the chunk's global world coordinates.
        /// </summary>
        /// <param name="x">Global X-coordinate.</param>
        /// <param name="z">Global Z-coordinate.</param>
        public virtual void SetLocation(int x, int z)
        {
            int diffx = (x - _cx) * XDIM;
            int diffz = (z - _cz) * ZDIM;

            // Update chunk position

            _cx = x;
            _cz = z;

            _tree.Root["Level"].ToTagCompound()["xPos"].ToTagInt().Data = x;
            _tree.Root["Level"].ToTagCompound()["zPos"].ToTagInt().Data = z;

            // Update tile entity coordinates

            List <TileEntity> tileEntites = new List <TileEntity>();

            foreach (TagNodeCompound tag in _tileEntities)
            {
                TileEntity te = TileEntityFactory.Create(tag);
                if (te == null)
                {
                    te = TileEntity.FromTreeSafe(tag);
                }

                if (te != null)
                {
                    te.MoveBy(diffx, 0, diffz);
                    tileEntites.Add(te);
                }
            }

            _tileEntities.Clear();
            foreach (TileEntity te in tileEntites)
            {
                _tileEntities.Add(te.BuildTree());
            }

            // Update tile tick coordinates

            if (_tileTicks != null)
            {
                List <TileTick> tileTicks = new List <TileTick>();
                foreach (TagNodeCompound tag in _tileTicks)
                {
                    TileTick tt = TileTick.FromTreeSafe(tag);

                    if (tt != null)
                    {
                        tt.MoveBy(diffx, 0, diffz);
                        tileTicks.Add(tt);
                    }
                }

                _tileTicks.Clear();
                foreach (TileTick tt in tileTicks)
                {
                    _tileTicks.Add(tt.BuildTree());
                }
            }

            // Update entity coordinates

            List <TypedEntity> entities = new List <TypedEntity>();

            foreach (TypedEntity entity in _entityManager)
            {
                entity.MoveBy(diffx, 0, diffz);
                entities.Add(entity);
            }

            _entities.Clear();
            foreach (TypedEntity entity in entities)
            {
                _entityManager.Add(entity);
            }
        }
示例#6
0
 /// <inheritdoc/>
 public void SetTileTick(int x, int y, int z, TileTick tt)
 {
     _tileTickManager.SetTileTick(x, y, z, tt);
     _dirty = true;
 }
示例#7
0
 /// <summary>
 /// Removes any <see cref="TileTick"/> currently attached to the block.
 /// </summary>
 public void ClearTileTick()
 {
     _tileTick = null;
 }
示例#8
0
 /// <summary>
 /// Sets a new <see cref="TileTick"/> record for the block.
 /// </summary>
 /// <param name="tt">A <see cref="TileTick"/> record compatible with the block's type.</param>
 public void SetTileTick(TileTick tt)
 {
     _tileTick = tt;
 }
示例#9
0
 /// <summary>
 /// Sets a new <see cref="TileTick"/> record for the block.
 /// </summary>
 /// <param name="te">A <see cref="TileTick"/> record compatible with the block's type.</param>
 public void SetTileTick(TileTick te)
 {
     _collection.SetTileTick(_index, te);
 }