예제 #1
0
        internal void AddPart(CLSPart p)
        {
            // Add the part to the space, and the space to the part.
            p.Space = this;

            // If this space does not have a name, take the name from the part we just added.
            if ("" == this.name)
            {
                ModuleConnectedLivingSpace modCLS = (ModuleConnectedLivingSpace)p;

                if (null != modCLS)
                {
                    this.name = modCLS.spaceName;
                }
            }

            this.parts.Add(p);

            this.maxCrew += ((Part)p).CrewCapacity;

            foreach (CLSKerbal crewMember in p.Crew)
            {
                this.crew.Add(crewMember);
            }
        }
예제 #2
0
        internal void AddPart(CLSPart p)
        {
            // Add the part to the space, and the space to the part.
            p.Space = this;

            // If this space does not have a name, take the name from the part we just added.
            if ("" == name)
            {
                ModuleConnectedLivingSpace modCLS = (ModuleConnectedLivingSpace)p;

                if (null != modCLS)
                {
                    name = modCLS.spaceName;
                }
            }

            parts.Add(p);

            maxCrew += ((Part)p).CrewCapacity;

            IEnumerator <ICLSKerbal> eCrew = p.Crew.GetEnumerator();

            while (eCrew.MoveNext())
            {
                if (eCrew.Current == null)
                {
                    continue;
                }
                crew.Add((CLSKerbal)eCrew.Current);
            }
            eCrew.Dispose();
        }
예제 #3
0
        public bool highlighted; // This allows us to remember if a part is SUPPOSED to be highlighted by CLS. We can then use appropriate moments to ensure that it either is or is not.

        public CLSPart(Part p)
        {
            part = p;

            habitable = IsHabitable(part);
            navigable = IsNavigable(part);
            space     = null;

            crew = new List <ICLSKerbal>();
            IEnumerator <ProtoCrewMember> crewmembers = p.protoModuleCrew.GetEnumerator();

            while (crewmembers.MoveNext())
            {
                if (crewmembers.Current == null)
                {
                    continue;
                }
                CLSKerbal kerbal = new CLSKerbal(crewmembers.Current, this);
                crew.Add(kerbal);
            }
            crewmembers.Dispose();

            // Does the part have a CLSModule on it? If so then give the module a reference to ourselves to make its life a bit easier.
            {
                ModuleConnectedLivingSpace m = (ModuleConnectedLivingSpace)this;
                if (null != m)
                {
                    m.clsPart = this;
                }
                else
                {
                    // Do not bother logging warnings about EVAs not being configured for CLS!
                    if (part.Modules.OfType <KerbalEVA>().Count() == 0)
                    {
                        // This part does not have a CLSModule. If it is habitable or navigable then it will not be possible to persist the name of the space in the savefile. Log a warning.
                        if (habitable)
                        {
                            Debug.LogWarning($"Part {part.partInfo.title} is habitable but does not have ModuleConnectedLivingSpace defined in the config. It would be better if it did as some infomation used by CLS will not be saved in the savefile.");
                        }
                        else if (navigable)
                        {
                            Debug.LogWarning($"Part {part.partInfo.title} is passable but does not have ModuleConnectedLivingSpace defined in the config. It would be better if it did as some infomation used by CLS will not be saved in the savefile.");
                        }
                    }
                }
            }

            // Run check for dynamic crew capacity
            if (CLSAddon.dynamicCrewCapacity)
            {
                CheckDCC();
            }
        }
예제 #4
0
        // Helper method that figures out if surfaceAttachmentsPassable is set for a CLSModule on the specified part.
        private bool PartHasPassableSurfaceAttachments(Part p)
        {
            ModuleConnectedLivingSpace clsMod = (ModuleConnectedLivingSpace)p;

            if (null == clsMod)
            {
                // No CLS module. Therefore surface attachments are definately not passable
                return(false);
            }
            else
            {
                return(clsMod.surfaceAttachmentsPassable);
            }
        }
예제 #5
0
    private bool IsNavigable(Part p)
    {
      // first test - does it have a crew capacity?
      if (p.CrewCapacity > 0)
      {
        return true;
      }

      ModuleConnectedLivingSpace CLSMod = (ModuleConnectedLivingSpace)this;
      if (null != CLSMod)
      {
        return (CLSMod.passable);
      }

      return false;
    }
