Esempio n. 1
0
    static void setANTOrderAndSaveAllLevels(BasePart thePart)
    {
        NXOpen.Assemblies.Component root = thePart.ComponentAssembly.RootComponent;
        if (root == null)
        {
            return;
        }

        PartLoadStatus loadStatus;

        theSession.Parts.SetDisplay(thePart, false, true, out loadStatus);
        reportPartLoadStatus(loadStatus);

        NXOpen.Assemblies.ComponentOrder componentOrder1 =
            (NXOpen.Assemblies.ComponentOrder)
            thePart.ComponentAssembly.OrdersSet.FindObject("Alphabetic");
        componentOrder1.Activate();

        thePart.Save(BasePart.SaveComponents.False, BasePart.CloseAfterSave.False);

        foreach (NXOpen.Assemblies.Component kid in root.GetChildren())
        {
            setANTOrderAndSaveAllLevels((BasePart)kid.Prototype);
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter(Collider col)
    {
        if (this.disabled || WPFMonoBehaviour.levelManager.gameState == LevelManager.GameState.Completed)
        {
            return;
        }
        BasePart basePart = this.FindPart(col);

        if (basePart && WPFMonoBehaviour.levelManager && WPFMonoBehaviour.levelManager.ContraptionRunning)
        {
            WPFMonoBehaviour.levelManager.ContraptionRunning.FinishConnectedComponentSearch();
            BasePart basePart2 = WPFMonoBehaviour.levelManager.ContraptionRunning.FindPig();
            if (WPFMonoBehaviour.levelManager.ContraptionRunning.IsConnectedToPig(basePart, col))
            {
                this.Collect();
            }
            else if (basePart.m_partType == BasePart.PartType.GoldenPig)
            {
                this.Collect();
            }
            else
            {
                List <BasePart> parts = WPFMonoBehaviour.levelManager.ContraptionRunning.Parts;
                for (int i = 0; i < parts.Count; i++)
                {
                    BasePart basePart3 = parts[i];
                    if (basePart3 != null && basePart3.ConnectedComponent == basePart.ConnectedComponent && Vector3.Distance(basePart3.transform.position, basePart2.transform.position) < 2.5f)
                    {
                        this.Collect();
                        break;
                    }
                }
            }
        }
    }
Esempio n. 3
0
    protected new bool CheckIfPartReachedGoal(BasePart part, Collider collider, BasePart.PartType targetType)
    {
        BasePart basePart = WPFMonoBehaviour.levelManager.ContraptionRunning.FindPart(targetType);

        if (!basePart)
        {
            return(false);
        }
        bool flag = WPFMonoBehaviour.levelManager.ContraptionRunning.IsConnectedTo(part, collider, basePart);

        if (flag)
        {
            this.OnGoalEnter(basePart);
            return(true);
        }
        List <BasePart> parts = WPFMonoBehaviour.levelManager.ContraptionRunning.Parts;

        for (int i = 0; i < parts.Count; i++)
        {
            BasePart basePart2 = parts[i];
            if (basePart2 && basePart2.ConnectedComponent == part.ConnectedComponent)
            {
                this.OnGoalEnter(basePart);
                return(true);
            }
        }
        return(false);
    }
Esempio n. 4
0
    public static void SetPartUsed(BasePart part, bool used)
    {
        string key = string.Format("{0}_isUsed", part.name);

        if (!used && !GameProgress.HasKey(key, GameProgress.Location.Local, null))
        {
            GameProgress.SetBool(key, used, GameProgress.Location.Local);
        }
        else if (used && !GameProgress.GetBool(key, false, GameProgress.Location.Local, null))
        {
            GameProgress.SetBool(key, used, GameProgress.Location.Local);
            PlayerProgress.ExperienceType experienceType = PlayerProgress.ExperienceType.NewCommonPartViewed;
            if (part.m_partTier == BasePart.PartTier.Rare)
            {
                experienceType = PlayerProgress.ExperienceType.NewRarePartViewed;
            }
            else if (part.m_partTier == BasePart.PartTier.Epic)
            {
                experienceType = PlayerProgress.ExperienceType.NewEpicPartViewed;
            }
            else if (part.m_partTier == BasePart.PartTier.Legendary)
            {
                experienceType = PlayerProgress.ExperienceType.NewLegendaryPartViewed;
            }
            Singleton <PlayerProgress> .Instance.AddExperience(experienceType);
        }
    }
        public static void SampleScales(BasePart limb, string scaleType, out Vector3 scaleR15, out Vector3 scaleNormal, out Vector3 scaleSlender)
        {
            string  limbName       = limb.Name;
            Vector3 sampleNoChange = new Vector3(1, 1, 1);

            // Sample the scaling tables
            Vector3 sampleR15ToNormal = R15_TO_RTHRO_NORMAL[limbName];
            Vector3 sampleNormalToR15 = RTHRO_NORMAL_TO_R15[limbName];

            Vector3 sampleR15ToSlender = R15_TO_RTHRO_SLENDER[limbName];
            Vector3 sampleSlenderToR15 = RTHRO_SLENDER_TO_R15[limbName];

            Vector3 sampleNormalToSlender = (sampleR15ToNormal / sampleR15ToSlender);
            Vector3 sampleSlenderToNormal = (sampleR15ToSlender / sampleR15ToNormal);

            if (scaleType == "Normal")
            {
                scaleR15     = sampleNormalToR15;
                scaleNormal  = sampleNoChange;
                scaleSlender = sampleNormalToSlender;
            }
            else if (scaleType == "Slender")
            {
                scaleR15     = sampleSlenderToR15;
                scaleNormal  = sampleSlenderToNormal;
                scaleSlender = sampleNoChange;
            }
            else
            {
                scaleR15     = sampleNoChange;
                scaleNormal  = sampleR15ToNormal;
                scaleSlender = sampleR15ToSlender;
            }
        }
 public static void Interacted(BasePart part)
 {
     if (OnInteracted != null)
     {
         OnInteracted.Invoke(part);
     }
 }
Esempio n. 7
0
 private void OnDataLoaded()
 {
     foreach (GameObject gameObject in WPFMonoBehaviour.gameData.m_parts)
     {
         BasePart component = gameObject.GetComponent <BasePart>();
         if (component.m_partType == this.partType)
         {
             if (this.partSpriteParent == null)
             {
                 this.partSpriteParent = new GameObject(string.Format("PartVisualisation_{0}", this.partType));
             }
             GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(component.m_constructionIconSprite.gameObject);
             gameObject2.layer             = base.gameObject.layer;
             this.partSprite               = gameObject2.transform;
             this.partSprite.name          = "PartVisualisation";
             this.partSprite.parent        = this.partSpriteParent.transform;
             this.partSprite.localPosition = Vector3.zero;
             this.partSprite.localRotation = Quaternion.identity;
             this.partSprite.GetComponent <Renderer>().enabled = false;
             if (this.collectAnimation != null)
             {
                 Animation animation = this.partSprite.gameObject.AddComponent <Animation>();
                 animation.playAutomatically = false;
                 animation.AddClip(this.collectAnimation, this.collectAnimation.name);
             }
         }
     }
     if (GameProgress.HasKey(string.Format("{0}_star_{1}", Singleton <GameManager> .Instance.CurrentSceneName, base.NameKey), GameProgress.Location.Local, null) && !GameProgress.HasKey(string.Format("{0}_part_{1}", Singleton <GameManager> .Instance.CurrentSceneName, base.NameKey), GameProgress.Location.Local, null))
     {
         GameProgress.AddPartBox(Singleton <GameManager> .Instance.CurrentSceneName, base.NameKey);
         GameProgress.AddSandboxParts(Singleton <GameManager> .Instance.CurrentSceneName, this.partType, this.count, true);
     }
 }
        public static void OverwriteHead(DataModelMesh mesh, BasePart head)
        {
            Contract.Requires(mesh != null && head != null);
            DataModelMesh currentMesh = head.FindFirstChild <DataModelMesh>("Mesh");

            if (currentMesh != null)
            {
                currentMesh.Destroy();
            }

            mesh.Name   = "Mesh";
            mesh.Parent = head;

            // Apply Rthro adjustments
            Vector3Value[] overrides = mesh.GetChildrenOfType <Vector3Value>();

            foreach (Vector3Value overrider in overrides)
            {
                Attachment attachment = head.FindFirstChild <Attachment>(overrider.Name);
                if (attachment != null)
                {
                    CFrame cf = attachment.CFrame;
                    attachment.CFrame = new CFrame(overrider.Value) * (cf - cf.Position);
                }
            }

            // Move any extra instances into the Head.
            var extraInstances = mesh.GetChildren()
                                 .Except(overrides)
                                 .ToList();

            extraInstances.ForEach((inst) => inst.Parent = head);
        }
Esempio n. 9
0
    public void Pop()
    {
        if (!this.m_popped)
        {
            this.m_popped = true;
            AudioSource effectSource;
            if (this.m_ghostBalloon)
            {
                effectSource = WPFMonoBehaviour.gameData.commonAudioCollection.ghostBalloonPop[UnityEngine.Random.Range(0, WPFMonoBehaviour.gameData.commonAudioCollection.ghostBalloonPop.Length)];
            }
            else
            {
                effectSource = WPFMonoBehaviour.gameData.commonAudioCollection.balloonPop;
            }
            Singleton <AudioManager> .Instance.SpawnOneShotEffect(effectSource, base.transform.position);

            WPFMonoBehaviour.effectManager.CreateParticles(WPFMonoBehaviour.gameData.m_ballonParticles, base.transform.position, false);
            base.contraption.ChangeOneShotPartAmount(BasePart.BaseType(this.m_partType), this.EffectDirection(), -1);
            if (this.m_balancer)
            {
                this.m_balancer.RemoveBalloon();
            }
            this.CheckBalloonPopperAchievement();
            base.contraption.RemovePart(this);
            UnityEngine.Object.Destroy(base.gameObject);
        }
    }
Esempio n. 10
0
        public static BoneKeyframe AssembleBones(StudioMdlWriter meshBuilder, BasePart rootPart)
        {
            Rbx2Source.Print("Building Skeleton...");

            BoneKeyframe kf = new BoneKeyframe();

            List <Bone> bones = kf.Bones;
            List <Node> nodes = meshBuilder.Nodes;

            Bone rootBone = new Bone(rootPart.Name, rootPart);

            rootBone.C0           = new CFrame();
            rootBone.IsAvatarBone = true;
            bones.Add(rootBone);

            Node rootNode = rootBone.Node;

            rootNode.NodeIndex = 0;
            nodes.Add(rootNode);

            // Assemble the base rig.
            BoneAssemblePrep prep = new BoneAssemblePrep(ref bones, ref nodes);

            GenerateBones(prep, rootPart.GetChildrenOfClass <Attachment>());

            // Assemble the accessories.
            prep.AllowNonRigs = true;
            GenerateBones(prep, prep.NonRigs.ToArray());

            // Apply the rig cframe data.
            ApplyBoneCFrames(rootPart);
            meshBuilder.Skeleton.Add(kf);

            return(kf);
        }
Esempio n. 11
0
    //------------------------------------------------------------------------------
    //  Explicit Activation
    //      This entry point is used to activate the application explicitly
    //------------------------------------------------------------------------------
    public static int Main(string[] args)
    {
        int retValue = 0;

        try
        {
            theProgram = new Program();

            //TODO: Add your application code here
            for (int ii = 0; ii < args.Length; ii++)
            {
                Echo("Processing: [" + ii.ToString() + "] = " + args[ii]);
                PartLoadStatus loadStatus;
                Echo("open part");
                workPart = (Part)theSession.Parts.OpenBaseDisplay(args[ii], out loadStatus);

                //workPart = (Part)theSession.Parts.Work;
                if (workPart != null)
                {
                    Echo("before pdf func");
                    DoIt();
                    Echo("After pdf func");
                    workPart.Close(BasePart.CloseWholeTree.True, BasePart.CloseModified.CloseModified, null);
                }
            }


            theProgram.Dispose();
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
        }
        return(retValue);
    }
Esempio n. 12
0
    private void UpdatePart()
    {
        if (this.favoritePart != null)
        {
            UnityEngine.Object.Destroy(this.favoritePart);
        }
        if (Singleton <CakeRaceKingsFavorite> .Instance.CurrentFavorite == null)
        {
            this.Close();
        }
        BasePart currentFavorite = Singleton <CakeRaceKingsFavorite> .Instance.CurrentFavorite;

        this.favoritePart = UnityEngine.Object.Instantiate <GameObject>(this.partTierBackgrounds[(int)currentFavorite.m_partTier]);
        this.favoritePart.transform.parent        = this.partRoot;
        this.favoritePart.transform.localScale    = Vector3.one * 0.7f;
        this.favoritePart.transform.localPosition = Vector3.zero;
        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(currentFavorite.m_constructionIconSprite.gameObject);

        gameObject.transform.localScale    = Vector3.one;
        gameObject.transform.parent        = this.favoritePart.transform;
        gameObject.transform.localPosition = Vector3.back * 0.1f;
        gameObject.transform.localRotation = Quaternion.identity;
        LayerHelper.SetLayer(this.favoritePart, base.gameObject.layer, true);
        LayerHelper.SetSortingLayer(this.favoritePart, "Popup", true);
    }
Esempio n. 13
0
    public void LoadAssmbly()
    {
        this.Dirs();

        string Asms = NS["ASM"];

        newSession.Parts.LoadOptions.UsePartialLoading = false;

        //https://community.plm.automation.siemens.com/t5/NX-Programming-Customization-Forum/How-to-fully-load-a-part-using-NXOpen/td-p/338330

        PartLoadStatus PLD;
        BasePart       Asm = newSession.Parts.OpenDisplay(Asms, out PLD);

        PlaceDefaultPos(Asm, NS["NUT"]);
        PlaceDefaultPos(Asm, NS["BOLT"]);
        PlaceDefaultPos(Asm, NS["WSH"]);
        PlaceDefaultPos(Asm, NS["WSH"]);

        Assembly = Asm;

        PartSaveStatus PS;
        bool           Partsmod;

        newSession.Parts.SaveAll(out Partsmod, out PS);

        //Component Comp = Asm.ComponentAssembly.RootComponent;

        //foreach (Component C in Comp.GetChildren())
        //{
        //    BasePart T = C.OwningPart;
        //    T.LoadFully();

        //}
    }
Esempio n. 14
0
    public override void ChangeVisualConnections()
    {
        bool flag  = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.Up, this.m_gridRotation));
        bool flag2 = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.Down, this.m_gridRotation));
        bool flag3 = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.Left, this.m_gridRotation));
        bool flag4 = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.Right, this.m_gridRotation));
        bool flag5 = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.UpLeft, this.m_gridRotation));
        bool flag6 = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.DownLeft, this.m_gridRotation));
        bool flag7 = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.UpRight, this.m_gridRotation));
        bool flag8 = base.contraption.CanConnectTo(this, BasePart.Rotate(BasePart.Direction.DownRight, this.m_gridRotation));
        bool flag9 = this.m_gridRotation == BasePart.GridRotation.Deg_135 || this.m_gridRotation == BasePart.GridRotation.Deg_45 || this.m_gridRotation == BasePart.GridRotation.Deg_225 || this.m_gridRotation == BasePart.GridRotation.Deg_315;

        this.m_leftAttachment.SetActive(flag3 && !flag9);
        this.m_rightAttachment.SetActive(flag4 && !flag9);
        this.m_topAttachment.SetActive(flag && !flag9);
        this.m_bottomAttachment.SetActive((flag2 && !flag9) || (!flag && !flag3 && !flag4 && !flag9));
        this.m_bottomLeftAttachment.SetActive(flag6 && flag9);
        this.m_bottomRightAttachment.SetActive(flag8 && flag9);
        this.m_topLeftAttachment.SetActive(flag5 && flag9);
        this.m_topRightAttachment.SetActive(flag7 && flag9);
        if (!flag && !flag6 && !flag3 && !flag4 && !flag5 && !flag6 && !flag7 && !flag8)
        {
            this.m_bottomAttachment.SetActive(true);
        }
    }
Esempio n. 15
0
    public override Joint CustomConnectToPart(BasePart part)
    {
        ConfigurableJoint configurableJoint = base.gameObject.AddComponent <ConfigurableJoint>();

        configurableJoint.connectedBody          = part.rigidbody;
        configurableJoint.angularXMotion         = ConfigurableJointMotion.Locked;
        configurableJoint.angularYMotion         = ConfigurableJointMotion.Locked;
        configurableJoint.angularZMotion         = ConfigurableJointMotion.Locked;
        configurableJoint.xMotion                = ConfigurableJointMotion.Locked;
        configurableJoint.yMotion                = ConfigurableJointMotion.Limited;
        configurableJoint.zMotion                = ConfigurableJointMotion.Locked;
        configurableJoint.enablePreprocessing    = false;
        configurableJoint.configuredInWorldSpace = true;
        configurableJoint.breakForce             = 250f;
        SoftJointLimitSpring linearLimitSpring = configurableJoint.linearLimitSpring;

        linearLimitSpring.spring            = 250f;
        linearLimitSpring.damper            = 20f;
        configurableJoint.linearLimitSpring = linearLimitSpring;
        SoftJointLimit linearLimit = configurableJoint.linearLimit;

        linearLimit.limit             = 0.1f;
        linearLimit.bounciness        = 1f;
        configurableJoint.linearLimit = linearLimit;
        this.m_connectedBody          = part.rigidbody;
        this.m_localConnectionPoint   = new Vector3(0f, 0.5f, 0f);
        this.m_remoteConnectionPoint  = part.transform.InverseTransformPoint(base.transform.position - 0.5f * base.transform.up);
        this.joint = configurableJoint;
        return(configurableJoint);
    }
Esempio n. 16
0
    public void CustomButtonPressed(int partTypeIndex, int partIndex)
    {
        if (this.cachedPartListing.LastMovement > 1.5f)
        {
            return;
        }
        BasePart customPart = WPFMonoBehaviour.gameData.GetCustomPart((BasePart.PartType)partTypeIndex, partIndex);

        this.cachedPartListing.UpdateSelectionIcon((BasePart.PartType)partTypeIndex, customPart.name);
        this.cachedPartListing.PlaySelectionAudio((BasePart.PartType)partTypeIndex, customPart.name);
        if (!CustomizationManager.IsPartUsed(customPart))
        {
            this.cachedPartListing.ShowExperienceParticles((BasePart.PartType)partTypeIndex, customPart.name);
            CustomizationManager.SetPartUsed(customPart, true);
        }
        if (CustomizationManager.IsPartNew(customPart))
        {
            CustomizationManager.SetPartNew(customPart, false);
        }
        CustomizationManager.SetLastUsedPartIndex((BasePart.PartType)partTypeIndex, partIndex);
        EventManager.Send(new PartCustomizationEvent((BasePart.PartType)partTypeIndex, partIndex));
        if (this.onButtonPressed != null)
        {
            this.onButtonPressed((BasePart.PartType)partTypeIndex);
            if (this.customPartWidget != null)
            {
                this.customPartWidget.ClosePastList();
            }
        }
    }
