Example #1
0
        void RefreshLineRenderer(Attachment attachment)
        {
            if (attachment.objects.Count(phase: AttachObjectPhase.Connected) != attachment.objects.Count())
            {
                return;
            }
            LineStrategyState state = (LineStrategyState)attachment.strategyState;

            if (state.objects == null || state.objects.Length != attachment.objects.Count())
            {
                state.objects = new AttachObject[attachment.objects.Count()];
            }
            int i = 0;

            for (int c = 0; c < GetCategories().Length; c++)
            {
                AttachObjectList.Enumerator e = attachment.objects.GetEnumerator(c);
                while (e.MoveNext())
                {
                    state.objects[i] = e.Current;
                    i++;
                }
            }
            LineAttachStrategyUtility.RefreshLineRenderer(lineRendererDescription, state.lineState, state.objects,
                                                          null, hideLineRendererInInspector);
        }
        public override void DoLateUpdate(Attachment attachment)
        {
            AttachObject target = GetTarget(attachment);

            if (target == null || !target.isConnected)
            {
                return;
            }
            AttachObjectList.Enumerator e = attachment.objects.GetEnumerator(category: (int)Categories.Followers,
                                                                             phase: AttachObjectPhase.Connected);
            while (e.MoveNext())
            {
                AttachObject follower = e.Current;
                ClingyFollowing.FollowingAttachStrategyUtility.FollowTarget(target, follower, positionOptions,
                                                                            rotationOptions);
            }
        }
        void UpdateFromParamsAndApply(Attachment attachment)
        {
            AttachObject root = GetRoot(attachment);

            if (root == null || !root.isConnected)
            {
                return;
            }
            AttachObjectList.Enumerator e = attachment.objects.GetEnumerator(phase: AttachObjectPhase.Connected,
                                                                             category: (int)Categories.Leaves);
            while (e.MoveNext())
            {
                AttachObject leaf = e.Current;
                PhysicsAttachStrategyHelper.CreateOrApplyAllJoints(leaf, root, jointDescriptions, leaf,
                                                                   hideJointsInInspector);
            }
        }
 void UpdateFromParamsAndApply(Attachment attachment)
 {
     // fixme - updating the anchors will also change a hinge joint's reference angle, which means the limits
     // will change if they are based on the starting rotation. :/  need to only update anchors if they have
     // actually changed.
     AttachObjectList.Enumerator e = attachment.objects.GetEnumerator(phase: AttachObjectPhase.Connected);
     while (e.MoveNext())
     {
         AttachObject link     = e.Current;
         AttachObject nextLink = GetNextLink(link);
         if (nextLink == null || !nextLink.isConnected)
         {
             continue;
         }
         // put the joint on nextLink - so it is also the reference object
         Physics2DAttachStrategyHelper.CreateOrApplyAllJoints(nextLink, link, jointDescriptions,
                                                              nextLink, hideJointsInInspector);
     }
 }
Example #5
0
        void RefreshLineRenderer(Attachment attachment)
        {
            AttachObject root = GetRoot(attachment);

            if (root == null || !root.isConnected)
            {
                return;
            }
            AttachObjectList.Enumerator e = attachment.objects.GetEnumerator((int)Categories.Leaves,
                                                                             phase: AttachObjectPhase.Connected);
            while (e.MoveNext())
            {
                AttachObject    leaf  = e.Current;
                LineObjectState state = (LineObjectState)leaf.state;
                state.objects[0] = root;
                state.objects[1] = leaf;
                ClingyLines.LineAttachStrategyUtility.RefreshLineRenderer(lineRendererDescription, state.lineState,
                                                                          state.objects, leaf, hideLineRenderersInInspector);
            }
        }
        void UpdateFromParamsAndApply(Attachment attachment)
        {
            AttachObject root = GetRoot(attachment);

            if (root == null || !root.isConnected)
            {
                return;
            }
            AttachObjectList.Enumerator e = attachment.objects.GetEnumerator(phase: AttachObjectPhase.Connected,
                                                                             category: (int)Categories.Leaves);
            while (e.MoveNext())
            {
                AttachObject leaf = e.Current;
                // fixme - updating the anchors will also change a hinge joint's reference angle, which means the limits
                // will change if they are based on the starting rotation. :/  need to only update anchors if they have
                // actually changed.
                Physics2DAttachStrategyHelper.CreateOrApplyAllJoints(leaf, root, jointDescriptions, leaf,
                                                                     hideJointsInInspector);
            }
        }
        public override void DoLateUpdate(Attachment attachment)
        {
            AttachObject target = null;

            for (int c = 0; c < GetCategories().Length; c++)
            {
                AttachObjectList.Enumerator e = attachment.objects.GetEnumerator(c);
                while (e.MoveNext())
                {
                    AttachObject follower = e.Current;
                    if (target == null || !follower.isConnected)
                    {
                        target = follower;
                        continue;
                    }
                    FollowingAttachStrategyUtility.FollowTarget(target, follower, positionOptions, rotationOptions);
                    target = follower;
                }
                ;
            }
        }
        public override void DisconnectObjectImmediate(AttachObject obj)
        {
            AttachObject root = GetRoot(obj.attachment);

            if (obj == root)
            {
                AttachObjectList.Enumerator e = obj.attachment.objects.GetEnumerator((int)Categories.Leaves,
                                                                                     phase: AttachObjectPhase.Connected);
                while (e.MoveNext())
                {
                    DisconnectLeaf(root, e.Current);
                }
                DisconnectRoot(root);
            }
            else
            {
                if (root == null || !root.isConnected)
                {
                    return;
                }
                DisconnectLeaf(root, obj);
            }
        }
        public override bool ConnectObject(AttachObject obj)
        {
            AttachObject root = GetRoot(obj.attachment);

            if (obj == root)
            {
                ConnectRoot(obj);
                AttachObjectList.Enumerator e = obj.attachment.objects.GetEnumerator((int)Categories.Leaves,
                                                                                     phase: AttachObjectPhase.Connected);
                while (e.MoveNext())
                {
                    ConnectLeaf(root, e.Current);
                }
            }
            else
            {
                if (root == null || !root.isConnected)
                {
                    return(true);
                }
                ConnectLeaf(root, obj);
            }
            return(true);
        }