Exemplo n.º 1
0
        public void SetupAttachNodes(Dictionary <Part, PartSim> partSimLookup, LogMsg log)
        {
            if (log != null)
            {
                log.AppendLine("SetupAttachNodes for ", name, ":", partId);
            }

            attachNodes.Clear();

            for (int i = 0; i < part.attachNodes.Count; ++i)
            {
                AttachNode attachNode = part.attachNodes[i];

                if (log != null)
                {
                    log.AppendLine("AttachNode ", attachNode.id, " = ", (attachNode.attachedPart != null ? attachNode.attachedPart.partInfo.name : "null"));
                }

                if (attachNode.attachedPart != null && attachNode.id != "Strut")
                {
                    PartSim attachedSim;
                    if (partSimLookup.TryGetValue(attachNode.attachedPart, out attachedSim))
                    {
                        if (log != null)
                        {
                            log.AppendLine("Adding attached node ", attachedSim.name, ":", attachedSim.partId);
                        }

                        attachNodes.Add(AttachNodeSim.New(attachedSim, attachNode.id, attachNode.nodeType));
                    }
                    else
                    {
                        if (log != null)
                        {
                            log.AppendLine("No PartSim for attached part (", attachNode.attachedPart.partInfo.name, ")");
                        }
                    }
                }
            }

            for (int i = 0; i < part.fuelLookupTargets.Count; ++i)
            {
                Part p = part.fuelLookupTargets[i];

                if (p != null)
                {
                    PartSim targetSim;
                    if (partSimLookup.TryGetValue(p, out targetSim))
                    {
                        if (log != null)
                        {
                            log.AppendLine("Fuel target: ", targetSim.name, ":", targetSim.partId);
                        }

                        fuelTargets.Add(targetSim);
                    }
                    else
                    {
                        if (log != null)
                        {
                            log.AppendLine("No PartSim for fuel target (", p.name, ")");
                        }
                    }
                }
            }
        }