int DamageAreaFast(Vector3 origin, int damage, int damageRadius = 1, bool distanceAttenuation = true, bool addParticles = true, List <VoxelIndex> results = null)
        {
            bool hasResults = results != null;

            if (hasResults)
            {
                results.Clear();
            }
            if (damageRadius < 0 || damage < 1)
            {
                return(0);
            }

            int          damagedCount = 0;
            Vector3      direction    = Misc.vector3zero;
            VoxelHitInfo hitInfo;

            GetVoxelIndices(origin, damageRadius, tempVoxelIndices);
            int count = tempVoxelIndices.Count;

            for (int k = 0; k < count; k++)
            {
                VoxelIndex vi         = tempVoxelIndices [k];
                VoxelChunk otherChunk = vi.chunk;
                int        otherIndex = vi.voxelIndex;
                int        dam        = damage;
                if (distanceAttenuation && vi.sqrDistance > 1)
                {
                    dam = (int)(damage * damageRadius * damageRadius / vi.sqrDistance);
                }
                if (dam > 0 && GetVoxelVisibility(otherChunk, otherIndex))
                {
                    FastVector.NormalizedDirection(ref origin, ref vi.position, ref direction);
                    if (RayCastFast(origin, direction, out hitInfo, damageRadius, false, 5))
                    {
                        int damageTaken = DamageVoxelFast(ref hitInfo, dam, addParticles, false);
                        if (hasResults)
                        {
                            VoxelIndex di = vi;
                            di.damageTaken = damageTaken;
                            results.Add(di);
                            damagedCount++;
                        }
                    }
                }
            }

            return(damagedCount);
        }
        bool HitVoxelFast(Vector3 origin, Vector3 direction, int damage, out VoxelHitInfo hitInfo, float maxDistance = 0, int damageRadius = 1, bool addParticles = true, bool playSound = true, bool allowDamageEvent = true)
        {
            RayCastFast(origin, direction, out hitInfo, maxDistance, false, 0, ColliderTypes.IgnorePlayer);
            VoxelChunk chunk = hitInfo.chunk;

            if (chunk == null || hitInfo.voxelIndex < 0)
            {
                lastHitInfo.chunk      = null;
                lastHitInfo.voxelIndex = -1;
                return(false);
            }

            lastHitInfo = hitInfo;
            DamageVoxelFast(ref hitInfo, damage, addParticles, playSound, allowDamageEvent);

            bool button1Pressed = input.GetButton(InputButtonNames.Button1);
            bool button2Pressed = input.GetButton(InputButtonNames.Button2);

            if ((button1Pressed || button2Pressed) && OnVoxelClick != null)
            {
                OnVoxelClick(chunk, hitInfo.voxelIndex, button1Pressed ? 0 : 1, hitInfo);
            }

            if (damageRadius > 1)
            {
                Vector3 otherPos;
                Vector3 explosionPosition = hitInfo.voxelCenter + hitInfo.normal * damageRadius;
                damageRadius--;

                for (int y = -damageRadius; y <= damageRadius; y++)
                {
                    otherPos.y = lastHitInfo.voxelCenter.y + y;
                    for (int z = -damageRadius; z <= damageRadius; z++)
                    {
                        otherPos.z = lastHitInfo.voxelCenter.z + z;
                        for (int x = -damageRadius; x <= damageRadius; x++)
                        {
                            if (x == 0 && z == 0 && y == 0)
                            {
                                continue;
                            }
                            VoxelChunk otherChunk;
                            int        otherIndex;
                            otherPos.x = lastHitInfo.voxelCenter.x + x;
                            if (GetVoxelIndex(otherPos, out otherChunk, out otherIndex, false))
                            {
                                if (GetVoxelVisibility(otherChunk, otherIndex))
                                {
                                    FastVector.NormalizedDirection(ref explosionPosition, ref otherPos, ref direction);
                                    if (RayCast(explosionPosition, direction, out hitInfo))
                                    {
                                        DamageVoxelFast(ref hitInfo, damage, addParticles, playSound, allowDamageEvent);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }