Exemplo n.º 1
0
        private void InitializePartCrewCapacity()
        {
            lastKnownPartCrewCapacity = part.CrewCapacity;
            // First, go through and note which slots already have a ModuleCrewIndicator assigned to them.
            bool[] slotAssignments = new bool[part.CrewCapacity];
            for (int moduleIndex = 0; moduleIndex < part.Modules.Count; ++moduleIndex)
            {
                ModuleCrewIndicator indicator = part.Modules[moduleIndex] as ModuleCrewIndicator;
                if (indicator == null)
                {
                    continue;
                }
                if ((indicator.slot < 0) || (indicator.slot >= part.CrewCapacity))
                {
                    indicator.slot = NO_SLOT;
                }
                else
                {
                    slotAssignments[indicator.slot] = true;
                }
            }
            // Next, go through and assign any unassigned ModuleCrewIndicators to any open slots.
            int slotIndex = 0;

            for (int moduleIndex = 0; moduleIndex < part.Modules.Count; ++moduleIndex)
            {
                ModuleCrewIndicator indicator = part.Modules[moduleIndex] as ModuleCrewIndicator;
                if (indicator == null)
                {
                    continue;
                }
                if (indicator.slot != NO_SLOT)
                {
                    continue;                            // explicitly specifies a slot
                }
                while (slotAssignments[slotIndex])
                {
                    ++slotIndex;
                    if (slotIndex >= part.CrewCapacity)
                    {
                        return;
                    }
                }
                indicator.slot             = slotIndex;
                slotAssignments[slotIndex] = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Here when the script starts up.
        /// </summary>
        public void Start()
        {
            UrlDir.UrlConfig[] configs = GameDatabase.Instance.GetConfigs(MASTER_NODE_NAME);
            if (configs.Length < 1)
            {
                Logging.Error("Can't find main " + MASTER_NODE_NAME + " config node! Some features will be inoperable.");
                return;
            }
            ConfigNode masterNode = configs[0].config;

            ProcessMasterNode(masterNode);

            // Community Trait Icons integration. If initCTIWrapper returns true,
            // it means that Community Trait Icons has been identified as being
            // loaded, and therefore we can load its colors.
            if (Compatibility.CTIWrapper.initCTIWrapper())
            {
                StartCoroutine(ModuleCrewIndicator.LoadCommunityTraitIconColors());
            }
        }