Пример #1
0
		// TODO: When farmland is broken, it should drop a dirt block.

		public override void Use(Level level, ChunkLayer layer, int blockX, int blockY, out bool isConsumed)
		{
			base.Use(level, layer, blockX, blockY, out isConsumed);

			var blockId = level[layer, blockX, blockY];
			if (blockId > 0)
			{
				level[layer, blockX, blockY] = 0;

				var blockEntity = new BlockEntity(blockId);
				blockEntity.MoveTo(level, new Vector2(blockX, blockY));
				level.AddEntity(blockEntity);
			}

			// TODO: If durability <= 0, isConsumed = true.
			isConsumed = false;
		}
Пример #2
0
        // TODO: When farmland is broken, it should drop a dirt block.

        public override void Use(Level level, ChunkLayer layer, int blockX, int blockY, out bool isConsumed)
        {
            base.Use(level, layer, blockX, blockY, out isConsumed);

            var blockId = level[layer, blockX, blockY];

            if (blockId > 0)
            {
                level[layer, blockX, blockY] = 0;

                var blockEntity = new BlockEntity(blockId);
                blockEntity.MoveTo(level, new Vector2(blockX, blockY));
                level.AddEntity(blockEntity);
            }

            // TODO: If durability <= 0, isConsumed = true.
            isConsumed = false;
        }
Пример #3
0
		private void Render(ITessellator tessellator, BlockEntity entity)
		{
			var color = tessellator.CurrentColor;
			tessellator.BindColor(Color.FromArgb(196, entity.IsSelected ? Color.Red : Color.White));
			tessellator.PushTransform();

			var origin = tessellator.Transform(Vector3.Zero);

			tessellator.LoadIdentity();
			tessellator.Scale(entity.Size, entity.Size);
			tessellator.Translate(-entity.Size / 2, -entity.Size / 2); // center the rotation
			tessellator.Rotate(entity.Rotation, 0, 0, 1);
			tessellator.Translate(entity.Size, entity.Size);
			tessellator.Translate(origin);
			//tessellator.Translate(entity.Size, entity.Size); // center on the current tile position
			tessellator.Translate(entity.Position); // move to the entity's position

			BlockRegistry.Instance.GetById(entity.BlockID).Renderer.Render(tessellator);

			tessellator.PopTransform();
			tessellator.BindColor(color); // TODO: Is this still needed?
		}