Esempio n. 17
0
        private int FindParent(List <Node> nodes)
        {
            BasePart part0 = Bone.Part0,
                     part1 = Bone.Part1;

            if (part0 != part1)
            {
                Node parent = null;

                foreach (Node n in nodes)
                {
                    Bone b = n.Bone;

                    if (b != Bone && b.Part1 == part0)
                    {
                        parent = n;
                        break;
                    }
                }

                return(nodes.IndexOf(parent));
            }

            return(-1);
        }
Esempio n. 18
0
 /// <summary>
 ///     Map gen constructor
 /// </summary>
 /// <param name="seed">The seed to use for generation</param>
 /// <param name="tileBase">The part type to use for the asteroid material</param>
 public MapGenerator(int seed, BasePart tileBase)
 {
     Random.InitState(seed);
     xOffset       = (int)(Random.value * 1e6);
     yOffset       = (int)(Random.value * 1e6);
     this.tileBase = tileBase;
 }
Esempio n. 19
0
    protected override void OnTouch()
    {
        if (!this.m_enabled && this.CanBeEnabled() && Time.time - this.m_plungerTimer > this.m_plungerResetTimer)
        {
            this.Shoot();
        }
        else if (this.m_State == GrapplingHook.State.Shoot || this.m_State == GrapplingHook.State.Winding || this.m_State == GrapplingHook.State.Idle)
        {
            Singleton <AudioManager> .Instance.SpawnOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.grapplingHookMiss, base.transform.position);

            this.m_State = GrapplingHook.State.Rewind;
            base.contraption.SetHangingFromHook(false, base.GetInstanceID());
            this.m_ReWindingStartTime = Time.time;
            if (Singleton <SocialGameManager> .IsInstantiated() && base.contraption.IsConnectedToPig(this, base.GetComponent <Collider>()) && !base.contraption.GetHangingFromHook() && Mathf.Abs(base.rigidbody.velocity.x) > 3f)
            {
                base.contraption.SetSwings(base.contraption.GetSwings() + 1);
                Singleton <SocialGameManager> .Instance.ReportAchievementProgress("grp.SWINGIN_PIGGIES", 100.0);

                BasePart basePart = base.contraption.FindPartOfType(BasePart.PartType.KingPig);
                if (base.contraption.GetSwings() > 1 && basePart && base.contraption.IsConnectedToPig(basePart, basePart.GetComponent <Collider>()))
                {
                    Singleton <SocialGameManager> .Instance.ReportAchievementProgress("grp.KING_PIG_OF_THE_JUNGLE", 100.0);
                }
            }
        }
    }
