Esempio n. 1
0
    public bool Remove(ActiveNode <T> nodeToRemove)
    {
        if (nodeToRemove != null)
        {
            ActiveNode <T> pNode  = nodeToRemove.prevNode;
            ActiveNode <T> nNode  = nodeToRemove.nextNode;
            ActiveNode <T> paNode = nodeToRemove.prevActiveNode;
            ActiveNode <T> naNode = nodeToRemove.nextActiveNode;

            pNode.nextNode = nNode;
            nNode.prevNode = pNode;

            if (paNode != null)
            {
                paNode.nextActiveNode = naNode;
                naNode.prevActiveNode = paNode;
            }

            if (nodeToRemove.IsActive())
            {
                ActiveCount--;
            }
            Count--;
            nodeToRemove = null;

            IsIndexable = false;

            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    private int PlanebTriangleIntersection(b_Plane plane, bTriangle triangle,
                                           out ActiveNode <bVertex>[] intersection,
                                           bool duplicateIntersectionPoints = false,
                                           bool useSecondLookupTable        = false)
    {
        intersection    = new ActiveNode <bVertex> [3];
        intersection[0] = null; intersection[1] = null; intersection[2] = null;
        int nullCount = 0;

        Vector3 vec;
        float   interp;

        for (int i = 0; i < 3; i++)
        {
            int j = (i + 1) % 3;

            int vi = triangle.GetVertexIndex(i);
            int vj = triangle.GetVertexIndex(j);

            if (LineIntersectLookup(vi, vj, !useSecondLookupTable) == lineLookupBlank)
            {
                nullCount++;
                continue;
            }
            else if (LineIntersectLookup(vi, vj, !useSecondLookupTable) != null)
            {
                intersection[i] = LineIntersectLookup(vi, vj, !useSecondLookupTable);
            }
            else if (PlaneSegmentIntersection(plane, triangle.GetVertex(i), triangle.GetVertex(j), out vec, out interp) == 1)
            {
                bVertex newVert = new bVertex(
                    new Vector3(vec.x, vec.y, vec.z),
                    Vector2.Lerp(triangle.GetUV(i), triangle.GetUV(j), interp)
                    );

                intersection[i] = AddVertex(newVert, true);
                SetLineIntersect(vi, vj, intersection[i], !useSecondLookupTable);

                if (duplicateIntersectionPoints)
                {
                    AddVertex(new bVertex(
                                  new Vector3(vec.x, vec.y, vec.z),
                                  Vector2.Lerp(triangle.GetUV(i), triangle.GetUV(j), interp)),
                              true);
                }
            }
            else
            {
                SetLineIntersect(vi, vj, lineLookupBlank, !useSecondLookupTable);
                nullCount++;
            }
        }

        if (nullCount > 1)
        {
            return(0);
        }

        return(1);
    }
Esempio n. 3
0
 private void Update()
 {
     if (isPaused || isDisabled)
     {
         return;
     }
     if (ActiveNode != null)
     {
         if (!ActiveNode.IsEntered)
         {
             ActiveNode.OnEnter();
         }
         else if (!ActiveNode.IsFinished)
         {
             ActiveNode.OnUpdate();
             UpdateChanges(ActiveNode);
         }
     }
     if (AnyState != null)
     {
         if (!AnyState.IsEntered)
         {
             AnyState.OnEnter();
         }
         else if (!AnyState.IsFinished)
         {
             AnyState.OnUpdate();
             UpdateChanges(AnyState);
         }
     }
 }
Esempio n. 4
0
    private void RegenerateMesh(bool reverse = false)
    {
        List <bVertex> newBVertices = new List <bVertex>();

        int[] newbTriangles = new int[triangles.ActiveCount * 3];

        vertices.CopyActiveTo(newBVertices);

        Vector3[] newVertices = new Vector3[newBVertices.Count];
        Vector2[] newUV       = new Vector2[newBVertices.Count];

        int ind = 0;

        foreach (bVertex v in newBVertices)
        {
            newVertices[ind] = v.vertex;
            newUV[ind]       = v.uv;

            ind++;
        }

        ActiveNode <bTriangle> it = triangles.GetRootNode().nextActiveNode;

        ind = 0;
        while (!it.isRootNode)
        {
            newbTriangles[ind]     = it.data.GetNode(0).activeIndex;
            newbTriangles[ind + 1] = it.data.GetNode(1).activeIndex;
            newbTriangles[ind + 2] = it.data.GetNode(2).activeIndex;

            it   = it.nextActiveNode;
            ind += 3;
        }

        /*
         * if (!reverse)
         * {
         *  targetMesh.SetVertices(newVertices);
         *  targetMesh.SetbTriangles(newbTriangles, 0);
         * }
         * else
         * {
         *  targetMesh.SetbTriangles(newbTriangles, 0);
         *  targetMesh.SetVertices(newVertices);
         * }
         */
        targetMesh.Clear();
        targetMesh.vertices  = newVertices;
        targetMesh.uv        = newUV;
        targetMesh.triangles = newbTriangles;

        targetMesh.RecalculateNormals();
        targetMesh.RecalculateTangents();
        targetMesh.RecalculateBounds();

        if (targetMeshCollider != null)
        {
            targetMeshCollider.sharedMesh = targetMesh;
        }
    }
Esempio n. 5
0
    public ActiveNode <T> InsertBefore(T itemToAdd, ActiveNode <T> beforeNode, bool active = true)
    {
        ActiveNode <T> newNode = new ActiveNode <T>(itemToAdd);

        newNode.prevNode = beforeNode.prevNode;
        newNode.nextNode = beforeNode;

        newNode.prevNode.nextNode = newNode;

        beforeNode.prevNode = newNode;

        Count++;

        if (active)
        {
            newNode.prevActiveNode = beforeNode.prevActiveNode;
            newNode.nextActiveNode = beforeNode;

            newNode.prevActiveNode.nextActiveNode = newNode;

            beforeNode.prevActiveNode = newNode;

            IsIndexable = false;
            ActiveCount++;
        }

        return(newNode);
    }
Esempio n. 6
0
        private bool AddNextSuffix()
        {
            var suffix = string.Concat(Word.Substring(CurrentSuffixStartIndex, CurrentSuffixEndIndex - CurrentSuffixStartIndex), "{", Word[CurrentSuffixEndIndex], "}");

            SendMessage("The next suffix of '{0}' to add is '{1}' at indices {2},{3}", Word, suffix, CurrentSuffixStartIndex, CurrentSuffixEndIndex);
            SendMessage(" => ActiveNode:             {0}", ActiveNode);
            SendMessage(" => ActiveEdge:             {0}", ActiveEdge == null ? "none" : ActiveEdge.ToString());
            SendMessage(" => DistanceIntoActiveEdge: {0}", DistanceIntoActiveEdge);
            SendMessage(" => UnresolvedSuffixes:     {0}", UnresolvedSuffixes);
            if (ActiveEdge != null && DistanceIntoActiveEdge >= ActiveEdge.Length)
            {
                throw new Exception("BOUNDARY EXCEEDED");
            }

            if (ActiveEdge != null)
            {
                return(AddCurrentSuffixToActiveEdge());
            }

            if (GetExistingEdgeAndSetAsActive())
            {
                return(false);
            }

            ActiveNode.AddNewEdge();
            TriggerChanged();

            UpdateActivePointAfterAddingNewEdge();
            return(true);
        }
Esempio n. 7
0
        private void SwitchNode(Node toNode)
        {
            if (toNode == null)
            {
                return;
            }

            if (ActiveNode != null)
            {
                ActiveNode.OnExit();
                if (ActiveNode.Parent != null && ActiveNode.Parent != toNode.Parent)
                {
                    ActiveNode.Parent.OnExit();
                }
            }
            ActiveNode = toNode;
            if (this.ActiveNode != null && this.ActiveNode.Parent != this.AnyState.Parent)
            {
                this.AnyState.OnExit();
                this.AnyState = this.ActiveNode.Parent.GetAnyState();
                this.AnyState.OnEnter();
            }
            switchToNode = null;

            ActiveNode.OnEnter();
            //Debug.Log (ActiveNode.Name);
        }
Esempio n. 8
0
    public void setActive(bool active)
    {
        isActiveNode = active;
        ship.SetActive(active);

        // Tell ObjectManager if I'm the new active node
        if (active)
        {
            ObjectManager.Instance.currentActiveNode = this;
        }

        // Game over, so don't do any game logic
        if (TimeCounter.Instance.gameOver)
        {
            return;
        }

        // Enable/disable the adjacent nodes as clickable
        NodeConnections myNodeConnections = GetComponent <NodeConnections>();

        if (myNodeConnections != null)
        {
            foreach (var node in myNodeConnections.connectedNodes.Keys)
            {
                ActiveNode nodeScript = node.GetComponent <ActiveNode>();
                if (nodeScript != null)
                {
                    nodeScript.setRingActive(isActiveNode);
                }
            }
        }
    }
Esempio n. 9
0
    public ActiveNode <T> Add(T item, bool active = true)
    {
        ActiveNode <T> newNode = new ActiveNode <T>(item);

        newNode.prevNode = rootNode.prevNode;
        newNode.nextNode = rootNode;

        newNode.prevNode.nextNode = newNode;

        rootNode.prevNode = newNode;

        Count++;

        if (active)
        {
            newNode.prevActiveNode = rootNode.prevActiveNode;
            newNode.nextActiveNode = rootNode;

            newNode.prevActiveNode.nextActiveNode = newNode;

            rootNode.prevActiveNode = newNode;

            newNode.activeIndex = ActiveCount++;
        }

        return(newNode);
    }
Esempio n. 10
0
        private ActiveNode TryBreakHere(
            IParagraphModel <TLine, TState> paragraph, IFrameModel frame,
            IBreakPoint breakPoint, ActiveNode prevNode,
            out bool doDeactivate)
        {
            var nextLineNumber = prevNode.LineNumber + 1;
            var suitableLength = frame.LengthOf(nextLineNumber);
            var constraint     = new LineConstraint {
                SuitableLength = suitableLength
            };
            var    newStyle = new TState();
            var    line     = paragraph.CreateLine(constraint, prevNode.Point, breakPoint, prevNode.Style, out newStyle);
            double ratio    = _evaluator.ComputeAdjustmentRatio(line, suitableLength);

            doDeactivate = (ratio < -1 || _evaluator.IsForcedBreakPoint(breakPoint));

            if (-1 <= ratio && ratio <= _tolerance)
            {
                var fitnessClass     = _evaluator.ComputeFitnessClass(ratio);
                var prevIsFlagged    = prevNode.Point.IsFlagged;
                var prevFitnessClass = prevNode.FitnessClass;
                var demerits         = _evaluator.ComputeDemerits(breakPoint, ratio, fitnessClass, prevIsFlagged, prevFitnessClass);
                return(ActiveNode.CreateBreakNode(breakPoint, line, fitnessClass, newStyle, ratio, demerits, prevNode));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 11
0
    public void CopyActiveTo(T[] array, int arrayIndex)
    {
        if (array == null)
        {
            throw new ArgumentNullException();
        }
        else if (arrayIndex < 0 || arrayIndex >= array.Length)
        {
            throw new ArgumentOutOfRangeException();
        }
        else if (array.Length - arrayIndex > ActiveCount)
        {
            throw new ArgumentException("The provided array does not contain enough elements.");
        }

        ActiveNode <T> it  = rootNode.nextActiveNode;
        int            ind = arrayIndex;

        while (!it.isRootNode)
        {
            array[ind]     = it.data;
            it.activeIndex = ind;

            it = it.nextActiveNode;
            ind++;
        }

        IsIndexable = true;
    }
Esempio n. 12
0
        // private void SetToIntactState()
        // {
        //     // _destructibleObjectState = DestructibleObjectState.Intact;
        //     // _intactNode.SetActive(true);
        //     _destructNode.SetActive(false);
        //     EnableIntactColliders();
        // }

        private void SetToDestructBeginState()
        {
            EnableDestructColliders();
            // _destructibleObjectState = DestructibleObjectState.DestructBegin;
            ActiveNode.SetActive(false);
            InactiveNode.SetActive(false);
            _destructNode.SetActive(true);
        }
Esempio n. 13
0
        /// <summary> Activates this graph's first node (either the StartNode or the EnterNode) </summary>
        public void ActivateStartOrEnterNode()
        {
            PreviousActiveNode = null;
            ActiveNode         = GetStartOrEnterNode();
            ActiveNode.SetActiveGraph(this);
            ActiveNode.OnEnter(null, null);
//            ActivateGlobalNodes();
        }
Esempio n. 14
0
    private ActiveNode <bTriangle> AddbTriangle(bTriangle triangle, bool active = true)
    {
        ActiveNode <bTriangle> ret = triangles.Add(triangle, active);

        history.AddChange(ret, null, false, true);

        return(ret);
    }
Esempio n. 15
0
    /*
     *  Helper Functions
     */

    private ActiveNode <bVertex> AddVertex(bVertex vertex, bool active = true)
    {
        ActiveNode <bVertex> ret = vertices.Add(vertex, active);

        history.AddChange(ret, ret.data, false, true);

        return(ret);
    }
Esempio n. 16
0
 private void SetToDestructEndState()
 {
     DisableAllColliders();
     // _destructibleObjectState = DestructibleObjectState.DestructEnd;
     ActiveNode.SetActive(false);
     InactiveNode.SetActive(false);
     _destructNode.SetActive(false);
 }
Esempio n. 17
0
    public ActiveNode <T> GetNodeAt(int index)
    {
        ActiveNode <T> it = rootNode.nextNode;

        for (int i = 0; i < index; i++, it = it.nextNode)
        {
            ;
        }
        return(it);
    }
Esempio n. 18
0
    private T Set(T item, int index)
    {
        ActiveNode <T> node = GetNodeAt(index);

        T returnVal = node.data;

        node.data = item;

        return(returnVal);
    }
Esempio n. 19
0
 public DocTreeView( Core.Document doc, TreeView treeView )
 {
     _doc = doc;
       _treeView = treeView;
       _rootNode = new TreeNode { ImageKey = "document.png", SelectedImageKey = "document.png" };
       _treeView.Nodes.Add( _rootNode );
       _nodes = new DocTreeNodeCollection( _doc.Entries, _rootNode.Nodes );
       _selection = new DocTreeNodeSelection( _treeView, _doc.SelectedEntries, this.Find );
       _activeNode = new ActiveNode { Font = new Font( _treeView.Font, FontStyle.Bold ) };
 }
Esempio n. 20
0
        public override void VisitTerminal([ValidatedNotNull] ITerminalNode node)
        {
            node.ValidateNotNull(nameof(node));
            if (ActiveNode is null)
            {
                throw new InvalidOperationException("ActiveNode is null!");
            }

            ActiveNode.Add(new XElement("Terminal", new XAttribute("Value", node.GetText( ))));
        }
Esempio n. 21
0
        private void MoveNode(NodePositionMovement npm)
        {
            CoreRepository.ClearQueryCache("Nodes");

            IList rootNodes = CoreRepository.GetRootNodes(ActiveNode.Site);

            ActiveNode.Move(rootNodes, npm);
            CoreRepository.FlushSession();
            Context.Response.Redirect(Context.Request.RawUrl);
        }
Esempio n. 22
0
        public override void EnterUnaryOpExpression([ValidatedNotNull] KaleidoscopeParser.UnaryOpExpressionContext context)
        {
            context.ValidateNotNull(nameof(context));
            if (ActiveNode is null)
            {
                throw new InvalidOperationException("ActiveNode is null!");
            }

            ActiveNode.Add(new XAttribute("Op", context.Op));
        }
Esempio n. 23
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (ActiveNode.Sections.Count > 0)
            {
                ShowError(
                    "Không thể xóa nút khi có các vùng phân hệ trong nó. Hãy xóa hoặc tạm gỡ toàn bộ các vùng này trước.");
            }
            else if (ActiveNode.ChildNodes.Count > 0)
            {
                ShowError("Không thể xóa nút khi còn các nút con. Hãy xóa hết các nút con trước.");
            }
            else
            {
                try
                {
                    CoreRepository.ClearQueryCache("Nodes");

                    bool hasParentNode = (ActiveNode.ParentNode != null);
                    if (hasParentNode)
                    {
                        ActiveNode.ParentNode.ChildNodes.Remove(ActiveNode);
                    }
                    else
                    {
                        IList rootNodes = CoreRepository.GetRootNodes(ActiveNode.Site);
                        rootNodes.Remove(ActiveNode);
                    }
                    CoreRepository.DeleteNode(ActiveNode);
                    // Reset the position of the 'neighbour' nodes.
                    if (ActiveNode.Level == 0)
                    {
                        ActiveNode.ReOrderNodePositions(CoreRepository.GetRootNodes(ActiveNode.Site),
                                                        ActiveNode.Position);
                    }
                    else
                    {
                        ActiveNode.ReOrderNodePositions(ActiveNode.ParentNode.ChildNodes, ActiveNode.Position);
                    }
                    CoreRepository.FlushSession();
                    if (hasParentNode)
                    {
                        Context.Response.Redirect(String.Format("NodeEdit.aspx?NodeId={0}", ActiveNode.ParentNode.Id));
                    }
                    else
                    {
                        Context.Response.Redirect("Default.aspx");
                    }
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                    log.Error(String.Format("Có lỗi khi xóa nút: {0}.", ActiveNode.Id), ex);
                }
            }
        }
Esempio n. 24
0
    IEnumerator IEnumerable.GetEnumerator()
    {
        ActiveNode <T> it = rootNode.nextNode;

        while (!it.isRootNode)
        {
            yield return(it.data);

            it = it.nextNode;
        }
    }
Esempio n. 25
0
        protected override ResourceDictionary[] LoadResoucesInternal(HashSet <string> dics)
        {
            var result = new List <ResourceDictionary>();

            if (ActiveNode != null)
            {
                result.AddRange(ActiveNode.LoadResources());
            }

            return(result.ToArray());
        }
Esempio n. 26
0
 bool CanAddEvent()
 {
     if (ActiveNode != null && ActiveNode.GetType() == typeof(EntityObject))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 27
0
    IEnumerator ContractTransition(float numSeconds, HashSet <ActiveNode <bVertex> > verticesToBeTranslated, List <ActiveNode <bTriangle> > trianglesToRemove, Vector3 translation)
    {
        float endTime     = Time.realtimeSinceStartup + numSeconds;
        float currentTime = Time.realtimeSinceStartup;

        List <Vector3> originalVertices = new List <Vector3>();

        foreach (ActiveNode <bVertex> node in verticesToBeTranslated)
        {
            originalVertices.Add(new Vector3(node.data.vertex.x, node.data.vertex.y, node.data.vertex.z));
        }

        while (currentTime < endTime)
        {
            float t  = 1.0f - ((endTime - currentTime) / numSeconds);
            int   _i = 0;
            foreach (ActiveNode <bVertex> node in verticesToBeTranslated)
            {
                node.data.vertex = Vector3.Lerp(originalVertices[_i], originalVertices[_i] + translation, t);
                _i++;
            }

            RegenerateMesh();

            currentTime = Time.realtimeSinceStartup;
            yield return(new WaitForEndOfFrame());
        }

        int i = 0;

        foreach (ActiveNode <bVertex> node in verticesToBeTranslated)
        {
            bVertex newVert = node.data.GetCopy();
            newVert.vertex   = originalVertices[i] + translation;
            node.data.vertex = originalVertices[i];

            ChangeVertex(node, newVert, node.data);
            //node.data = originalVertices[i] + translation;
            i++;
        }
        int x = trianglesToRemove.Count;

        for (int j = 0; j < x; j++)
        {
            ActiveNode <bTriangle> node = trianglesToRemove[j];
            ChangebTriangle(node, null, true);
            //triangles.SetActivity(node, false);
        }

        RegenerateMesh();
        history.PushChanges();
    }
Esempio n. 28
0
        private void Push(XElement element)
        {
            if (ActiveNode == null)
            {
                Document.Add(element);
            }
            else
            {
                ActiveNode.Add(element);
            }

            ActiveNode = element;
        }
Esempio n. 29
0
        public override void ExitEveryRule([NotNull] ParserRuleContext context)
        {
            base.ExitEveryRule(context);
            ActiveNode.Add(new XAttribute("Text", context.GetSourceText(Recognizer)));
            ActiveNode.Add(new XAttribute("RuleIndex", context.RuleIndex));
            ActiveNode.Add(new XAttribute("SourceInterval", context.SourceInterval.ToString( )));
            if (context.exception != null)
            {
                ActiveNode.Add(new XAttribute("Exception", context.exception));
            }

            Pop( );
        }
Esempio n. 30
0
    private void ChangebTriangle(ActiveNode <bTriangle> node, bTriangle newVal, bool activityToggle = false)
    {
        history.AddChange(node, node.data, activityToggle);

        if (newVal != null)
        {
            node.data = newVal;
        }

        if (activityToggle)
        {
            triangles.SetActivity(node, !node.IsActive());
        }
    }
Esempio n. 31
0
    private void ChangeVertex(ActiveNode <bVertex> node, bVertex newVal, bVertex oldVal, bool activityToggle = false)
    {
        history.AddChange(node, oldVal, activityToggle);

        if (newVal != null)
        {
            node.data = newVal;
        }

        if (activityToggle)
        {
            vertices.SetActivity(node, !node.IsActive());
        }
    }