New() public static method

public static New ( PartSim partSim, String newId, AttachNode newNodeType ) : AttachNodeSim
partSim PartSim
newId String
newNodeType AttachNode
return AttachNodeSim
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, ")");
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void SetupAttachNodes(Dictionary <Part, PartSim> partSimLookup, LogMsg log)
        {
            if (log != null)
            {
                log.buf.AppendLine("SetupAttachNodes for " + this.name + ":" + this.partId + "");
            }

            this.attachNodes.Clear();
            for (int i = 0; i < this.part.attachNodes.Count; i++)
            {
                AttachNode attachNode = this.part.attachNodes[i];
                if (log != null)
                {
                    log.buf.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.buf.AppendLine("Adding attached node " + attachedSim.name + ":" + attachedSim.partId + "");
                        }

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

            for (int i = 0; i < this.part.fuelLookupTargets.Count; i++)
            {
                Part p = this.part.fuelLookupTargets[i];
                if (p != null)
                {
                    PartSim targetSim;
                    if (partSimLookup.TryGetValue(p, out targetSim))
                    {
                        if (log != null)
                        {
                            log.buf.AppendLine("Fuel target: " + targetSim.name + ":" + targetSim.partId);
                        }

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