public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var subEntity = (EntityViewModel)children.First();
            var command   = TargetNode.GetCommand(SetEntityReferenceCommand.CommandName);

            command.Execute(subEntity);
        }
Esempio n. 2
0
        internal void Refresh([NotNull] IGraphNode ownerNode, NodeContainer nodeContainer, NodeIndex index)
        {
            var objectValue = ownerNode.Retrieve(index);

            var boxedTarget = TargetNode as BoxedNode;

            if (boxedTarget != null && objectValue?.GetType() == TargetNode.Type)
            {
                // If we are boxing a struct, and the targeted type didn't change, we reuse the same nodes and just overwrite the struct value.
                boxedTarget.UpdateFromOwner(objectValue);
                // But we still need to refresh inner references!
                foreach (var member in TargetNode.Members.Where(x => x.IsReference))
                {
                    nodeContainer?.UpdateReferences(member);
                }
            }
            else if (TargetNode?.Retrieve() != objectValue)
            {
                // This call will recursively update the references.
                var target = SetTarget(objectValue, nodeContainer);
                if (target != null)
                {
                    var boxedContent = target as BoxedNode;
                    boxedContent?.SetOwnerContent(ownerNode, index);
                }
            }
            // This reference is not orphan anymore.
            orphanObject = null;
        }
Esempio n. 3
0
        private string BuildDot()
        {
            var builder = StringBuilderCache.Acquire();

            var sourceIdentifier = SourcePort != null
                ? SourceNode + ":" + SourcePort
                : SourceNode.ToString();

            var targetIdentifier = TargetPort != null
                ? TargetNode + ":" + TargetPort
                : TargetNode.ToString();

            builder.Append(sourceIdentifier)
            .Append(" -> ")
            .Append(targetIdentifier);

            if (EdgeAttributes.Any())
            {
                const string indent = "  ";

                builder.AppendLine(" [");

                foreach (var edgeAttr in EdgeAttributes)
                {
                    builder.Append(indent).AppendLine(edgeAttr.ToString());
                }

                builder.Append(']');
            }

            return(builder.GetStringAndRelease());
        }
        protected override void ExecuteCore()
        {
            Folder targetFolder = GetTargetNodeAncestorAsXenObjectOrGroupingTag <Folder>();

            if (DraggedNodes != null)
            {
                foreach (VirtualTreeNode draggedNode in DraggedNodes)
                {
                    if (GetItemsNotAlreadyInTargetFolder().Contains((IXenObject)draggedNode.Tag))
                    {
                        GreyAll(draggedNode);
                    }
                }
            }

            new MoveToFolderAction(GetItemsNotAlreadyInTargetFolder(), targetFolder).RunAsync();

            // need to now wait until the operation has finished... then we can expand the node.
            ThreadPool.QueueUserWorkItem(delegate
            {
                for (int i = 0; i < 20 && TargetNode.Nodes.Count == 0; i++)
                {
                    Thread.Sleep(100);
                }

                MainWindowCommandInterface.Invoke(delegate { TargetNode.Expand(); });
            });
        }
        public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var symbol  = (Symbol)children.Select(x => (NodeViewModel)x).First().NodeValue;
            var command = TargetNode.GetCommand(SetSymbolReferenceCommand.CommandName);

            command.Execute(symbol);
        }
