Example #1
0
        public static ModelAnimationData[] parseAnimationData(ConfigNode[] nodes)
        {
            int len = nodes.Length;

            ModelAnimationData[] data = new ModelAnimationData[len];
            for (int i = 0; i < len; i++)
            {
                data[i] = new ModelAnimationData(nodes[i]);
            }
            return(data);
        }
Example #2
0
 public AnimationData(ConfigNode node)
 {
     deployLabel       = node.GetStringValue("deployLabel", "Deploy");
     retractLabel      = node.GetStringValue("retractLabel", "Retract");
     toggleLabel       = node.GetStringValue("toggleLabel", "Toggle");
     deployLimitActive = node.GetBoolValue("deployLimitActive", false);
     activeEditor      = node.GetBoolValue("activeEditor", true);
     activeFlight      = node.GetBoolValue("activeFlight", true);
     activeUnfocused   = node.GetBoolValue("activeUnfocused", false);
     activeUncommanded = node.GetBoolValue("activeUncommanded", false);
     activeEVAOnly     = node.GetBoolValue("activeEVAOnly", false);
     unfocusedRange    = node.GetFloatValue("unfocusedRange", 4f);
     oneShot           = node.GetBoolValue("oneShot", false);
     looping           = node.GetBoolValue("looping", false);
     //the actual animation data for the model
     mads = ModelAnimationData.parseAnimationData(node.GetNodes("ANIMATION"));
 }
        private void updateSolarModules()
        {
            if (!updateSolar)
            {
                return;
            }
            if (animationControl == null && !string.Equals("none", solarAnimationID))
            {
                SSTUAnimateControlled[] controls = part.GetComponents <SSTUAnimateControlled>();
                int len = controls.Length;
                for (int i = 0; i < len; i++)
                {
                    if (controls[i].animationID == solarAnimationID)
                    {
                        animationControl = controls[i];
                        break;
                    }
                }
                if (animationControl == null)
                {
                    MonoBehaviour.print("ERROR: Animation controller was null for ID: " + solarAnimationID);
                    return;
                }
            }

            bool   animEnabled  = solarModule.model.hasAnimation();
            bool   solarEnabled = solarModule.model.panelsEnabled;
            string animName     = string.Empty;
            float  animSpeed    = 1f;

            if (animEnabled)
            {
                ModelAnimationData mad = solarModule.model.modelDefinition.animationData[0];
                animName  = mad.animationName;
                animSpeed = mad.speed;
            }
            else
            {
                animName  = string.Empty;
                animSpeed = 1f;
            }

            if (animationControl != null)
            {
                animationControl.animationName  = animName;
                animationControl.animationSpeed = animSpeed;
                animationControl.reInitialize();
            }

            SSTUSolarPanelDeployable solar = part.GetComponent <SSTUSolarPanelDeployable>();

            if (solar != null)
            {
                if (solarEnabled)
                {
                    solar.resourceAmount  = solarModule.model.energy;
                    solar.pivotTransforms = solarModule.model.pivotNames;
                    solar.rayTransforms   = solarModule.model.sunNames;

                    SSTUSolarPanelDeployable.Axis axis = (SSTUSolarPanelDeployable.Axis)Enum.Parse(typeof(SSTUSolarPanelDeployable.Axis), solarModule.model.sunAxis);
                    solar.setSuncatcherAxis(axis);
                    solar.enableModule();
                }
                else
                {
                    solar.disableModule();
                }
            }
        }
Example #4
0
        public ModelDefinition(ConfigNode node)
        {
            configNode        = node;
            name              = node.GetStringValue("name", String.Empty);
            title             = node.GetStringValue("title", name);
            description       = node.GetStringValue("description", title);
            icon              = node.GetStringValue("icon");
            modelName         = node.GetStringValue("modelName", String.Empty);
            upgradeUnlockName = node.GetStringValue("upgradeUnlock", upgradeUnlockName);
            height            = node.GetFloatValue("height", height);
            volume            = node.GetFloatValue("volume", volume);
            mass              = node.GetFloatValue("mass", mass);
            cost              = node.GetFloatValue("cost", cost);
            diameter          = node.GetFloatValue("diameter", diameter);
            verticalOffset    = node.GetFloatValue("verticalOffset", verticalOffset);
            if (node.GetBoolValue("invertForTop", false))
            {
                orientation = ModelOrientation.BOTTOM;
            }
            else if (node.GetBoolValue("invertForBottom", false))
            {
                orientation = ModelOrientation.TOP;
            }
            invertAxis            = node.GetVector3("invertAxis", invertAxis);
            fairingDisabled       = node.GetBoolValue("fairingDisabled", fairingDisabled);
            fairingTopOffset      = node.GetFloatValue("fairingTopOffset", fairingTopOffset);
            rcsVerticalPosition   = node.GetFloatValue("rcsVerticalPosition", rcsVerticalPosition);
            rcsHorizontalPosition = node.GetFloatValue("rcsHorizontalPosition", rcsHorizontalPosition);
            rcsVerticalRotation   = node.GetFloatValue("rcsVerticalRotation", rcsVerticalRotation);
            rcsHorizontalRotation = node.GetFloatValue("rcsHorizontalRotation", rcsHorizontalRotation);

            ConfigNode[] subModelNodes = node.GetNodes("SUBMODEL");
            int          len           = subModelNodes.Length;

            subModelData = new SubModelData[len];
            for (int i = 0; i < len; i++)
            {
                subModelData[i] = new SubModelData(subModelNodes[i]);
            }

            defaultTextureSet = node.GetStringValue("defaultTextureSet");

            String[] attachNodeStrings = node.GetValues("node");
            len            = attachNodeStrings.Length;
            attachNodeData = new AttachNodeBaseData[len];
            for (int i = 0; i < len; i++)
            {
                attachNodeData[i] = new AttachNodeBaseData(attachNodeStrings[i]);
            }

            ConfigNode[] textureSetNodes = node.GetNodes("TEXTURESET");
            len         = textureSetNodes.Length;
            textureSets = new TextureSet[len];
            for (int i = 0; i < len; i++)
            {
                textureSets[i] = new TextureSet(textureSetNodes[i]);
            }
            if (node.HasValue("surface"))
            {
                surfaceNode = new AttachNodeBaseData(node.GetStringValue("surface"));
            }
            else
            {
                String val = (diameter * 0.5f) + ",0,0,1,0,0,2";
                surfaceNode = new AttachNodeBaseData(val);
            }

            if (node.HasNode("COMPOUNDMODEL"))
            {
                compoundModelData = new CompoundModelData(node.GetNode("COMPOUNDMODEL"));
            }

            if (node.HasNode("ANIMATION"))
            {
                animationData = ModelAnimationData.parseAnimationData(node.GetNodes("ANIMATION"));
            }
            else
            {
                animationData = new ModelAnimationData[0];
            }

            if (node.HasNode("CONSTRAINT"))
            {
                constraintData = node.GetNode("CONSTRAINT");
            }
        }