Example #1
0
    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);
        }
    }
Example #2
0
 public static void RemoveSuperGlue(List <BasePart> parts)
 {
     foreach (BasePart basePart in parts)
     {
         if (Glue.IsPartTypeRequireGlue(basePart.m_partType))
         {
             Glue component = basePart.GetComponent <Glue>();
             if (component != null)
             {
                 for (int i = basePart.transform.childCount - 1; i >= 0; i--)
                 {
                     GameObject gameObject = basePart.transform.GetChild(i).gameObject;
                     if (gameObject.name.StartsWith(WPFMonoBehaviour.gameData.m_glueSprite.name) || gameObject.name.StartsWith(WPFMonoBehaviour.gameData.m_alienGlueSprite.name))
                     {
                         UnityEngine.Object.DestroyImmediate(gameObject);
                     }
                 }
                 UnityEngine.Object.DestroyImmediate(component);
             }
         }
     }
 }
Example #3
0
 public static void ShowSuperGlue(Contraption contraption, Type type, List <BasePart> parts)
 {
     foreach (BasePart basePart in parts)
     {
         if (Glue.IsPartTypeRequireGlue(basePart.m_partType))
         {
             BasePart anotherPart  = contraption.FindPartAt(basePart.m_coordX - 1, basePart.m_coordY);
             BasePart anotherPart2 = contraption.FindPartAt(basePart.m_coordX + 1, basePart.m_coordY);
             BasePart anotherPart3 = contraption.FindPartAt(basePart.m_coordX, basePart.m_coordY - 1);
             BasePart anotherPart4 = contraption.FindPartAt(basePart.m_coordX, basePart.m_coordY + 1);
             Glue     exists       = basePart.GetComponent <Glue>();
             if (exists == null)
             {
                 exists = basePart.gameObject.AddComponent <Glue>();
             }
             Glue.CheckSideAndAppendGlue(basePart, anotherPart, Glue.Direction.Left, type);
             Glue.CheckSideAndAppendGlue(basePart, anotherPart2, Glue.Direction.Right, type);
             Glue.CheckSideAndAppendGlue(basePart, anotherPart4, Glue.Direction.Up, type);
             Glue.CheckSideAndAppendGlue(basePart, anotherPart3, Glue.Direction.Down, type);
         }
     }
 }