예제 #1
0
        private static IEnumerable <PresetNode> FindConnected(PresetNode node, IDictionary <PresetNode, ConnectionInfo> dictionary, HashSet <PresetNode> founds)
        {
            if (founds is null)
            {
                founds = new HashSet <PresetNode>();
            }

            if (founds.Contains(node))
            {
                yield break;
            }

            founds.Add(node);
            yield return(node);

            var info = dictionary[node];

            foreach (var input in info.Inputs)
            {
                var foundItems = FindConnected(input, dictionary, founds).ToArray();
                foreach (var found in foundItems)
                {
                    yield return(found);
                }
            }

            foreach (var output in info.Outputs)
            {
                var foundItems = FindConnected(output, dictionary, founds).ToArray();
                foreach (var found in foundItems)
                {
                    yield return(found);
                }
            }
        }
예제 #2
0
 public ConnectionInfo(PresetNode node, PresetNode[] inputs, PresetNode[] outputs)
 {
     Node      = node;
     Inputs    = inputs;
     Outputs   = outputs;
     Connected = inputs.Concat(outputs).ToArray();
 }
예제 #3
0
        private string GetPresetName(PresetNode preset)
        {
            GetPresetNameEvent eventInstance = new GetPresetNameEvent();

            base.ScheduleEvent(eventInstance, preset);
            return(eventInstance.Name);
        }
예제 #4
0
        private PresetNode GetOrCreateNodeInternal(string name)
        {
            var node = GetNodeInternal(name);

            if (node != null)
            {
                return(node);
            }

            var id = NodeMap[name].Count;

            node = new PresetNode()
            {
                Name = name,
                Id   = id,
            };
            NodeMap[name].Add(node);
            Network.Nodes.Add(node);
            return(node);
        }
예제 #5
0
 public ConnectionInfo[] GetOutputsNodes(PresetNode presetNode)
 {
     return(Dictionary[presetNode].Outputs.Select(x => Dictionary[x]).ToArray());
 }
예제 #6
0
 public void InitTurret(NodeAddedEvent e, SingleNode <SelectedTurretUIComponent> turretUI, SelfUserNode self, [Context] PresetNode preset, [JoinByUser, Context] MountedTurretNode turret, [JoinByMarketItem, Context] ParentGarageMarketItemNode marketItem, [JoinByParentGroup, Context, Combine] MountedSkin mountedSkin)
 {
     if (preset.userGroup.Key == mountedSkin.userGroup.Key)
     {
         this.SetItem(turret, turretUI.component, mountedSkin);
     }
 }