Example #1
0
    private void DamageBlock(Vector3 pos, float damage)
    {
        if (!blockDamages.ContainsKey(pos))
        {
            blockDamages.Add(pos, 0);
        }
        blockDamages[pos] += damage;

        float blockResistance = Blocks.GetResistance(world.BlockAt((int)pos.x, (int)pos.y, (int)pos.z));

        if (blockResistance != -1 && blockDamages[pos] >= blockResistance)
        {
            _playerInfo.AddBlockToInv(world.BlockAt((int)pos.x, (int)pos.y, (int)pos.z));
            ChangeBlockAt(pos, Air.ID);
        }

        _breakParticleSystem.transform.position = pos + new Vector3(.5f, 0, .5f);
    }