Example #1
0
        private void UpdateBlockDestroyProgress()
        {
            Block blockToDestroy = Block.FromId(World.Instance.GetBlock(PositionBlock.FromVector(BlockAttackPosition)));
            float efficiency     = ToolMatrix.GetEfficiency(SelectedStack.Id, blockToDestroy.Id);

            DestroyProgress += (100f / (float)blockToDestroy.Density) * efficiency;
            if (SelectedStack.AsItem != null)
            {
                Item itemInHand = Item.FromId(SelectedStack.Id);
                itemInHand.OnAfterAttack();
            }
        }
Example #2
0
        private void DestroyBlock(Vector4 pos)
        {
            PositionBlock posBlock = PositionBlock.FromVector(pos);
            Block         block    = Block.FromId(World.Instance.GetBlock(posBlock));

            block.OnDestroy(posBlock);
            World.Instance.SetBlock(posBlock, 0);
            PositionChunk posChunk = PositionChunk.CreateFrom(posBlock);
            Chunk         chunk    = World.Instance.GetChunk(posChunk);

            chunk.InvalidateMeAndNeighbors();
        }
Example #3
0
        private void HandleMouseRight()
        {
            // activate block?
            PositionBlock positionBlock = PositionBlock.FromVector(World.Instance.PlayerVoxelTrace.ImpactPosition);
            Block         impactBlock   = Block.FromId(World.Instance.GetBlock(positionBlock));

            if (impactBlock.OnActivate(positionBlock))
            {
                return;
            }

            // are we using a block?
            if (SelectedStack.AsBlock != null)
            {
                UseBlockInHand();
            }
            // are we using an item?
            else if (SelectedStack.AsItem != null)
            {
                UseItemInHand();
                NeedsRest();
            }
        }