Exemple #1
0
 public void addElement(ElementContainer element)
 {
     if (element.getErdc().getType() == Controller.ITEM_REFERENCE)
     {
         itemReferencesList.Add((ElementReference)element.getErdc().getContent());
     }
     else if (element.getErdc().getType() == Controller.ATREZZO_REFERENCE)
     {
         atrezzoReferencesList.Add((ElementReference)element.getErdc().getContent());
     }
     else if (element.getErdc().getType() == Controller.NPC_REFERENCE)
     {
         npcReferencesList.Add((ElementReference)element.getErdc().getContent());
     }
     allReferencesDataControl.Insert(element.getLayer(), element);
     reassignLayerAllReferencesDataControl(element.getLayer());
 }
Exemple #2
0
        /**
         * Insert in order in allReferencesDataControl attribute
         *
         * @param element
         *            The element container to be added
         * @param hasLayer
         *            Take either layer or depth value to order value
         * @param playerLayer
         *            Take the layer if player has it, or the y position if the
         *            player has not layer.
         *
         * @return i returns the position where the element has been inserted. It
         *         will be use to reassign layer
         */
        public int insertInOrder(ElementContainer element, bool hasLayer)
        {
            bool added = false;
            int  i     = 0;
            bool empty = allReferencesDataControl.Count == 0;

            // While the element has not been added, and
            // we haven't checked every previous element
            while (!added && (i < allReferencesDataControl.Count || empty))
            {
                if (!empty)
                {
                    if (hasLayer)
                    {
                        if (element.getLayer() <= allReferencesDataControl[i].getLayer())
                        {
                            allReferencesDataControl.Insert(i, element);
                            added = true;
                        }
                    }
                    else
                    {
                        if (element.getY() <= Mathf.Round(allReferencesDataControl[i].getY()))
                        {
                            allReferencesDataControl.Insert(i, element);
                            reassignLayerAllReferencesDataControl(i);
                            added = true;
                        }
                    }
                    i++;
                }
                else
                {
                    allReferencesDataControl.Insert(i, element);
                    if (!hasLayer)
                    {
                        reassignLayerAllReferencesDataControl(i);
                    }
                    added = true;
                    i++;
                }
            }

            // If the element wasn't added, add it in the last position
            if (!added)
            {
                //element.setLayer(i);
                allReferencesDataControl.Add(element);
                if (!hasLayer)
                {
                    reassignLayerAllReferencesDataControl(i - 1);
                }
            }
            return(i - 1);
        }
        public void addElement(ElementContainer element)
        {
            var elementRef = (ElementReference)element.getErdc().getContent();

            if (elementRef == null)
            {
                return;
            }

            var type = controller.IdentifierSummary.getType(elementRef.getTargetId());

            if (type == null)
            {
                return;
            }

            getReferencesList(type).Add(elementRef);
            allReferencesDataControl.Insert(element.getLayer(), element);
            reassignLayerAllReferencesDataControl(element.getLayer());
        }