Esempio n. 20
0
    protected override void OnGoalEnter(BasePart part)
    {
        if (this.collected)
        {
            return;
        }
        AudioSource win_snd = new GameObject("win_snd").AddComponent <AudioSource>();

        //win_snd.gameObject.tag = "m_engineSetup";
        win_snd.GetComponent <AudioSource>().clip = (AudioClip)Resources.Load("AudioAdd" + Path.DirectorySeparatorChar + "win_snd");
        //win_snd.GetComponent<AudioSource>().Play();
        win_snd.GetComponent <AudioSource>().loop   = false;
        win_snd.GetComponent <AudioSource>().volume = 1f;
        win_snd.GetComponent <AudioSource>().Play();

        WPFMonoBehaviour.levelManager.NotifyGoalReachedByPart(part.m_partType);
        if (WPFMonoBehaviour.levelManager.PlayerHasRequiredObjects())
        {
            this.m_flagObject.GetComponent <Animation>().Play();
            if (this.m_goalAchievement)
            {
                this.m_goalAchievement.GetComponent <Animation>().Play();
            }
            if (this.m_goalParticles != null)
            {
                this.m_goalParticles.Stop();
            }
            WPFMonoBehaviour.levelManager.NotifyGoalReached();
            this.collected = true;
            EventManager.Send(default(ObjectiveAchieved));
            this.DisableGoal();
        }
    }
