コード例 #1
0
        //public float GetModuleCost()
        //{
        //    return moduleCost;
        //}

        public override string GetInfo()
        {
            if (showInfo)
            {
                List <string> variantList;
                if (objectDisplayNames.Length > 0)
                {
                    variantList = ParseTools.ParseNames(objectDisplayNames);
                }
                else
                {
                    variantList = ParseTools.ParseNames(objects);
                }

                StringBuilder info = new StringBuilder();
                info.AppendLine("Part variants available:");
                for (int i = 0; i < variantList.Count; i++)
                {
                    info.AppendLine(variantList[i]);
                }
                return(info.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #2
0
        public override string GetInfo()
        {
            if (showInfo)
            {
                var variantList = ParseTools.ParseNames(textureNames.Length > 0 ? textureNames : mapNames);

                textureDisplayList = ParseTools.ParseNames(textureDisplayNames);
                var info = new StringBuilder();
                info.AppendLine("Alternate textures available:");
                if (variantList.Count == 0)
                {
                    if (variantList.Count == 0)
                    {
                        info.AppendLine("None");
                    }
                }
                for (var i = 0; i < variantList.Count; i++)
                {
                    info.AppendLine(i > textureDisplayList.Count - 1
                        ? getTextureDisplayName(variantList[i])
                        : textureDisplayList[i]);
                }
                info.AppendLine("\nUse the Next Texture button on the right click menu.");
                return(info.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #3
0
        public void initializeData()
        {
            if (!initialized)
            {
                debug = new InterstellarDebugMessages(debugMode, "InterstellarMeshSwitch");
                // you can't have fuel switching without symmetry, it breaks the editor GUI.
                if (useFuelSwitchModule)
                {
                    updateSymmetry = true;
                }

                parseObjectNames();
                fuelTankSetupList = ParseTools.ParseIntegers(fuelTankSetups);
                objectDisplayList = ParseTools.ParseNames(objectDisplayNames);

                if (useFuelSwitchModule)
                {
                    fuelSwitch = part.GetComponent <InterstellarFuelSwitch>();
                    if (fuelSwitch == null)
                    {
                        useFuelSwitchModule = false;
                        debug.debugMessage("no FSfuelSwitch module found, despite useFuelSwitchModule being true");
                    }
                }
                initialized = true;
            }
        }
コード例 #4
0
        public override string GetInfo()
        {
            if (showInfo)
            {
                var variantList = ParseTools.ParseNames(textureNames.Length > 0 ? textureNames : mapNames);
                textureDisplayList = ParseTools.ParseNames(textureDisplayNames);

                var info = StringBuilderCache.Acquire();
                info.AppendLine(Localizer.Format("#LOC_IFS_TextureSwitch_GetInfo"));//"Alternate textures available:"
                if (variantList.Count == 0)
                {
                    if (variantList.Count == 0)
                    {
                        info.AppendLine(Localizer.Format("#LOC_IFS_TextureSwitch_GetInfoNone"));//"None"
                    }
                }

                for (var i = 0; i < variantList.Count; i++)
                {
                    info.AppendLine(i > textureDisplayList.Count - 1 ?
                                    getTextureDisplayName(variantList[i]) : textureDisplayList[i]);
                }

                info.AppendLine().AppendLine().Append(Localizer.Format("#LOC_IFS_TextureSwitch_GetInfoNext"));//Use the Next Texture button on the right click menu.
                return(info.ToStringAndRelease());
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #5
0
        public override string GetInfo()
        {
            try
            {
                if (!showInfo)
                {
                    return(string.Empty);
                }

                var resourceList = ParseTools.ParseNames(resourceNames);
                var info         = new StringBuilder();

                info.AppendLine("Fuel tank setups available:");

                foreach (string t in resourceList)
                {
                    info.AppendLine(t.Replace(",", ", "));
                }
                return(info.ToString());
            }
            catch (Exception e)
            {
                Debug.LogError("InsterstellarFuelSwitch GetInfo Error " + e.Message);
                throw;
            }
        }
コード例 #6
0
        // runs the kind of commands that would normally be in OnStart, if they have not already been run. In case a method is called upon externally, but values have not been set up yet
        private void initializeData()
        {
            if (initialized)
            {
                return;
            }

            debug = new InterstellarDebugMessages(debugMode, "InterstellarTextureSwitch2");
            // you can't have fuel switching without symmetry, it breaks the editor GUI.
            if (useFuelSwitchModule)
            {
                updateSymmetry = true;
            }

            objectList         = ParseTools.ParseNames(objectNames, true);
            texList            = ParseTools.ParseNames(textureNames, true, true, textureRootFolder);
            mapList            = ParseTools.ParseNames(mapNames, true, true, textureRootFolder);
            textureDisplayList = ParseTools.ParseNames(textureDisplayNames);
            fuelTankSetupList  = ParseTools.ParseIntegers(fuelTankSetups);

            debug.debugMessage("found " + texList.Count + " textures, using number " + selectedTexture + ", found " + objectList.Count + " objects, " + mapList.Count + " maps");

            foreach (String targetObjectName in objectList)
            {
                Transform[]     targetObjectTransformArray = part.FindModelTransforms(targetObjectName);
                List <Material> matList = new List <Material>();
                foreach (Transform t in targetObjectTransformArray)
                {
                    if (t != null)
                    {
                        var renderer = t.gameObject.GetComponent <Renderer>();

                        // check for if the object even has a mesh. otherwise part list loading crashes
                        if (renderer != null)
                        {
                            Material targetMat = renderer.material;
                            if (targetMat != null && !matList.Contains(targetMat))
                            {
                                matList.Add(targetMat);
                            }
                        }
                    }
                }
                targetMats.Add(matList);
            }

            if (useFuelSwitchModule)
            {
                fuelSwitch = part.GetComponent <InterstellarFuelSwitch>(); // only looking for first, not supporting multiple fuel switchers
                if (fuelSwitch == null)
                {
                    useFuelSwitchModule = false;
                    debug.debugMessage("no InterstellarFuelSwitch module found, despite useFuelSwitchModule being true");
                }
            }
            initialized = true;
        }
コード例 #7
0
        public override string GetInfo()
        {
            if (showInfo)
            {
                List <string> variantList = ParseTools.ParseNames(objectDisplayNames.Length > 0 ? objectDisplayNames : objects);

                var info = new StringBuilder();
                info.AppendLine(Localizer.Format("#LOC_IFS_MeshSwitch_GetInfo") + ":");
                for (int i = 0; i < variantList.Count; i++)
                {
                    info.AppendLine(variantList[i]);
                }
                return(info.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #8
0
        public override string GetInfo()
        {
            if (showInfo)
            {
                var variantList = ParseTools.ParseNames(objectDisplayNames.Length > 0 ? objectDisplayNames : objects);

                var info = StringBuilderCache.Acquire();
                info.Append(Localizer.Format("#LOC_IFS_MeshSwitch_GetInfo")).AppendLine(":");

                foreach (var t in variantList)
                {
                    info.AppendLine(t);
                }
                return(info.ToStringAndRelease());
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #9
0
        public void InitializeData(bool forced = false)
        {
            if (initialized && !forced)
            {
                return;
            }

            // you can't have fuel switching without symmetry, it breaks the editor GUI.
            if (useFuelSwitchModule)
            {
                updateSymmetry = true;
            }

            objectTransforms = ParseObjectNames();
            var fuelTankSetupList   = ParseTools.ParseNames(fuelTankSetups);
            var objectDisplayList   = ParseTools.ParseNames(objectDisplayNames);
            var indexNamesList      = ParseTools.ParseNames(indexNames);
            var tankSwitchNamesList = ParseTools.ParseNames(tankSwitchNames);

            // we need to clear the list because InitializeData might be called multiple times
            meshConfigurationList.Clear();

            for (var i = 0; i < objectDisplayList.Count; i++)
            {
                meshConfigurationList.Add(new MeshConfiguration()
                {
                    objectDisplay    = objectDisplayList[i],
                    tankSwitchName   = Localizer.Format(i < tankSwitchNamesList.Count ? tankSwitchNamesList[i] : objectDisplayList[i]),
                    indexName        = i < indexNamesList.Count ? indexNamesList[i] : objectDisplayList[i],
                    fuelTankSetup    = i < fuelTankSetupList.Count ? fuelTankSetupList[i] : objectDisplayList[i],
                    objectTransforms = i < objectTransforms.Count ? objectTransforms[i] : new List <Transform>()
                });
            }

            if (orderByIndexNames)
            {
                if (debugMode)
                {
                    Debug.Log("[IFS] - InterstellarMeshSwitch " + part.GetInstanceID() + " order meshConfigurationList on indexName");
                }
                meshConfigurationList.Sort((a, b) => string.Compare(a.indexName, b.indexName, StringComparison.Ordinal));
            }

            if (debugMode)
            {
                foreach (var config in meshConfigurationList)
                {
                    Debug.Log("fuelTankSetup:" + config.fuelTankSetup + " indexName:" + config.indexName +
                              " objectDisplay: " + config.objectDisplay + " tankSwitchName:" + config.tankSwitchName);
                }
            }

            if (useFuelSwitchModule)
            {
                var fuelSwitches = part.FindModulesImplementing <InterstellarFuelSwitch>();

                if (fuelSwitches.Any() && !string.IsNullOrEmpty(searchTankId))
                {
                    fuelSwitch = fuelSwitches.FirstOrDefault(m => m.tankId == searchTankId);
                }

                if (fuelSwitch == null)
                {
                    fuelSwitch = fuelSwitches.FirstOrDefault();
                }

                if (fuelSwitch == null)
                {
                    useFuelSwitchModule = false;
                }
                else
                {
                    var matchingObject = fuelSwitch.FindMatchingConfig(this);

                    var matchingArray = matchingObject.Split(',');

                    var matchingIndexName = matchingArray[0];

                    var matchingMesh = meshConfigurationList.FirstOrDefault(m => m.indexName == matchingIndexName);

                    if (matchingMesh != null)
                    {
                        selectedObject = meshConfigurationList.IndexOf(matchingMesh);
                    }
                    else
                    {
                        var matchingIndex = int.Parse(matchingObject.Split(',')[1]);

                        if (HighLogic.LoadedSceneIsFlight || matchingIndex >= 0)
                        {
                            if (debugMode)
                            {
                                Debug.Log("[IFS] - InterstellarMeshSwitch " + part.GetInstanceID() +
                                          " sets selectedObject to matching object " + matchingObject);
                            }
                            selectedObject = matchingIndex;
                        }
                    }
                }
            }
            initialized = true;
        }
コード例 #10
0
        // runs the kind of commands that would normally be in OnStart, if they have not already been run. In case a method is called upon externally, but values have not been set up yet
        private void InitializeData()
        {
            if (initialized)
            {
                return;
            }

            debug = new InterstellarDebugMessages(debugMode, "InterstellarTextureSwitch2");

            // you can't have fuel switching without symmetry, it breaks the editor GUI.
            if (useFuelSwitchModule)
            {
                updateSymmetry = true;
            }

            objectList         = ParseTools.ParseNames(objectNames, true);
            mapList            = ParseTools.ParseNames(mapNames, true, true, textureRootFolder);
            textureDisplayList = ParseTools.ParseNames(textureDisplayNames);
            fuelTankSetupList  = ParseTools.ParseNames(fuelTankSetups);

            var textureNameGroups = textureNames.Split(';').ToArray();

            for (var i = 0; i < textureNameGroups.Count(); i++)
            {
                var texListGroup = ParseTools.ParseNames(textureNameGroups[i], true, true, textureRootFolder);

                texList.Add(texListGroup);
            }

            debug.debugMessage("found " + texList.Count + " textures, using number " + selectedTexture + ", found " + objectList.Count + " objects, " + mapList.Count + " maps");

            for (var i = 0; i < objectList.Count(); i++)
            {
                Transform[] targetObjectTransformArray = part.FindModelTransforms(objectList[i]);

                var matList = new List <Material>();

                foreach (Transform t in targetObjectTransformArray)
                {
                    if (t == null)
                    {
                        continue;
                    }

                    var renderer = t.gameObject.GetComponent <Renderer>();

                    // check for if the object even has a mesh. otherwise part list loading crashes
                    if (renderer == null)
                    {
                        continue;
                    }

                    Material targetMat = renderer.material;
                    if (targetMat != null && !matList.Contains(targetMat))
                    {
                        matList.Add(targetMat);
                    }
                }

                targetMats.Add(matList);
            }

            if (useFuelSwitchModule)
            {
                fuelSwitch = part.GetComponent <InterstellarFuelSwitch>(); // only looking for first, not supporting multiple fuel switchers
                if (fuelSwitch == null)
                {
                    useFuelSwitchModule = false;
                    debug.debugMessage("no InterstellarFuelSwitch module found, despite useFuelSwitchModule being true");
                }
                else
                {
                    var matchingObject = fuelSwitch.FindMatchingConfig(this);
                    var matchingIndex  = int.Parse(matchingObject.Split(',')[1]);

                    if (matchingIndex >= 0)
                    {
                        selectedTexture = matchingIndex;
                    }
                }
            }
            initialized = true;
        }
コード例 #11
0
        public void InitializeData()
        {
            try
            {
                if (!initialized)
                {
                    debug = new InterstellarDebugMessages(debugMode, "InterstellarMeshSwitch");
                    // you can't have fuel switching without symmetry, it breaks the editor GUI.
                    if (useFuelSwitchModule)
                    {
                        updateSymmetry = true;
                    }

                    parseObjectNames();
                    fuelTankSetupList = ParseTools.ParseIntegers(fuelTankSetups);
                    objectDisplayList = ParseTools.ParseNames(objectDisplayNames);

                    tankSwitchNamesList = new List <string>();

                    // add any missing names
                    var tankSwitchNamesListTmp = ParseTools.ParseNames(tankSwitchNames);
                    for (int i = 0; i < objectDisplayList.Count; i++)
                    {
                        if (i < tankSwitchNamesListTmp.Count)
                        {
                            tankSwitchNamesList.Add(tankSwitchNamesListTmp[i]);
                        }
                        else
                        {
                            tankSwitchNamesList.Add(objectDisplayList[i]);
                        }
                    }

                    if (useFuelSwitchModule)
                    {
                        var fuelSwitches = part.FindModulesImplementing <InterstellarFuelSwitch>();

                        if (!String.IsNullOrEmpty(searchTankId))
                        {
                            fuelSwitch = fuelSwitches.FirstOrDefault(m => m.tankId == searchTankId);
                        }

                        if (fuelSwitch == null)
                        {
                            fuelSwitch = fuelSwitches.FirstOrDefault();
                        }

                        //searchTankId
                        if (fuelSwitch == null)
                        {
                            useFuelSwitchModule = false;
                            debug.debugMessage("no FSfuelSwitch module found, despite useFuelSwitchModule being true");
                        }
                    }
                    initialized = true;
                }
            }
            catch (Exception e)
            {
                Debug.LogError("[IFS] - InterstellarMeshSwitch.InitializeData Error: " + e.Message);
                throw;
            }
        }
コード例 #12
0
        public void InitializeData()
        {
            try
            {
                if (initialized)
                {
                    return;
                }

                // you can't have fuel switching without symmetry, it breaks the editor GUI.
                if (useFuelSwitchModule)
                {
                    updateSymmetry = true;
                }

                objectTransforms = ParseObjectNames();
                var fuelTankSetupList   = ParseTools.ParseNames(fuelTankSetups);
                var objectDisplayList   = ParseTools.ParseNames(objectDisplayNames);
                var indexNamesList      = ParseTools.ParseNames(indexNames);
                var tankSwitchNamesList = ParseTools.ParseNames(tankSwitchNames);

                for (var i = 0; i < objectDisplayList.Count; i++)
                {
                    meshConfigurationList.Add(new meshConfiguration()
                    {
                        objectDisplay    = objectDisplayList[i],
                        tankSwitchName   = Localizer.Format(i < tankSwitchNamesList.Count ? tankSwitchNamesList[i] : objectDisplayList[i]),
                        indexName        = i < indexNamesList.Count ? indexNamesList[i] : objectDisplayList[i],
                        fuelTankSetup    = i < fuelTankSetupList.Count ? fuelTankSetupList[i] : objectDisplayList[i],
                        objectTransforms = i < objectTransforms.Count ? objectTransforms[i] : new List <Transform>()
                    });
                }

                if (orderByIndexNames)
                {
                    meshConfigurationList = meshConfigurationList.OrderBy(m => m.indexName).ToList();
                }

                if (useFuelSwitchModule)
                {
                    var fuelSwitches = part.FindModulesImplementing <InterstellarFuelSwitch>();

                    if (fuelSwitches.Any() && !string.IsNullOrEmpty(searchTankId))
                    {
                        fuelSwitch = fuelSwitches.FirstOrDefault(m => m.tankId == searchTankId);
                    }

                    if (fuelSwitch == null)
                    {
                        fuelSwitch = fuelSwitches.FirstOrDefault();
                    }

                    if (fuelSwitch == null)
                    {
                        useFuelSwitchModule = false;
                    }
                    else
                    {
                        var matchingObject = fuelSwitch.FindMatchingConfig();

                        if (HighLogic.LoadedSceneIsFlight || matchingObject >= 0)
                        {
                            selectedObject = matchingObject;
                        }
                    }
                }
                initialized = true;
            }
            catch (Exception e)
            {
                Debug.LogError("[IFS] - InterstellarMeshSwitch.InitializeData Error: " + e.Message);
                throw;
            }
        }