public WaterfallEffect(ConfigNode node, WaterfallEffectTemplate templateOwner)
 {
     parentTemplate         = templateOwner;
     TemplatePositionOffset = Vector3.zero;
     TemplateRotationOffset = Vector3.zero;
     TemplateScaleOffset    = Vector3.one;
     Load(node);
 }
 public WaterfallEffect(WaterfallEffect fx)
 {
     parentTemplate         = fx.parentTemplate;
     TemplatePositionOffset = fx.TemplatePositionOffset;
     TemplateRotationOffset = fx.TemplateRotationOffset;
     TemplateScaleOffset    = fx.TemplateScaleOffset;
     Load(fx.Save());
 }
示例#3
0
        public WaterfallEffect(string parent, WaterfallModel mdl, WaterfallEffectTemplate templateOwner)
        {
            parentName = parent;
            model      = mdl;

            parentTemplate         = templateOwner;
            TemplatePositionOffset = parentTemplate.position;
            TemplateRotationOffset = parentTemplate.rotation;
            TemplateScaleOffset    = parentTemplate.scale;
            fxModifiers            = new List <EffectModifier>();
        }
示例#4
0
        public WaterfallEffect(WaterfallEffect fx, WaterfallEffectTemplate templateOwner)
        {
            parentTemplate         = templateOwner;
            TemplatePositionOffset = parentTemplate.position;
            TemplateRotationOffset = parentTemplate.rotation;
            TemplateScaleOffset    = parentTemplate.scale;

            if (parentTemplate.overrideParentTransform != "" && parentTemplate.overrideParentTransform != null)
            {
                fx.savedNode.SetValue("parentName", parentTemplate.overrideParentTransform, true);
            }

            Load(fx.savedNode);
        }
示例#5
0
        public void CopyEffect(WaterfallEffect toCopy, WaterfallEffectTemplate template)
        {
            Utils.Log($"[ModuleWaterfallFX]: Copying effect {toCopy}", LogType.Modules);

            WaterfallEffect newEffect = new WaterfallEffect(toCopy);

            if (Templates != null && template != null)
            {
                foreach (WaterfallEffectTemplate t in Templates)
                {
                    if (t == template)
                    {
                        t.allFX.Add(newEffect);
                    }
                }
            }


            allFX.Add(newEffect);
            newEffect.InitializeEffect(this, false, useRelativeScaling);
        }
        private void LoadEffects(ConfigNode node)
        {
            Utils.Log(String.Format("[ModuleWaterfallFX]: Loading Effects on moduleID {0}", moduleID), LogType.Modules);
            var effectNodes   = node.GetNodes(WaterfallConstants.EffectNodeName);
            var templateNodes = node.GetNodes(WaterfallConstants.TemplateNodeName);

            if (allFX == null)
            {
                allFX = new();
            }
            if (allTemplates == null)
            {
                allTemplates = new();
            }
            if (allFX.Count == 0)
            {
                foreach (var fxDataNode in effectNodes)
                {
                    allFX.Add(new(fxDataNode));
                }


                Utils.Log(String.Format("[ModuleWaterfallFX]: Loading Template effects on moduleID {0}", moduleID), LogType.Modules);
                foreach (var templateNode in templateNodes)
                {
                    var template = new WaterfallEffectTemplate(templateNode);
                    allTemplates.Add(template);
                    foreach (var fx in template.allFX)
                    {
                        allFX.Add(fx);
                    }

                    Utils.Log($"[ModuleWaterfallFX]: Loaded effect template {template.templateName}", LogType.Modules);
                }
            }

            Utils.Log($"[ModuleWaterfallFX]: Finished loading {allTemplates.Count} templates", LogType.Modules);
            Utils.Log($"[ModuleWaterfallFX]: Finished loading {allFX.Count} effects", LogType.Modules);
        }