Esempio n. 21
0
        public PartData(BasePart part, PartListing partListInstance)
        {
            PartListing.PartData.partList = partListInstance;
            this.parts = new Dictionary <BasePart.PartTier, List <BasePart> >();
            this.parts.Add(part.m_partTier, new List <BasePart>());
            this.parts[part.m_partTier].Add(part);
            this.type = part.m_partType;
            CustomPartInfo customPart = WPFMonoBehaviour.gameData.GetCustomPart(part.m_partType);

            this.partInstances = new Dictionary <BasePart.PartTier, List <GameObject> >();
            this.partInstances.Add(part.m_partTier, new List <GameObject>());
            this.selectedIcon = null;
            if (customPart == null)
            {
                return;
            }
            for (int i = 0; i < customPart.PartList.Count; i++)
            {
                if (customPart.PartList[i].VisibleOnPartListBeforeUnlocking)
                {
                    if (!this.parts.ContainsKey(customPart.PartList[i].m_partTier))
                    {
                        this.parts.Add(customPart.PartList[i].m_partTier, new List <BasePart>());
                    }
                    this.parts[customPart.PartList[i].m_partTier].Add(customPart.PartList[i]);
                    if (!this.partInstances.ContainsKey(customPart.PartList[i].m_partTier))
                    {
                        this.partInstances.Add(customPart.PartList[i].m_partTier, new List <GameObject>());
                    }
                }
            }
        }
        public static void PrepareAccessory(Instance asset, Folder assembly)
        {
            Contract.Requires(asset != null && assembly != null);

            if (DEBUG_RAPID_ASSEMBLY)
            {
                asset.Destroy();
                return;
            }

            BasePart handle = asset.FindFirstChild <BasePart>("Handle");

            if (handle != null)
            {
                handle.Name   = FileUtility.MakeNameWindowsSafe(asset.Name);
                handle.CFrame = new CFrame();
                handle.Parent = assembly;

                if (asset is Accessory) // Make sure the attachment is in the Handle
                {
                    Attachment accAtt = asset.FindFirstChildOfClass <Attachment>();

                    if (accAtt == null)
                    {
                        return;
                    }

                    accAtt.Parent = handle;
                }
            }
        }