Esempio n. 6
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ProjectNode project = e.Node as ProjectNode;

            if (project != null)
            {
                current_project         = project;
                textBoxProjectName.Text = project.Text;
                //tabControl2.TabPages.Add( tabControl1.
                SelectActivePage(tabPageProjectProperties);
            }
            TargetNode target = e.Node as TargetNode;

            if (target != null)
            {
                SelectActivePage(tabPageTargetProperties);

                comboBoxTargetType.SelectedValue = target.target["target_type"];

                current_target = target;
                //ProjectData.project_data_set.current_target = target.target;
            }
            TargetSourceNode target_source = e.Node as TargetSourceNode;

            if (target_source != null)
            {
            }
        }
        public override BehaviorResult Exec(IBehaviorTree tree)
        {
            if (TargetNode == null)
            {
                return(BehaviorResult.failed);
            }

            SetStarting();

            BehaviorResult result = TargetNode.Exec(tree);

            if (result == BehaviorResult.success)
            {
                SetCompleted();
                return(BehaviorResult.success);
            }
            else if (result == BehaviorResult.failed)
            {
                SetFailed();
                return(BehaviorResult.failed);
            }
            else if (result == BehaviorResult.running)
            {
                return(BehaviorResult.running);
            }

            SetAborted();
            return(BehaviorResult.abort);
        }
        /// <summary>
        ///
        /// </summary>
        protected override void Apply()
        {
            if (TargetChildNodes == null || TargetChildNodes.Count == 0)
            {
                TargetNode.AppendChild(TransformNode);
            }
            else
            {
                XmlAttribute transformAtt = null;

                foreach (XmlAttribute att in TransformNode.Attributes)
                {
                    if (string.Equals(att.Name, AttributeName, StringComparison.OrdinalIgnoreCase))
                    {
                        transformAtt = att;
                        break;
                    }
                }

                if (transformAtt == null)
                {
                    throw new InvalidOperationException("No target attribute to append");
                }

                foreach (XmlNode targetNode in TargetChildNodes)
                {
                    var foundAttribute = false;
                    foreach (XmlAttribute att in targetNode.Attributes)
                    {
                        if (string.Equals(att.Name, AttributeName, StringComparison.OrdinalIgnoreCase))
                        {
                            foundAttribute = true;
                            if (string.IsNullOrEmpty(att.Value))
                            {
                                att.Value = transformAtt.Value;
                            }
                            else
                            {
                                // TODO: This doesn't compose well with insertOrAppend being applied on the TargetNode.
                                // The target node is created with the children it has in the transform, which means we would
                                // duplicate the value here.
                                if (att.Value == transformAtt.Value)
                                {
                                    return;
                                }
                                att.Value = $"{att.Value};{transformAtt.Value}";
                            }
                        }
                    }

                    if (!foundAttribute)
                    {
                        var attribute = targetNode.OwnerDocument.CreateAttribute(AttributeName);
                        attribute.Value = transformAtt.Value;
                        targetNode.Attributes.Append(attribute);
                    }
                }
            }
        }
Esempio n. 9
0
        protected override void Apply()
        {
            CommonErrors.ExpectNoArguments(Log, TransformNameShort, ArgumentString);

            TargetNode.AppendChild(TransformNode);

            Log.LogMessage(MessageType.Verbose, Resources.XMLTRANSFORMATION_TransformMessageInsert, TransformNode.Name);
        }
Esempio n. 10
0
 // Add a new target node to the end of the list. Don't need all the points before we start traveling.
 private void Event_SpawnedNode(TargetNode inNode)
 {
     if (DebugMsg)
     {
         Debug.Log("Player notified by spawned node");
     }
     nodeList.Add(inNode);
 }
Esempio n. 11
0
 protected override void Apply()
 {
     CommonErrors.ExpectNoArguments(Log, TransformNameShort, ArgumentString);
     if (TargetChildNodes is null || TargetChildNodes.Count == 0)
     {
         TargetNode.AppendChild(TransformNode);
         Log.LogMessage(MessageType.Verbose, SR.XMLTRANSFORMATION_TransformMessageInsert, TransformNode.Name);
     }
 }
