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); } } }
public ConnectionInfo(PresetNode node, PresetNode[] inputs, PresetNode[] outputs) { Node = node; Inputs = inputs; Outputs = outputs; Connected = inputs.Concat(outputs).ToArray(); }
private string GetPresetName(PresetNode preset) { GetPresetNameEvent eventInstance = new GetPresetNameEvent(); base.ScheduleEvent(eventInstance, preset); return(eventInstance.Name); }
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); }
public ConnectionInfo[] GetOutputsNodes(PresetNode presetNode) { return(Dictionary[presetNode].Outputs.Select(x => Dictionary[x]).ToArray()); }
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); } }