Esempio n. 23
0
 public virtual BasePart.GridRotation AutoAlignRotation(BasePart.JointConnectionDirection target)
 {
     if (this.m_jointConnectionDirection == BasePart.JointConnectionDirection.None)
     {
         return(BasePart.RotationTo(this.m_customJointConnectionDirection, target));
     }
     return(BasePart.RotationTo(this.m_jointConnectionDirection, target));
 }
        private static void GenerateBones(BoneAssemblePrep prep, Attachment[] queue)
        {
            if (queue.Length == 0)
            {
                return;
            }

            Instance bin = queue[0].Parent.Parent;

            foreach (Attachment a0 in queue)
            {
                List <Attachment> a1s = FindOtherAttachments(a0, bin);

                foreach (Attachment a1 in a1s)
                {
                    if (a1 != null && !prep.Completed.Contains(a1))
                    {
                        BasePart part0 = (BasePart)a0.Parent;
                        BasePart part1 = (BasePart)a1.Parent;

                        bool isRigAttachment = a0.Name.EndsWith("RigAttachment", StringComparison.InvariantCulture);

                        if (isRigAttachment || prep.AllowNonRigs)
                        {
                            StudioBone bone = new StudioBone(part1.Name, part0, part1)
                            {
                                C0 = a0.CFrame,
                                C1 = a1.CFrame,
                            };

                            bone.IsAvatarBone = !prep.AllowNonRigs;
                            prep.Bones.Add(bone);

                            Node node = bone.Node;
                            node.NodeIndex = prep.Bones.IndexOf(bone);
                            prep.Nodes.Add(node);

                            if (!prep.Completed.Contains(a0))
                            {
                                prep.Completed.Add(a0);
                            }

                            prep.Completed.Add(a1);

                            if (!prep.AllowNonRigs)
                            {
                                GenerateBones(prep, part1.GetChildrenOfType <Attachment>());
                            }
                        }
                        else // We'll deal with Accessory attachments afterwards.
                        {
                            prep.NonRigs.Add(a0);
                        }
                    }
                }
            }
        }