Esempio n. 12
0
    /// <summary>
    /// Spawns and configures a chain of target nodes towards the target position.
    /// </summary>
    public void BeginTargetting()
    {
        List <Vector3> linePositions = new List <Vector3>();
        Vector3        toTarget      = targetLocation - transform.position;
        float          distance      = toTarget.magnitude;

        toTarget.Normalize();
        Vector3 toTargetPerp = Vector2.Perpendicular(toTarget).normalized;

        TargetNode firstNode    = null;
        TargetNode lastNode     = null;
        int        numNodes     = Mathf.Min((int)(distance) + 7, 12);
        float      waveDistance = numNodes * 0.15f + Random.Range(-0.25f, 0.25f);
        bool       flipped      = (Random.Range(0, 2) == 0);

        for (int i = 0; i < numNodes; i++)
        {
            // Standard node init
            TargetNode node = Instantiate(targetNodePrefab, MyGameManager.TargettingNodes).GetComponent <TargetNode>();
            node.MyCannon = this;
            if (lastNode != null)
            {
                lastNode.NextNode = node;
                node.gameObject.SetActive(false);
            }
            if (firstNode == null)
            {
                firstNode = node;
            }
            lastNode = node;

            // Position along a line straight back to cannon
            float   distanceRatio = 1f - ((float)i / (numNodes - 1));
            Vector3 position      = new Vector3(toTarget.x * distance * distanceRatio, toTarget.y * distance * distanceRatio);

            // Add a simple sin wave
            float   angle  = distanceRatio * 360f * Mathf.Deg2Rad;
            Vector3 offset = new Vector3(toTargetPerp.x * Mathf.Sin(angle) * waveDistance, toTargetPerp.y * Mathf.Sin(angle) * waveDistance, 0f);
            position += flipped ? offset : -offset;
            //position += offset;

            node.transform.position = position;
            node.ProgressOnLink     = distanceRatio;
            node.TimeToSelect       = 1f * (distanceRatio + 0.2f);
            linePositions.Add(position);
        }

        firstNode.transform.position = targetLocation;
        lastNode.transform.position  = transform.position;

        TargettingLine.positionCount = numNodes;
        TargettingLine.SetPositions(linePositions.ToArray());
        TargettingLine.gameObject.SetActive(true);

        SetTargettingLineProgress(0f);
        TargettingLineProgressAmount = 1f / numNodes;
    }
        public override BehaviorResult Exec(IBehaviorTree tree)
        {
            if (TargetNode == null)
            {
                //Debug.LogError("missing target node");
                return(BehaviorResult.failed);
            }

            if (!Running)
            {
                if (OnPrecondition != null)
                {
                    if (!OnPrecondition())
                    {
                        return(BehaviorResult.failed);
                    }
                }

                SetStarting();
            }

            if (N == 0.0f)
            {
                N = tree.GameTime;
            }
            BehaviorResult result = TargetNode.Exec(tree);

            if (result == BehaviorResult.success)
            {
                SetCompleted();
                N = 0.0f;
                return(BehaviorResult.success);
            }
            else if (result == BehaviorResult.failed)
            {
                SetFailed();
                return(BehaviorResult.failed);
            }
            else if (result == BehaviorResult.running)
            {
                if (tree.GameTime - N < Interval)
                {
                    return(BehaviorResult.running);
                }
                else
                {
                    TargetNode.Abort();
                    N = 0.0f;
                    return(BehaviorResult.failed);
                }
            }
            else
            {
                return(BehaviorResult.abort);
            }
        }
Esempio n. 14
0
        public override bool CanAddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers, out string message)
        {
            AssetViewModel asset       = null;
            var            singleChild = true;

            foreach (var child in children)
            {
                if (!singleChild)
                {
                    message = "Multiple assets selected";
                    return(false);
                }
                asset = child as AssetViewModel;
                if (asset == null)
                {
                    message = "The selection is not an asset";
                    return(false);
                }
                if (AssetRegistry.IsContentType(TargetNode.Type) || typeof(AssetReference).IsAssignableFrom(TargetNode.Type))
                {
                    var isCompatible       = false;
                    var resolvedAssetTypes = AssetRegistry.GetAssetTypes(TargetNode.Type);
                    foreach (var resolvedAssetType in resolvedAssetTypes)
                    {
                        if (resolvedAssetType.IsAssignableFrom(asset.AssetType))
                        {
                            isCompatible = true;
                            break;
                        }
                    }
                    if (!isCompatible)
                    {
                        message = "Incompatible asset";
                        return(false);
                    }
                }
                var command = TargetNode.GetCommand("SetContentReference");
                var param   = new SetContentReferenceCommand.Parameter {
                    Asset = asset, Type = TargetNode.Type
                };
                if (!command.CanExecute(param))
                {
                    message = "The selection is not valid in this context";
                    return(false);
                }

                singleChild = false;
            }
            if (asset == null)
            {
                message = "The selection is not an asset";
                return(false);
            }
            message = $"Reference {asset.Url}";
            return(true);
        }
