예제 #1
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;
            }
        }
예제 #2
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;
        }
        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;
            }
        }
        // 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;
        }
예제 #5
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;
            }
        }
        // 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 && t.gameObject.renderer != null) // check for if the object even has a mesh. otherwise part list loading crashes
                    {
                        Material targetMat = t.gameObject.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;

        }