Exemple #1
0
 private IEnumerable <Widgets.DropdownMenuElement <PatchTreeDef> > PatchTreeDebugElements(PatchTreeDef _)
 {
     foreach (var patchTree in DefDatabase <PatchTreeDef> .AllDefs)
     {
         yield return new Widgets.DropdownMenuElement <PatchTreeDef>
                {
                    option  = new FloatMenuOption(patchTree.defName, () => this.patchTree = patchTree),
                    payload = patchTree,
                }
     }
     ;
 }
Exemple #2
0
        private IEnumerable <Widgets.DropdownMenuElement <int> > PatchTreeDebugValues(PatchTreeDef patchTree)
        {
            yield return(new Widgets.DropdownMenuElement <int>
            {
                option = new FloatMenuOption("Default".Translate(), () =>
                {
                    flagChanged = true;
                    if (patchTreeDebug.ContainsKey(patchTree))
                    {
                        patchTreeDebug.Remove(patchTree);
                    }
                }),
                payload = int.MinValue,
            });

            for (int i = -2; i < 11; i++)
            {
                var j = i;
                yield return(new Widgets.DropdownMenuElement <int>
                {
                    option = new FloatMenuOption(j.ToString(), () => {
                        flagChanged = true;
                        patchTreeDebug.SetOrAdd(patchTree, j);
                    }),
                    payload = j,
                });
            }
        }
Exemple #3
0
        public bool Initialize(PatchTreeDef patchTree, List <Node> list)
        {
            this.patchTree = patchTree;
            if (inputNode == null)
            {
                if (inputNodeName != null)
                {
                    if (!(list.FirstOrDefault(t => t.name == inputNodeName) is Node node))
                    {
                        Log.Error($"[[LC]AutoPatcher] TempError 687669");
                        return(false);
                    }
                    inputNode = node;
                }
                else
                {
                    if (!(list.FirstOrDefault(t => t.index == inputNodeInd) is Node node))
                    {
                        Log.Error($"[[LC]AutoPatcher] TempError 949867");
                        return(false);
                    }
                    inputNode = node;
                }
            }
            if (outputNode == null)
            {
                if (outputNodeName != null)
                {
                    if (!(list.FirstOrDefault(t => t.name == outputNodeName) is Node node))
                    {
                        Log.Error($"[[LC]AutoPatcher] TempError 687669");
                        return(false);
                    }
                    outputNode = node;
                }
                else
                {
                    if (!(list.FirstOrDefault(t => t.index == outputNodeInd) is Node node))
                    {
                        Log.Error($"[[LC]AutoPatcher] TempError 949867");
                        return(false);
                    }
                    outputNode = node;
                }
            }
            if (inputPort != null && outputPort != null)
            {
                return(true);
            }

            if (inputPortInd < 0 || outputPortInd < 0)
            {
                List <IPort> inputPorts;
                List <IPort> outputPorts;
                if (inputPortInd < 0)
                {
                    inputPortGroup = inputPortGroup < 0 ? 0 : inputPortGroup;
                    inputPorts     = inputNode.inputPortGroups[inputPortGroup];
                }
                else
                {
                    if (inputPortGroup < 0)
                    {
                        inputPort = inputNode.inputPorts[inputPortInd];
                    }
                    else
                    {
                        inputPort = inputNode.inputPortGroups[inputPortGroup][inputPortInd];
                    }
                    inputPorts = new List <IPort>()
                    {
                        inputPort
                    };
                }
                if (outputPortInd < 0)
                {
                    outputPortGroup = outputPortGroup < 0 ? 0 : outputPortGroup;
                    outputPorts     = outputNode.outputPortGroups[outputPortGroup];
                }
                else
                {
                    if (outputPortGroup < 0)
                    {
                        outputPort = outputNode.outputPorts[outputPortInd];
                    }
                    else
                    {
                        outputPort = outputNode.outputPortGroups[outputPortGroup][outputPortInd];
                    }
                    outputPorts = new List <IPort>()
                    {
                        outputPort
                    };
                }
                foreach (var outPort in outputPorts)
                {
                    foreach (var inPort in inputPorts)
                    {
                        if (outPort.DataType.CanCastTo(inPort.DataType))
                        // if (inPort.DataType.IsAssignableFrom(outPort.DataType))
                        {
                            var branch = new PatchTreeBranch(patchTree)
                            {
                                inputNode  = inputNode,
                                outputNode = outputNode,
                                inputPort  = inPort,
                                outputPort = outPort,
                            };
                            patchTree.Branches.Add(branch);
                            branch.Initialize(patchTree, list);
                        }
                    }
                }
                patchTree.Branches.Remove(this);
            }
            else
            {
                if (inputPortGroup < 0)
                {
                    inputPort = inputNode.inputPorts[inputPortInd];
                }
                else
                {
                    inputPort = inputNode.inputPortGroups[inputPortGroup][inputPortInd];
                }
                if (outputPortGroup < 0)
                {
                    outputPort = outputNode.outputPorts[outputPortInd];
                }
                else
                {
                    outputPort = outputNode.outputPortGroups[outputPortGroup][outputPortInd];
                }
            }
            return(true);
        }
Exemple #4
0
 // Shortcut methods to the driver's methods
 public bool Initialize(PatchTreeDef patchTree)
 {
     this.patchTree = patchTree;
     return(nodeDef.Initialize(this));
 }
Exemple #5
0
 public PatchTreeBranch(PatchTreeDef patchTree)
 {
     this.patchTree = patchTree;
 }