예제 #1
0
    public PhysPart SetCurrPart(PhysPart p, bool recalcConnectedParts = true)
    {
        PhysPart oldPart = currPart;

        if (oldPart)                                                             //Deal with previously held part
        {
            foreach (Collider c in oldPart.GetComponentsInChildren <Collider>()) //make previously held part tangible again
            {
                //c.enabled = true;
                c.gameObject.layer = currPartTrueLayer;
            }
            lastObjRot = oldPart.transform.rotation; //save previous obj rotation
        }

        //Deal with held part transition
        currPart = p;

        if (recalcConnectedParts)
        {
            if (oldPart) //Reconnect old held part appropriately
            {
                oldPart.connections = CalculatePartConnections(oldPart);
                oldPart.RecalcConnections(true);
            }
            if (currPart) //Disconnect new held part
            {
                currPart.DisconnectLiteFromAllParts();
            }
            MakeAllDisconnectedPartsGhosty();
        }

        //Deal with currently held part
        if (p != null)
        {
            foreach (Collider c in currPart.GetComponentsInChildren <Collider>()) //make part being held intangible
            {
                //c.enabled = false;
                currPartTrueLayer  = c.gameObject.layer;
                c.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
            }


            MakePartGhosty(currPart, true); //make curr part render ghosty
        }

        return(p);
    }
예제 #2
0
 void MakePartGhosty(PhysPart p, bool ghosty)
 {
     MeshRenderer[] rends = p.GetComponentsInChildren <MeshRenderer>();
     if (ghosty)
     {
         foreach (MeshRenderer r in rends)
         {
             r.material = GhostyMaterial;
         }
     }
     else
     {
         Material[] trueMats = p.GetComponent <EditorPartData>().trueRendMaterials;
         for (int i = 0; i < rends.Length; i++)
         {
             rends[i].material = trueMats[i];
         }
     }
     p.mat_emissiveOn = false; //Material emission will need to be turned on again
 }
예제 #3
0
    public PhysPart MakePartEditorFriendly(PhysPart p)
    {
        //Make it non-solid
        foreach (Collider c in p.GetComponentsInChildren <Collider>())
        {
            c.isTrigger = true;
        }

        //Disable all components
        List <PartComponent> components = new List <PartComponent>(p.components);

        while (components.Count > 0)
        {
            components[0].enabled = false;
            components.RemoveAt(0);
        }
        p.enabled = false;

        //Remember materials
        p.gameObject.AddComponent <EditorPartData>().RememberRendMaterials();

        return(p);
    }