示例#1
0
文件: Glue.cs 项目: mrdivdiz/bpvita
    private static void CheckSideAndAppendGlue(BasePart partWithGlue, BasePart anotherPart, Direction dir, Type type)
    {
        bool flag      = dir == Glue.Direction.Up || dir == Glue.Direction.Down;
        bool flag2     = dir == Glue.Direction.Left || dir == Glue.Direction.Right;
        Glue component = partWithGlue.GetComponent <Glue>();

        if (anotherPart != null)
        {
            Glue component2 = anotherPart.GetComponent <Glue>();
            BasePart.JointConnectionDirection jointConnectionDirection = anotherPart.GetJointConnectionDirection();
            bool flag3 = BasePart.IsDirection(jointConnectionDirection);
            bool flag4 = (flag3 && Glue.OppositeGlueDir(BasePart.ConvertDirection(jointConnectionDirection)) == dir) || (flag && jointConnectionDirection == BasePart.JointConnectionDirection.UpAndDown) || (flag2 && jointConnectionDirection == BasePart.JointConnectionDirection.LeftAndRight) || (jointConnectionDirection == BasePart.JointConnectionDirection.Any && anotherPart.GetJointConnectionType() != BasePart.JointConnectionType.None);
            if ((component.m_GlueDirectionMask & (int)dir) == 0)
            {
                if (component2)
                {
                    if ((component2.m_GlueDirectionMask & (int)Glue.OppositeGlueDir(dir)) == 0)
                    {
                        Glue.AddSuperGlueSprite(component, dir, type);
                    }
                }
                else if (Glue.IsPartTypeRequireGlue(anotherPart.m_partType) || flag4)
                {
                    Glue.AddSuperGlueSprite(component, dir, type);
                }
                else
                {
                    Glue.RemoveSuperGlueSprite(component, dir);
                }
            }
            else if (!Glue.IsPartTypeRequireGlue(anotherPart.m_partType) && !flag4)
            {
                Glue.RemoveSuperGlueSprite(component, dir);
            }
        }
        else if (!anotherPart && (component.m_GlueDirectionMask & (int)dir) != 0)
        {
            Glue.RemoveSuperGlueSprite(component, dir);
        }
    }