示例#7
0
        /// <summary>
        /// Load alll CONTROLLERS, TEMPLATES and EFFECTS
        /// </summary>
        /// <param name="node"></param>
        ///

        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            Utils.Log($"[ModuleWaterfallFX]: OnLoad called with contents \n{node.ToString()}", LogType.Modules);

            ConfigNode[] effectNodes   = node.GetNodes(WaterfallConstants.EffectNodeName);
            ConfigNode[] templateNodes = node.GetNodes(WaterfallConstants.TemplateNodeName);

            if (initialized)
            {
                Utils.Log($"[ModuleWaterfallFX]: Already initialized, cleaning up effects", LogType.Modules);
                CleanupEffects();
            }

            LoadControllers(node);

            Utils.Log(String.Format("[ModuleWaterfallFX]: Loading Effects on moduleID {0}", moduleID), LogType.Modules);

            if (allFX == null)
            {
                allFX = new List <WaterfallEffect>();
            }
            if (allTemplates == null)
            {
                allTemplates = new List <WaterfallEffectTemplate>();
            }
            else
            {
                if (effectNodes.Length > 0 && allFX.Count > 0 || allFX.Count > 0 && templateNodes.Length > 0)
                {
                    CleanupEffects();
                    allFX.Clear();
                    allTemplates.Clear();
                }
            }

            foreach (ConfigNode fxDataNode in effectNodes)
            {
                allFX.Add(new WaterfallEffect(fxDataNode));
            }


            Utils.Log(String.Format("[ModuleWaterfallFX]: Loading Template effects on moduleID {0}", moduleID), LogType.Modules);
            foreach (ConfigNode templateNode in templateNodes)
            {
                WaterfallEffectTemplate template = new WaterfallEffectTemplate(templateNode);
                allTemplates.Add(template);
                foreach (WaterfallEffect fx in template.allFX)
                {
                    allFX.Add(fx);
                }
                Utils.Log($"[ModuleWaterfallFX]: Loaded effect template {template.templateName}", LogType.Modules);
                //string templateName = "";
                //string overrideTransformName = "";
                //Vector3 scaleOffset = Vector3.one;
                //Vector3 positionOffset = Vector3.zero;
                //Vector3 rotationOffset = Vector3.zero;


                //templateNode.TryGetValue("templateName", ref templateName);
                //templateNode.TryGetValue("overrideParentTransform", ref overrideTransformName);
                //templateNode.TryParseVector3("scale", ref scaleOffset);
                //templateNode.TryParseVector3("rotation", ref rotationOffset);
                //templateNode.TryParseVector3("position", ref positionOffset);

                //WaterfallTemplate template = WaterfallTemplates.GetTemplate(templateName);

                //foreach (WaterfallEffect fx in template.allFX)
                //{
                //  allFX.Add(new WaterfallEffect(fx, positionOffset, rotationOffset, scaleOffset, overrideTransformName));
                //}
                //Utils.Log($"[ModuleWaterfallFX]: Loaded effect template {template.templateName}", LogType.Modules);
            }
            Utils.Log($"[ModuleWaterfallFX]: Finished loading {allTemplates.Count} templates", LogType.Modules);
            Utils.Log($"[ModuleWaterfallFX]: Finished loading {allFX.Count} effects", LogType.Modules);

            if (initialized)
            {
                Utils.Log($"[ModuleWaterfallFX]: Reinitializing", LogType.Modules);
                InitializeControllers();
                ReinitializeEffects();
            }
        }
