Exemplo n.º 1
0
        private void AttachObject(
            GameObjectReference child, ref GameObject childObject, GameObjectReference parent, ref GameObject parentObject)
        {
            if (child.Uid != childObject.Uid)
            {
                return;
            }

            if (parent.Uid != parentObject.Uid)
            {
                return;
            }

            // TODO: update world position by don't notify yet
            if (childObject.IsMoved)
            {
                this.UpdateWorldPositionAndNotifyComponents(ref childObject);
            }

            if (childObject.Parent != 0)
            {
                childObject.DetachNode(child.Index, this);
            }

            // TODO: update world position by don't notify yet
            if (parentObject.IsMoved)
            {
                this.UpdateWorldPositionAndNotifyComponents(ref parentObject);
            }

            childObject.AttachNodeTail(child.Index, parent.Index, ref parentObject, this);

            childObject.Origin.UpdateLocalPosition(parentObject.Origin);

            this.EnqueuePositionChanged(child.Index, ref childObject);
        }