Esempio n. 15
0
        public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var asset = (AssetViewModel)children.First();
            var param = new SetContentReferenceCommand.Parameter {
                Asset = asset, Type = TargetNode.Type
            };
            var command = TargetNode.GetCommand("SetContentReference");

            command.Execute(param);
        }
Esempio n. 16
0
        public void RemoveFirst()
        {
            if (_start.Target == null)
            {
                _start = null;
                return;
            }

            _start = _start.Target;
        }
        protected override void OnEnable()
        {
            base.OnEnable();

            TargetNode.SortShowViewsList();
            TargetNode.SortHideViewsList();

            m_infoMessageUnnamedNodeName   = new InfoMessage(InfoMessage.MessageType.Error, UILabels.UnnamedNodeTitle, UILabels.UnnamedNodeMessage);
            m_infoMessageDuplicateNodeName = new InfoMessage(InfoMessage.MessageType.Error, UILabels.DuplicateNodeTitle, UILabels.DuplicateNodeMessage);
        }
Esempio n. 18
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     if (TargetNode != null)
     {
         return(TargetNode.GetHashCode() + (int)Cost);
     }
     else
     {
         return((int)Cost);
     }
 }
Esempio n. 19
0
    private void Event_SpawnedNode(TargetNode inNode)
    {
        if (DebugMsg)
        {
            Debug.Log("Game Manager notified by spawn.");
        }

        if (OnSpawnedNode != null)
        {
            OnSpawnedNode(inNode);
        }
    }
        private void chkFlagsTypeUnk0x8000_CheckedChanged(object sender, EventArgs e)
        {
            if (_updating)
            {
                return;
            }

            TargetNode.SignalPropertyChange();
            foreach (CollisionPlane p in _selectedPlanes)
            {
                p.IsTypeUnknown0x8000 = chkFlagsTypeUnk0x8000.Checked;
            }
        }
Esempio n. 21
0
        protected override void OnNodeGUI()
        {
            if (TargetNode.MaxChance <= 0)
            {
                TargetNode.UpdateMaxChance();
            }
            TargetNode.UpdateConnectedOutputSockets();

            DrawNodeBody();
            DrawSocketsList(Node.InputSockets);
            DrawSocketsList(Node.OutputSockets);
            DrawAddSocketButton(SocketDirection.Output, ConnectionMode.Override, typeof(WeightedConnection));
        }
Esempio n. 22
0
        public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var subEntity = (EntityViewModel)children.First();
            var index     = subEntity.Components.IndexOf(x => TargetNode.Type.IsInstanceOfType(x));

            if (index >= 0)
            {
                var command = TargetNode.GetCommand(SetComponentReferenceCommand.CommandName);
                command.Execute(new SetComponentReferenceCommand.Parameter {
                    Entity = subEntity, Index = index
                });
            }
        }
Esempio n. 23
0
        private void chkTypeRightWall_CheckedChanged(object sender, EventArgs e)
        {
            if (_updating)
            {
                return;
            }

            TargetNode.SignalPropertyChange();
            foreach (CollisionPlane p in _selectedPlanes)
            {
                p.IsRightWall = chkTypeRightWall.Checked;
            }
        }
Esempio n. 24
0
        public override BehaviorResult Exec(IBehaviorTree tree)
        {
            if (TargetNode == null)
            {
                return(BehaviorResult.failed);
            }

            if (!Running)
            {
                if (OnPrecondition != null)
                {
                    if (!OnPrecondition())
                    {
                        return(BehaviorResult.failed);
                    }
                }

                SetStarting();
            }

            while (true)
            {
                if (N == 0.0f)
                {
                    N = tree.GameTime;
                }
                while (tree.GameTime - N < CDTime)
                {
                    return(BehaviorResult.running);
                }
                BehaviorResult result = TargetNode.Exec(tree);

                if (result == BehaviorResult.success)
                {
                    Reset();
                }
                else if (result == BehaviorResult.failed)
                {
                    Reset();
                }
                else if (result == BehaviorResult.running)
                {
                    return(BehaviorResult.running);
                }
            }
        }