예제 #6
0
        bool highlighted = false; // This allows us to remember if a part is SUPPOSED to be highlighted by CLS. We can then use appropriate moments to ensure that it either is or is not.

        public CLSPart(Part p)
        {
            this.part = p;

            habitable = IsHabitable(this.part);
            navigable = IsNavigable(this.part);
            space     = null;

            this.crew = new List <ICLSKerbal>();
            foreach (ProtoCrewMember crewMember in p.protoModuleCrew)
            {
                CLSKerbal kerbal = new CLSKerbal(crewMember, this);
                this.crew.Add(kerbal);
            }

            // Does the part have a CLSModule on it? If so then give the module a reference to ourselves to make its life a bit easier.
            {
                ModuleConnectedLivingSpace m = (ModuleConnectedLivingSpace)this;
                if (null != m)
                {
                    m.clsPart = this;
                }
                else
                {
                    // Do not bother logging warnings about EVAs not being configured for CLS!
                    if (this.part.Modules.OfType <KerbalEVA>().Count() == 0)
                    {
                        // This part does not have a CLSModule. If it is habitable or navigable then it will not be possible to persist the name of the space in the savefile. Log a warning.
                        if (this.habitable)
                        {
                            Debug.LogWarning("Part " + this.part.partInfo.title + " is habitable but does not have ModuleConnectedLivingSpace defined in the config. It would be better if it did as some infomation used by CLS will not be saved in the savefile.");
                        }
                        else if (this.navigable)
                        {
                            Debug.LogWarning("Part " + this.part.partInfo.title + " is passable but does not have ModuleConnectedLivingSpace defined in the config. It would be better if it did as some infomation used by CLS will not be saved in the savefile.");
                        }
                    }
                }
            }
        }
예제 #7
0
        private bool IsDockedDockingPortPassable(Part thisPart, Part otherPart)
        {
            bool retVal = false;

            // First things first - does this part even support CLS? If it does not then the dockingPort is certain to be impassable.
            ModuleConnectedLivingSpace clsModThis = (ModuleConnectedLivingSpace)thisPart;

            if (null == clsModThis)
            {
                //Debug.Log("Part " + thisPart.partInfo.title + "(" + thisPart.uid + ") does not seem to support CLS. Setting it as impassable.");
                return(false);
            }
            else
            {
                // As it does support CLS, first set the passable value to the the "passable" field for this part
                retVal = clsModThis.passable;
            }

            // Loop through all the ModuleDockingNodes for this part and check if any are docked to the other part.
            IEnumerator <ModuleDockingNode> epNodes = thisPart.Modules.OfType <ModuleDockingNode>().GetEnumerator();

            while (epNodes.MoveNext())
            {
                if (epNodes.Current == null)
                {
                    continue;
                }
                if (CheckForNodeDockedToPart(epNodes.Current, otherPart))
                {
                    // We have found the ModuleDockingNode that represents the docking connection on this part.
                    //Debug.Log("Found docking node that represents the docking connection to the 'other' part");

                    // First consider if this docked connection has an accompanying AttachNode may be defined as (im)passable by CLS.
                    if (epNodes.Current.referenceNode.id != string.Empty)
                    {
                        //Debug.Log("docking node uses a referenceAttachNode called: " + docNode.referenceNode.id + " In the meantime, passablenodes: " + clsModThis.passablenodes + " impassablenodes: " + clsModThis.impassablenodes);
                        if (clsModThis.passablenodes.Contains(epNodes.Current.referenceNode.id))
                        {
                            retVal = true;
                        }

                        if (clsModThis.impassablenodes.Contains(epNodes.Current.referenceNode.id))
                        {
                            retVal = false;
                        }
                    }
                    // Second, if there is no AttachNode, what about the type / size of the docking port
                    else
                    {
                        //Debug.Log("docking node does not use referenceNode.id, instead considering the nodeType: " + docNode.nodeType + " In the meantime, impassableDockingNodeTypes:" + clsModThis.impassableDockingNodeTypes + " passableDockingNodeTypes:" + clsModThis.passableDockingNodeTypes);
                        if (clsModThis.impassableDockingNodeTypes.Contains(epNodes.Current.nodeType))
                        {
                            retVal = false; // Docking node is of an impassable type.
                        }
                        if (clsModThis.passableDockingNodeTypes.Contains(epNodes.Current.nodeType))
                        {
                            retVal = true; // Docking node is of a passable type.
                        }
                    }

                    // third, consider if there is an open / closed hatch
                    {
                        ModuleDockingHatch docHatch = GetHatchForDockingNode(epNodes.Current);
                        if (docHatch != null)
                        {
                            // The dockingNode is actually a DockingNodeHatch :)
                            if (!docHatch.HatchOpen)
                            {
                                //Debug.Log("DockingNodeHatch is closed and so can not be passed through");
                                retVal = false; // Hatch in the docking node is closed, so it is impassable
                            }
                        }
                    }
                    break;
                }
            }
            //Debug.Log("returning " + retVal);
            return(retVal);
        }