Ejemplo n.º 1
0
    private void CollapseSandByForce(Vector3 velocity, SandCombiner sandCombiner)
    {
        float scCenterX = sandCombiner.Pivot.x + 0.25f;
        float toCenterX = scCenterX - Pivot.x;
        var   toSand    = new Vector2(toCenterX, -0.25f);

        if (Vector2.Dot(toSand, velocity.XY()) < 0)
        {
            sandCombiner.CollapseNow();
            Rigidbody.AddForce(velocity, ForceMode.VelocityChange);
        }
    }
Ejemplo n.º 2
0
        private bool ShouldSandCollapse(int cellz, SandCombiner sandCombo)
        {
            bool hasFloor   = GetCellBlocking(cellXY + Vector2Int.down).HasSubFlag(SubCellFlags.HasFloor, cellz);
            bool isFullCell = sandCombo.IsFullCell;

            if (isFullCell && !hasFloor)
            {
                return(true);
            }

            bufferUsed = true;
            int tag = GetNextTag();

            sandCombo.SetTagRecursive(tag);
            if (!isFullCell)
            {
                MarkPlaceablesInBuffer(ref cells[cellPos], cellz, tag);
            }

            int c = BuffCToBuffC(new Vector2Int(0, 0), cellz * buffZshift);

            if (!GetCellBlocking(cellXY + Vector2Int.left).HasSubFlag(SubCellFlags.FullEx, cellz))
            {
                MarkPlaceablesInBuffer(ref GetCell(cellXY + Vector2Int.left), cellz, tag);
                if (!DoBorderSandTestAllowSpeedy(c, sandCombo.L1))
                {
                    return(true);
                }
            }

            if (!GetCellBlocking(cellXY + Vector2Int.right).HasSubFlag(SubCellFlags.FullEx, cellz))
            {
                MarkPlaceablesInBuffer(ref GetCell(cellXY + Vector2Int.right), cellz, tag);
                if (!DoBorderSandTestAllowSpeedy(c + 5, sandCombo.L4))
                {
                    return(true);
                }
            }

            if (!isFullCell)
            {
                if (!buffer[BuffCToBuffC(new Vector2Int(1, 4 - sandCombo.L1), cellz * buffZshift)].Stattic ||
                    !buffer[BuffCToBuffC(new Vector2Int(4, 4 - sandCombo.L4), cellz * buffZshift)].Stattic)
                {
                    return(true);
                }
            }

            return(false);
        }