Esempio n. 25
0
        public void RemoveLast()
        {
            if (_start.Target == null)
            {
                _start = null;
                return;
            }

            var node = _start;

            while (node.Target?.Target != null)
            {
                node = node.Target;
            }

            node.Target = null;
        }
Esempio n. 26
0
 protected override void Apply()
 {
     if (TargetChildNodes == null)
     {
         return;
     }
     foreach (var element in TargetChildNodes.OfType <XmlElement>())
     {
         if (element.ChildNodes.Cast <XmlNode>()
             .Any(n => n.NodeType != XmlNodeType.Whitespace &&
                  n.NodeType != XmlNodeType.Comment &&
                  n.NodeType != XmlNodeType.Attribute))
         {
             continue;
         }
         TargetNode.RemoveChild(element);
     }
 }
Esempio n. 27
0
        public void Add(float x, float y)
        {
            var target = new TargetNode(x, y);

            if (_start == null)
            {
                _start = target;
                return;
            }

            var t = _start;

            while (t.Target != null)
            {
                t = t.Target;
            }

            t.Target = target;
        }
        public override BehaviorResult Exec(IBehaviorTree tree)
        {
            if (TargetNode == null)
            {
                // Debug.LogError("missing target node");
                return(BehaviorResult.failed);
            }

            if (!Running)
            {
                if (OnPrecondition != null)
                {
                    if (!OnPrecondition())
                    {
                        return(BehaviorResult.failed);
                    }
                }

                SetStarting();
            }

            while (true)
            {
                BehaviorResult result = TargetNode.Exec(tree);

                if (result == BehaviorResult.success)
                {
                    SetCompleted();
                    return(BehaviorResult.success);
                }
                else if (result == BehaviorResult.running)
                {
                    return(BehaviorResult.running);
                }
                else if (result == BehaviorResult.failed)
                {
                    return(BehaviorResult.running);
                }
            }
        }
Esempio n. 29
0
        public override BehaviorResult Exec(IBehaviorTree tree)
        {
            if (TargetNode == null)
            {
                return(BehaviorResult.failed);
            }

            SetStarting();

            while (LoopCount < 0 || m_CounterLoop < LoopCount)
            {
                BehaviorResult result = TargetNode.Exec(tree);

                if (result == BehaviorResult.success)
                {
                    if (LoopCount > 0)
                    {
                        m_CounterLoop++;
                    }
                    //return BehaviorResult.running;
                }
                else if (result == BehaviorResult.failed)
                {
                    if (LoopCount > 0)
                    {
                        m_CounterLoop++;
                    }
                }
                else if (result == BehaviorResult.running)
                {
                    //return BehaviorResult.running;
                }
                return(BehaviorResult.running);
            }

            SetCompleted();
            return(BehaviorResult.success);
        }