Esempio n. 25
0
    private void OnTriggerEnter(Collider other)
    {
        BasePart component = other.GetComponent <BasePart>();

        if (component)
        {
            this.affectedParts.Add(component);
        }
    }
Esempio n. 26
0
    private void OnTriggerExit(Collider other)
    {
        BasePart component = other.GetComponent <BasePart>();

        if (component)
        {
            this.affectedParts.Remove(component);
        }
    }
Esempio n. 27
0
 public void OpenCustomizationForPart(BasePart part, Action <BasePart.PartType> onClose = null)
 {
     this.onPartListClose = onClose;
     if (part)
     {
         this.centerPart = part.m_partType;
     }
     this.OpenPartList();
 }
Esempio n. 28
0
    private BasePart InstantiatePart(int coordX, int coordY, BasePart partPrefab)
    {
        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(partPrefab.gameObject);
        BasePart   component  = gameObject.GetComponent <BasePart>();

        component.PrePlaced();
        this.m_contraption.SetPartAt(coordX, coordY, component);
        return(component);
    }
    public void LoadAllItems()
    {
        foreach (Transform child in headContentDisplay)
        {
            GameObject.Destroy(child.gameObject);
        }
        foreach (Transform child in torsoContentDisplay)
        {
            GameObject.Destroy(child.gameObject);
        }
        foreach (Transform child in armsContentDisplay)
        {
            GameObject.Destroy(child.gameObject);
        }
        foreach (Transform child in legsContentDisplay)
        {
            GameObject.Destroy(child.gameObject);
        }

        List <PartData> partDataList = PartsTable.instance.GetPartsByType(BasePart.LIMB_TYPE.LIMB_END);

        foreach (PartData data in partDataList)
        {
            BasePart part = null;
            part = CreatePartAsImage(data);
            Button btn = (new GameObject()).AddComponent <Button>();
            btn.onClick.AddListener(() => SelectFromInventory(btn.transform.GetChild(0).gameObject));
            btn.gameObject.AddComponent <RectTransform>();
            switch ((BasePart.LIMB_TYPE)(data.partType))
            {
            case BasePart.LIMB_TYPE.LIMB_HEAD:
                btn.gameObject.GetComponent <RectTransform>().SetParent(headContentDisplay);
                break;

            case BasePart.LIMB_TYPE.LIMB_TORSO:
                btn.gameObject.GetComponent <RectTransform>().SetParent(torsoContentDisplay);
                break;

            case BasePart.LIMB_TYPE.LIMB_ARM:
                btn.gameObject.GetComponent <RectTransform>().SetParent(armsContentDisplay);
                break;

            case BasePart.LIMB_TYPE.LIMB_LEG:
                btn.gameObject.GetComponent <RectTransform>().SetParent(legsContentDisplay);
                break;

            default:
                break;
            }

            part.GetComponent <RectTransform>().SetParent(btn.transform);
            part.GetComponent <RectTransform>().sizeDelta = btn.gameObject.GetComponent <RectTransform>().sizeDelta;

            btn.gameObject.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
        }
    }
Esempio n. 30
0
    private BasePart GetRandomPart(BasePart.PartTier tier)
    {
        BasePart randomCraftablePartFromTier = CustomizationManager.GetRandomCraftablePartFromTier(tier, true);

        if (randomCraftablePartFromTier == null)
        {
            randomCraftablePartFromTier = CustomizationManager.GetRandomCraftablePartFromTier(tier, false);
        }
        return(randomCraftablePartFromTier);
    }