示例#1
0
            private bool RemoveDropAtPosition(FluidLine fluidLine, int removePosition)
            {
                if (fluidLine.length <= 0)
                {
                    Debug.Log("[ERROR] Can't remove from an empty FluidLine.");
                    return(false);
                }

                if (fluidLine.length == 1)
                {
                    // nothing to do
                    DeleteFluidLine(fluidLine);
                    return(true);
                }

                if (removePosition >= 0 && removePosition < fluidLine.length)
                {
                    if (removePosition == 0)
                    {
                        // remove left
                        fluidLine.RemoveDropLeft();
                        return(true);
                    }
                    else if (removePosition == fluidLine.length - 1)
                    {
                        // remove right
                        fluidLine.RemoveDropRight();
                        return(true);
                    }
                    else
                    {
                        // remove in the middle. The two lines left and right exist
                        // because we arent removing the left or right end.

                        FluidLine rightFluidLine = fluidLine.Split(removePosition, UpdateID);
                        RegisterFluidLine(rightFluidLine);
                        if (rightFluidLine.length == 0)
                        {
                            Debug.Log("Adding empty FluidLine: " + rightFluidLine.ToString());
                        }
                        activeLines.Add(rightFluidLine);

                        return(true);
                    }
                }
                else
                {
                    Debug.Log("[ERROR] Remove position not inside the fluidLine.");
                    return(false);
                }
            }