Esempio n. 30
0
        public IHttpActionResult Post([FromBody] List <Target> targets)
        {
            try
            {
                int[,] adj = Algorithms.Algorithms.GetAdjacencyMatrix(targets);
                if (Algorithms.Algorithms.ContainsCycle(adj, new List <int>(), new List <List <int> >(), 0))
                {
                    throw new Exception("Target graph must not contain cycles");
                }

                TargetNode        root  = Algorithms.Algorithms.BuildTargetTree(targets);
                List <TargetNode> nodes = Algorithms.Algorithms.TopologicalSort(root);

                return(Ok(nodes.Select(x => new
                {
                    Name = x.Title
                })));
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Do unit selection.
        /// </summary>
        /// <param name="searchConfig">Search configuration.</param>
        /// <returns>The best path.</returns>
        public List<PathNodeInfo> UnitSelecting(SearchConfig searchConfig)
        {
            ILatticeProvider latticeProvider = searchConfig.LatticeProvider;
            ITargetCostCalculator targetCostCalculator = searchConfig.TargetCostCalculator;
            IJoinCalculator joinCostCalculator = searchConfig.JoinCostCalculator;

            int targetCount = latticeProvider.GetColumnCount();
            if (targetCount == 0)
            {
                string message = Helper.NeutralFormat("The ILatticeProvider contains 0 targets!");
                throw new InvalidDataException(message);
            }

            List<PathNodeInfo> bestPath = new List<PathNodeInfo>(targetCount);

            TargetNode[] targets = new TargetNode[targetCount];
            LatticeNode[][] lattice = new LatticeNode[targetCount][];

            for (int i = 0; i < targetCount; i++)
            {
                int candidateCount = latticeProvider.GetRowCount(i);
                if (candidateCount == 0)
                {
                    string message = Helper.NeutralFormat("The ILatticeProvider contains 0 candidates for target {0}!", i);
                    throw new InvalidDataException(message);
                }

                targets[i] = new TargetNode(latticeProvider.GetTarget(i), candidateCount);

                lattice[i] = new LatticeNode[candidateCount];
                for (int j = 0; j < candidateCount; j++)
                {
                    PathNodeInfo pathNodeInfo = new PathNodeInfo(latticeProvider.GetCandidate(i, j), float.PositiveInfinity, float.PositiveInfinity);
                    lattice[i][j] = new LatticeNode(pathNodeInfo, float.PositiveInfinity, -1);
                }
            }

            for (int i = 0; i < targets[0].CandidateCount; i++)
            {
                LatticeNode nodeCur = lattice[0][i];

                float targetCost = targetCostCalculator.GetTargetCost(targets[0].Target, nodeCur.PathNodeInfo.Candidate);
                nodeCur.BestScore = targetCost;

                nodeCur.PathNodeInfo.TargetCost = targetCost;
            }

            for (int col = 1; col < targetCount; col++)
            {
                TargetNode targetCur = targets[col];
                TargetNode targetLeft = targets[col - 1];

                for (int i = 0; i < targetCur.CandidateCount; i++)
                {
                    LatticeNode nodeCur = lattice[col][i];

                    LatticeNode nodeLeft = lattice[col - 1][0];
                    float joinCost = joinCostCalculator.GetJoinCost(targetLeft.Target, targetCur.Target,
                        nodeLeft.PathNodeInfo.Candidate, nodeCur.PathNodeInfo.Candidate);
                    float bestPreScore = nodeLeft.BestScore + joinCost;
                    int bestPreNodeIndex = 0;
                    float bestJoinCost = joinCost;

                    for (int j = 1; j < targets[col - 1].CandidateCount; j++)
                    {
                        nodeLeft = lattice[col - 1][j];
                        joinCost = joinCostCalculator.GetJoinCost(targetLeft.Target, targetCur.Target,
                            nodeLeft.PathNodeInfo.Candidate, nodeCur.PathNodeInfo.Candidate);
                        float preCost = nodeLeft.BestScore + joinCost;
                        if (preCost < bestPreScore)
                        {
                            bestPreScore = preCost;
                            bestPreNodeIndex = j;
                            bestJoinCost = joinCost;
                        }
                    }

                    float targetCost = targetCostCalculator.GetTargetCost(targetCur.Target, nodeCur.PathNodeInfo.Candidate);
                    nodeCur.BestScore = bestPreScore + targetCost;
                    nodeCur.BestPreNodeIndex = bestPreNodeIndex;

                    nodeCur.PathNodeInfo.TargetCost = targetCost;
                    nodeCur.PathNodeInfo.JoinCost = bestJoinCost;
                }
            }

            int columnIndex = targetCount - 1;
            LatticeNode bestNode = lattice[columnIndex][0];
            float bestScore = bestNode.BestScore;
            for (int i = 1; i < targets[columnIndex].CandidateCount; i++)
            {
                LatticeNode curNode = lattice[columnIndex][i];
                if (curNode.BestScore < bestScore)
                {
                    bestNode = curNode;
                    bestScore = bestNode.BestScore;
                }
            }

            while (true)
            {
                bestPath.Add(bestNode.PathNodeInfo);
                columnIndex--;
                if (columnIndex < 0)
                {
                    break;
                }

                bestNode = lattice[columnIndex][bestNode.BestPreNodeIndex];
            }

            bestPath.Reverse();

            return bestPath;
        }