示例#8
0
        //public virtual void OnBeforeSerialize()
        //{
        //  Utils.Log($"[ModuleWaterfallFX] Serializing");
        //  serializedData = ScriptableObject.CreateInstance<SerializedData>();

        //  ConfigNode newNode = new ConfigNode("Serialized");
        //  foreach (WaterfallEffect fx in allFX)
        //  {
        //    newNode.AddNode(fx.Save());
        //  }


        //  serializedData.SerializedString = newNode.ToString();
        //}

        //public virtual void OnAfterDeserialize()
        //{
        //  Utils.Log($"[ModuleWaterfallFX] Deserializing");

        //  OnLoad(ConfigNode.Parse(serializedData.SerializedString));

        //  Destroy(serializedData);
        //  serializedData = null;
        //}

        /// <summary>
        /// Load alll CONTROLLERS, TEMPLATES and EFFECTS
        /// </summary>
        /// <param name="node"></param>
        ///

        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            ConfigNode[] controllerNodes = node.GetNodes(WaterfallConstants.ControllerNodeName);
            ConfigNode[] effectNodes     = node.GetNodes(WaterfallConstants.EffectNodeName);
            ConfigNode[] templateNodes   = node.GetNodes(WaterfallConstants.TemplateNodeName);

            if (initialized)
            {
                Utils.Log($"[ModuleWaterfallFX]: Cleaning up effects", LogType.Modules);
                CleanupEffects();
            }

            if (allControllers == null)
            {
                Utils.Log(String.Format("[ModuleWaterfallFX]: Loading Controllers on moduleID {0}", moduleID), LogType.Modules);
                allControllers = new Dictionary <string, WaterfallController>();
                foreach (ConfigNode controllerDataNode in controllerNodes)
                {
                    string ctrlType = "throttle";
                    if (!controllerDataNode.TryGetValue("linkedTo", ref ctrlType))
                    {
                        Utils.LogWarning(String.Format("[ModuleWaterfallFX]: Controller on moduleID {0} does not define linkedTo, setting throttle as default ", moduleID));
                    }
                    if (ctrlType == "throttle")
                    {
                        ThrottleController tCtrl = new ThrottleController(controllerDataNode);
                        allControllers.Add(tCtrl.name, tCtrl);
                        Utils.Log(String.Format("[ModuleWaterfallFX]: Loaded Throttle Controller on moduleID {0}", moduleID), LogType.Modules);
                    }
                    if (ctrlType == "atmosphere_density")
                    {
                        AtmosphereDensityController aCtrl = new AtmosphereDensityController(controllerDataNode);
                        allControllers.Add(aCtrl.name, aCtrl);
                        Utils.Log(String.Format("[ModuleWaterfallFX]: Loaded Atmosphere Density Controller on moduleID {0}", moduleID), LogType.Modules);
                    }
                    if (ctrlType == "custom")
                    {
                        CustomController cCtrl = new CustomController(controllerDataNode);
                        allControllers.Add(cCtrl.name, cCtrl);
                        Utils.Log(String.Format("[ModuleWaterfallFX]: Loaded Custom Controller on moduleID {0}", moduleID), LogType.Modules);
                    }
                    if (ctrlType == "rcs")
                    {
                        RCSController rcsCtrl = new RCSController(controllerDataNode);
                        allControllers.Add(rcsCtrl.name, rcsCtrl);
                        Utils.Log(String.Format("[ModuleWaterfallFX]: Loaded RCS Controller on moduleID {0}", moduleID), LogType.Modules);
                    }
                    if (ctrlType == "random")
                    {
                        RandomnessController rCtrl = new RandomnessController(controllerDataNode);
                        allControllers.Add(rCtrl.name, rCtrl);
                        Utils.Log(String.Format("[ModuleWaterfallFX]: Loaded Randomness Controller on moduleID {0}", moduleID), LogType.Modules);
                    }
                }
            }

            Utils.Log(String.Format("[ModuleWaterfallFX]: Loading Effects on moduleID {0}", moduleID), LogType.Modules);

            if (allFX == null)
            {
                allFX = new List <WaterfallEffect>();
            }
            else
            {
                if (effectNodes.Length > 0 && allFX.Count > 0 || allFX.Count > 0 && templateNodes.Length > 0)
                {
                    CleanupEffects();
                    allFX.Clear();
                }
            }

            foreach (ConfigNode fxDataNode in effectNodes)
            {
                allFX.Add(new WaterfallEffect(fxDataNode));
            }


            Utils.Log(String.Format("[ModuleWaterfallFX]: Loading Template effects on moduleID {0}", moduleID), LogType.Modules);
            foreach (ConfigNode templateNode in templateNodes)
            {
                string  templateName          = "";
                string  overrideTransformName = "";
                Vector3 scaleOffset           = Vector3.one;
                Vector3 positionOffset        = Vector3.zero;
                Vector3 rotationOffset        = Vector3.zero;


                templateNode.TryGetValue("templateName", ref templateName);
                templateNode.TryGetValue("overrideParentTransform", ref overrideTransformName);
                templateNode.TryParseVector3("scale", ref scaleOffset);
                templateNode.TryParseVector3("rotation", ref rotationOffset);
                templateNode.TryParseVector3("position", ref positionOffset);

                WaterfallEffectTemplate template = WaterfallTemplates.GetTemplate(templateName);

                foreach (WaterfallEffect fx in template.allFX)
                {
                    allFX.Add(new WaterfallEffect(fx, positionOffset, rotationOffset, scaleOffset, overrideTransformName));
                }
                Utils.Log($"[ModuleWaterfallFX]: Loaded effect template {template.templateName}", LogType.Modules);
            }

            Utils.Log($"[ModuleWaterfallFX]: Finished loading {allFX.Count} effects", LogType.Modules);

            if (initialized)
            {
                Utils.Log($"[ModuleWaterfallFX]: Reinitializing", LogType.Modules);
                ReinitializeEffects();
            }
        }