Ejemplo n.º 1
0
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int target;

            if (int.TryParse(node.GetValue("Survey_Target"), out target))
            {
                body = FlightGlobals.Bodies[target];
            }
            else
            {
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
            if (!int.TryParse(node.GetValue("Survey_Type"), out surveyType))
            {
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
            if (this.ParameterCount == 0)
            {
                DMUtils.Logging("No Parameters Loaded For This Survey Contract; Removing Now...");
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
        }
Ejemplo n.º 2
0
        private void monitorAnomScience(CelestialBody B, string s, string name)
        {
            if (FlightGlobals.currentMainBody == B)
            {
                if (s == scienceContainer.exp.id)
                {
                    DMAnomalyList.updateAnomaly(FlightGlobals.ActiveVessel, city);
                    DMUtils.Logging("Distance To Anomaly: {0} ; Altitude Above Anomaly: {1} ; Horizontal Distance To Anomaly: {2}", city.Vdistance, city.Vheight, city.Vhorizontal);

                    //Draw a cone above the anomaly position up to 100km with a diameter of 60km at its widest
                    if (city.Vdistance < 100000)
                    {
                        if (situation == ExperimentSituations.FlyingLow || situation == ExperimentSituations.InSpaceLow || situation == ExperimentSituations.FlyingHigh)
                        {
                            if (city.Vheight > 625 && city.Vheight < 100000)
                            {
                                double vHeight = city.Vheight;
                                if (vHeight > 50000)
                                {
                                    vHeight = 50000;
                                }
                                if (city.Vhorizontal < (60000 * (city.Vheight / 50000)))
                                {
                                    ScreenMessages.PostScreenMessage("Results From Anomalous Signal Recovered", 6f, ScreenMessageStyle.UPPER_CENTER);
                                    collected = true;
                                }
                                else
                                {
                                    ScreenMessages.PostScreenMessage("Anomalous signal too weak, try again when closer", 6f, ScreenMessageStyle.UPPER_CENTER);
                                }
                            }
                            else if (city.Vheight < 625)
                            {
                                if (city.Vhorizontal < 750)
                                {
                                    ScreenMessages.PostScreenMessage("Results From Anomalous Signal Recovered", 6f, ScreenMessageStyle.UPPER_CENTER);
                                    collected = true;
                                }
                                else
                                {
                                    ScreenMessages.PostScreenMessage("Anomalous signal too weak, try again when closer", 6f, ScreenMessageStyle.UPPER_CENTER);
                                }
                            }
                        }
                        else if (situation == ExperimentSituations.SrfLanded)
                        {
                            if (city.Vhorizontal < 500)
                            {
                                ScreenMessages.PostScreenMessage("Results From Anomalous Signal Recovered", 6f, ScreenMessageStyle.UPPER_CENTER);
                                collected = true;
                            }
                            else
                            {
                                ScreenMessages.PostScreenMessage("Anomalous signal too weak, try again when closer", 6f, ScreenMessageStyle.UPPER_CENTER);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int target;

            string[] orbitString = node.GetValue("Orbital_Parameter").Split('|');
            if (int.TryParse(orbitString[0], out target))
            {
                body = FlightGlobals.Bodies[target];
            }
            else
            {
                DMUtils.Logging("Failed To Load Target Body Variables; Mag Long Orbit Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            if (!double.TryParse(orbitString[1], out orbitTime))
            {
                DMUtils.Logging("Failed To Load Orbit Time Variables; Mag Long Orbit Parameter Reset");
                orbitTime = 0;
            }
            if (!double.TryParse(orbitString[2], out timeNeeded))
            {
                DMUtils.Logging("Failed To Load Time Needed Variables; Mag Long Orbit Parameter Reset to Default Value Of 100 Days");
                timeNeeded = 2160000;
            }
        }
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int target;

            if (int.TryParse(node.GetValue("Mag_Survey_Target"), out target))
            {
                body = FlightGlobals.Bodies[target];
            }
            else
            {
                DMUtils.Logging("Failed To Load Mag Contract");
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
            if (this.GetParameter <DMLongOrbitParameter>() == null)
            {
                DMUtils.Logging("Magnetic Field Long Orbit Parameter Not Found; Removing This Contract");
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
            if (this.ParameterCount == 0)
            {
                DMUtils.Logging("No Parameters Loaded For Mag Contract; Removing Now...");
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
        }
Ejemplo n.º 5
0
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int targetBodyID, targetSituation;

            string[] scienceString = node.GetValue("Science_Subject").Split('|');
            if (!int.TryParse(scienceString[0], out type))
            {
                DMUtils.Logging("Failed To Load Contract Type Value; Collect Science Parameter Reset");
                type = 1;
            }
            name = scienceString[1];
            DMUtils.availableScience["All"].TryGetValue(name, out scienceContainer);
            if (scienceContainer == null)
            {
                DMUtils.Logging("Failed To Load Science Container Variables; Collect Science Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            else
            {
                partName = scienceContainer.sciPart;
            }
            if (int.TryParse(scienceString[2], out targetBodyID))
            {
                body = FlightGlobals.Bodies[targetBodyID];
            }
            else
            {
                DMUtils.Logging("Failed To Load Target Body Variables; Collect Science Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            if (int.TryParse(scienceString[3], out targetSituation))
            {
                scienceLocation = (ExperimentSituations)targetSituation;
            }
            else
            {
                DMUtils.Logging("Failed To Load Situation Variables; Collect Science Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            biomeName = scienceString[4];
            if (!float.TryParse(scienceString[5], out returnedScience))
            {
                DMUtils.Logging("Failed To Load Returned Data Variables; Collect Science Parameter Reset");
                returnedScience = 0;
            }
            subject = string.Format("{0}@{1}{2}{3}", scienceContainer.exp.id, body.name, scienceLocation, biomeName.Replace(" ", ""));
        }
Ejemplo n.º 6
0
        public static DMAnomalyObject getAnomalyObject(string body, string city)
        {
            if (!anomalies.Contains(body))
            {
                DMUtils.Logging("No anomaly of name [{0}] found for body [{1}]", city, body);
                return(null);
            }

            return(anomalies[body].getAnomaly(city));
        }
Ejemplo n.º 7
0
 private void hackWaypointIcons()
 {
     foreach (GameDatabase.TextureInfo ti in GameDatabase.Instance.databaseTexture.Where(t => t.name.StartsWith(iconURL)))
     {
         if (ti != null)
         {
             string s = ti.name.Remove(0, iconURL.Length);
             ti.name = "Squad/Contracts/Icons/" + s;
             DMUtils.Logging("DMagic Icon [{0}] Inserted Into FinePrint Database", s);
         }
     }
 }
Ejemplo n.º 8
0
 private void findAssemblies(string[] assemblies)
 {
     foreach (string name in assemblies)
     {
         AssemblyLoader.LoadedAssembly assembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == name);
         if (assembly != null)
         {
             DMUtils.Logging("Assembly: {0} Found; Reactivating Experiment Properties", assembly.assembly.GetName().Name);
             DMUtils.whiteListed = true;
         }
     }
 }
Ejemplo n.º 9
0
 private void scienceRecieve(float sci, ScienceSubject sub)
 {
     if (sub.id.Contains(subject))
     {
         if (collected)
         {
             base.SetComplete();
         }
         else
         {
             DMUtils.Logging("Data Not Collected From Correctly Sized Asteroid");
         }
     }
 }
Ejemplo n.º 10
0
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int targetLocation;

            string[] scienceString = node.GetValue("Science_Subject").Split('|');
            name = scienceString[0];
            DMUtils.availableScience["All"].TryGetValue(name, out scienceContainer);
            if (scienceContainer == null)
            {
                DMUtils.Logging("Failed To Load Science Container Variables; Asteroid Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            else
            {
                partName = scienceContainer.sciPart;
            }
            if (int.TryParse(scienceString[1], out size))
            {
                aSize = DMUtils.sizeHash(size);
            }
            else
            {
                DMUtils.Logging("Failed To Load Asteroid Size Value; Asteroid Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            if (int.TryParse(scienceString[2], out targetLocation))
            {
                scienceLocation = (ExperimentSituations)targetLocation;
            }
            else
            {
                DMUtils.Logging("Failed To Load Situation Variables; Asteroid Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            if (!bool.TryParse(scienceString[3], out collected))
            {
                DMUtils.Logging("Failed To Load Collecte State; Asteroid Parameter Reset");
                collected = false;
            }
            subject = string.Format("{0}@Asteroid{1}", scienceContainer.exp.id, scienceLocation);
        }
Ejemplo n.º 11
0
 protected override void OnLoad(ConfigNode node)
 {
     //if (DMScienceScenario.SciScenario != null)
     //	if (DMScienceScenario.SciScenario.contractsReload)
     //		DMUtils.resetContracts();
     hash = node.GetValue("Asteroid_Size_Class");
     if (this.ParameterCount == 0)
     {
         DMUtils.Logging("No Parameters Loaded For This Asteroid Contract; Removing Now...");
         this.Unregister();
         ContractSystem.Instance.Contracts.Remove(this);
         return;
     }
 }
Ejemplo n.º 12
0
        private void initializeUtils()
        {
            DMUtils.OnAnomalyScience  = new EventData <CelestialBody, String, String>("OnAnomalyScience");
            DMUtils.OnAsteroidScience = new EventData <String, String>("OnAsteroidScience");

            var infoAtt = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;

            if (infoAtt != null)
            {
                DMUtils.version = infoAtt.InformationalVersion;
                DMUtils.Logging("DMagic Orbital Science Version: [{0}] Loaded", DMUtils.version);
            }
            else
            {
                DMUtils.version = "";
                DMUtils.Logging("Something Went Wrong Here... Version Not Set, Contracts Might Reset");
            }

            DMUtils.rand = new System.Random();

            DMUtils.availableScience = new Dictionary <string, Dictionary <string, DMScienceContainer> >();

            foreach (var sciType in Enum.GetValues(typeof(DMScienceType)))
            {
                string type = ((DMScienceType)sciType).ToString();
                if (!string.IsNullOrEmpty(type))
                {
                    if (!DMUtils.availableScience.ContainsKey(type))
                    {
                        DMUtils.availableScience[type] = new Dictionary <string, DMScienceContainer>();
                    }
                    else
                    {
                        DMUtils.Logging("");
                    }
                }
                else
                {
                    DMUtils.Logging("");
                }
            }

            DMUtils.backStory = new Dictionary <string, List <string> >();
            DMUtils.backStory.Add("survey", new List <string>());
            DMUtils.backStory.Add("asteroid", new List <string>());
            DMUtils.backStory.Add("anomaly", new List <string>());
            DMUtils.backStory.Add("magnetic", new List <string>());
        }
Ejemplo n.º 13
0
        public static List <Guid> parse(this ConfigNode node, string name, List <Guid> original)
        {
            if (!node.HasValue(name))
            {
                return(original);
            }

            string source = node.GetValue(name);

            if (string.IsNullOrEmpty(source))
            {
                return(original);
            }
            else
            {
                List <Guid> ids = new List <Guid>();

                string[] sA = source.Split('|');
                for (int i = 0; i < sA.Length; i++)
                {
                    try
                    {
                        Guid g = new Guid(sA[i]);

                        if (g == null)
                        {
                            continue;
                        }

                        if (!ids.Contains(g))
                        {
                            ids.Add(g);
                        }
                    }
                    catch (Exception e)
                    {
                        DMUtils.Logging("Guid invalid:\n{0}", e);
                        continue;
                    }
                }

                return(ids);
            }
        }
Ejemplo n.º 14
0
 public DMAnomalyObject(PQSCity City)
 {
     city = City;
     name = city.name;
     try
     {
         body = FlightGlobals.Bodies.FirstOrDefault(b => b.name == city.transform.parent.name);
     }
     catch (Exception e)
     {
         DMUtils.Logging("Something Went Wrong Here: {0}", e);
     }
     if (body != null)
     {
         worldLocation = city.transform.position;
         lat           = clampLat(body.GetLatitude(worldLocation));
         lon           = clampLon(body.GetLongitude(worldLocation));
     }
 }
Ejemplo n.º 15
0
        public DMAnomalyObject getAnomalyObject(string body, string city)
        {
            if (anomalies.ContainsKey(body))
            {
                if (anomalies[body].ContainsKey(city))
                {
                    return(anomalies[body][city]);
                }
                else
                {
                    DMUtils.Logging("No anomaly of name [{0}] found for body [{1}]", city, body);
                }
            }
            else
            {
                DMUtils.Logging("No anomalies found for body [{0}]", body);
            }

            return(null);
        }
Ejemplo n.º 16
0
        private void seismicLoad()
        {
            ConfigNode seismicNode = GameDatabase.Instance.GetConfigNode("DMagicOrbitalScience/Resources/DMSeismicSettings/DM_SEISMIC_SETTINGS");

            if (seismicNode != null)
            {
                DMSeismicHandler.nearPodMinDistance = seismicNode.parse("Seismic_Near_Pod_Min_Distance", 10f);
                DMSeismicHandler.nearPodMaxDistance = seismicNode.parse("Seismic_Near_Pod_Max_Distance", 2500f);
                DMSeismicHandler.nearPodThreshold   = seismicNode.parse("Seismic_Near_Pod_Threshold", 500f);

                DMSeismicHandler.farPodMinDistance = seismicNode.parse("Seismic_Far_Pod_Min_Distance", 2500f);
                DMSeismicHandler.farPodMaxDistance = seismicNode.parse("Seismic_Far_Pod_Max_Distance", 15000f);
                DMSeismicHandler.farPodThreshold   = seismicNode.parse("Seismic_Far_Pod_Threshold", 4000f);

                DMSeismicHandler.podMinAngle       = seismicNode.parse("Seismic_Pod_Min_Angle", 20f);
                DMSeismicHandler.podAngleThreshold = seismicNode.parse("Seismic_Pod_Angle_Threshold", 90f);
            }
            else
            {
                DMUtils.Logging("Broken Seismic Config...");
            }
        }
Ejemplo n.º 17
0
        private List <Guid> stringSplitGuid(string source)
        {
            if (source == "")
            {
                return(new List <Guid>());
            }
            string[]    s  = source.Split(',');
            List <Guid> id = new List <Guid>();

            for (int j = 0; j < s.Length; j++)
            {
                try
                {
                    Guid g = new Guid(s[j]);
                    id.Add(g);
                }
                catch (Exception e)
                {
                    DMUtils.Logging("Guid invalid: {0}", e);
                }
            }
            return(id);
        }
Ejemplo n.º 18
0
        private void initializeUtils()
        {
            DMUtils.OnAnomalyScience  = new EventData <CelestialBody, String, String>("OnAnomalyScience");
            DMUtils.OnAsteroidScience = new EventData <String, String>("OnAsteroidScience");

            var infoAtt = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;

            if (infoAtt != null)
            {
                DMUtils.version = infoAtt.InformationalVersion;
                DMUtils.Logging("DMagic Orbital Science Version: [{0}] Loaded", DMUtils.version);
            }
            else
            {
                DMUtils.version = "";
                DMUtils.Logging("Something Went Wrong Here... Version Not Set, Contracts Might Reset");
            }

            DMUtils.rand = new System.Random();

            DMUtils.availableScience        = new Dictionary <string, Dictionary <string, DMScienceContainer> >();
            DMUtils.availableScience["All"] = new Dictionary <string, DMScienceContainer>();
            DMUtils.availableScience[DMScienceType.Surface.ToString()]    = new Dictionary <string, DMScienceContainer>();
            DMUtils.availableScience[DMScienceType.Aerial.ToString()]     = new Dictionary <string, DMScienceContainer>();
            DMUtils.availableScience[DMScienceType.Space.ToString()]      = new Dictionary <string, DMScienceContainer>();
            DMUtils.availableScience[DMScienceType.Biological.ToString()] = new Dictionary <string, DMScienceContainer>();
            DMUtils.availableScience[DMScienceType.Asteroid.ToString()]   = new Dictionary <string, DMScienceContainer>();
            DMUtils.availableScience[DMScienceType.Anomaly.ToString()]    = new Dictionary <string, DMScienceContainer>();

            DMUtils.backStory               = new Dictionary <string, List <string> >();
            DMUtils.backStory["generic"]    = new List <string>();
            DMUtils.backStory["survey"]     = new List <string>();
            DMUtils.backStory["biological"] = new List <string>();
            DMUtils.backStory["asteroid"]   = new List <string>();
            DMUtils.backStory["anomaly"]    = new List <string>();
            DMUtils.backStory["magnetic"]   = new List <string>();
        }
Ejemplo n.º 19
0
        public static Vessel parse(this ConfigNode node, string name, Vessel original)
        {
            if (!node.HasValue(name))
            {
                return(original);
            }

            Vessel v = original;

            string s = node.GetValue(name);

            if (string.IsNullOrEmpty(s))
            {
                return(original);
            }
            else
            {
                try
                {
                    Guid id = new Guid(s);

                    v = FlightGlobals.Vessels.FirstOrDefault(a => a.id == id);

                    if (v == null)
                    {
                        return(original);
                    }
                }
                catch (Exception e)
                {
                    DMUtils.Logging("Vessel invalid:\n{0}", e);
                    return(original);
                }
            }

            return(v);
        }
Ejemplo n.º 20
0
        private void configLoad()
        {
            ConfigNode DMcontractDefs = GameDatabase.Instance.GetConfigNode("DMagicOrbitalScience/Resources/DMContracts/DMContracts");

            if (DMcontractDefs == null)
            {
                return;
            }

            foreach (ConfigNode node in DMcontractDefs.GetNodes("DM_CONTRACT_EXPERIMENT"))
            {
                if (node == null)
                {
                    continue;
                }
                DMScienceContainer DMscience = null;
                ScienceExperiment  exp       = null;

                //Some apparently not impossible errors can cause duplicate experiments to be added to the R&D science experiment dictionary
                try
                {
                    exp = ResearchAndDevelopment.GetExperiment(node.GetValue("experimentID"));
                }
                catch (Exception e)
                {
                    Debug.LogError("[DM] Whoops. Something really wrong happened here, a duplicate science experiment definition may be present somewhere; stopping this contract experiment from loading..." + e);
                    continue;
                }
                if (exp != null)
                {
                    string name = node.parse("name", "null");
                    if (name == "null")
                    {
                        continue;
                    }

                    int type = node.parse("type", (int)1000);
                    if (type == 1000)
                    {
                        continue;
                    }

                    float transmit = node.parse("xmitDataScalar", (float)1000);
                    if (transmit >= 1000)
                    {
                        continue;
                    }

                    string part = node.parse("part", "None");

                    string agent = node.parse("agent", "Any");

                    DMscience = new DMScienceContainer(exp, (DMScienceType)type, part, agent, transmit);

                    foreach (var sciType in Enum.GetValues(typeof(DMScienceType)))
                    {
                        string typeString = ((DMScienceType)sciType).ToString();
                        if (string.IsNullOrEmpty(typeString))
                        {
                            continue;
                        }

                        if (DMUtils.availableScience.ContainsKey(typeString))
                        {
                            if ((DMScienceType)sciType == DMScienceType.All)
                            {
                                if (!DMUtils.availableScience[typeString].ContainsKey(name))
                                {
                                    DMUtils.availableScience[typeString].Add(name, DMscience);
                                }
                            }
                            else if (((DMScienceType)type & (DMScienceType)sciType) == (DMScienceType)sciType)
                            {
                                if (!DMUtils.availableScience[typeString].ContainsKey(name))
                                {
                                    DMUtils.availableScience[typeString].Add(name, DMscience);
                                }
                            }
                        }
                    }
                }
            }

            DMUtils.Logging("Successfully Added {0} New Experiments To Contract List", DMUtils.availableScience["All"].Count);

            ConfigNode DMAnomalyNode  = DMcontractDefs.GetNode("DMAnomaly");
            ConfigNode DMAsteroidNode = DMcontractDefs.GetNode("DMAsteroid");
            ConfigNode DMMagNode      = DMcontractDefs.GetNode("DMMag");
            ConfigNode DMReconNode    = DMcontractDefs.GetNode("DMRecon");
            ConfigNode DMSurveyNode   = DMcontractDefs.GetNode("DMSurvey");

            if (DMAnomalyNode != null)
            {
                DMContractDefs.DMAnomaly.maxOffers = DMAnomalyNode.parse("maxOffers", (int)2);
                DMContractDefs.DMAnomaly.maxActive = DMAnomalyNode.parse("maxActive", (int)3);

                DMContractDefs.DMAnomaly.TrivialReconLevelRequirement     = DMAnomalyNode.parse("Trivial_Recon_Level_Requirement", (int)0);
                DMContractDefs.DMAnomaly.SignificantReconLevelRequirement = DMAnomalyNode.parse("Significant_Recon_Level_Requirement", (int)1);
                DMContractDefs.DMAnomaly.ExceptionalReconLevelRequirement = DMAnomalyNode.parse("Exceptional_Recon_Level_Requirement", (int)1);

                DMContractDefs.DMAnomaly.TrivialAnomalyLevel     = DMAnomalyNode.parse("Trivial_Anomaly_Level_Requirement", (float)0);
                DMContractDefs.DMAnomaly.SignificantAnomalyLevel = DMAnomalyNode.parse("Significant_Anomaly_Level_Requirement", (float)0.3f);
                DMContractDefs.DMAnomaly.ExceptionalAnomalyLevel = DMAnomalyNode.parse("Exceptional_Anomaly_Level_Requirement", (float)0.6f);

                DMContractDefs.DMAnomaly.backStory = DMAnomalyNode.parse("Backstory", '|', new List <string>(1)
                {
                    "Something, Something, Something..."
                });

                DMContractDefs.DMAnomaly.backStory = DMUtils.formatFixStringList(DMContractDefs.DMAnomaly.backStory);

                ConfigNode AnomalyExpireNode = DMAnomalyNode.GetNode("Expire");
                ConfigNode AnomalyFundsNode  = DMAnomalyNode.GetNode("Funds");
                ConfigNode AnomalySciNode    = DMAnomalyNode.GetNode("Science");
                ConfigNode AnomalyRepNode    = DMAnomalyNode.GetNode("Reputation");

                if (AnomalyExpireNode != null)
                {
                    DMContractDefs.DMAnomaly.Expire.MinimumExpireDays = AnomalyExpireNode.parse("MinimumExpireDays", (int)4);
                    DMContractDefs.DMAnomaly.Expire.MaximumExpireDays = AnomalyExpireNode.parse("MaximumExpireDays", (int)10);
                    DMContractDefs.DMAnomaly.Expire.DeadlineYears     = AnomalyExpireNode.parse("DeadlineYears", (float)1.5);
                }

                if (AnomalyFundsNode != null)
                {
                    DMContractDefs.DMAnomaly.Funds.BaseAdvance  = AnomalyFundsNode.parse("BaseAdvance", (float)20000);
                    DMContractDefs.DMAnomaly.Funds.BaseReward   = AnomalyFundsNode.parse("BaseReward", (float)24000);
                    DMContractDefs.DMAnomaly.Funds.BaseFailure  = AnomalyFundsNode.parse("BaseFailure", (float)24000);
                    DMContractDefs.DMAnomaly.Funds.ParamReward  = AnomalyFundsNode.parse("ParamReward", (float)8000);
                    DMContractDefs.DMAnomaly.Funds.ParamFailure = AnomalyFundsNode.parse("ParamFailure", (float)0);
                }

                if (AnomalySciNode != null)
                {
                    DMContractDefs.DMAnomaly.Science.BaseReward      = AnomalySciNode.parse("BaseReward", (float)0);
                    DMContractDefs.DMAnomaly.Science.ParamReward     = AnomalySciNode.parse("ParamReward", (float)5);
                    DMContractDefs.DMAnomaly.Science.SecondaryReward = AnomalySciNode.parse("SecondaryReward", (float)0.25);
                }

                if (AnomalyRepNode != null)
                {
                    DMContractDefs.DMAnomaly.Reputation.BaseReward   = AnomalyRepNode.parse("BaseReward", (float)7);
                    DMContractDefs.DMAnomaly.Reputation.BaseFailure  = AnomalyRepNode.parse("BaseFailure", (float)6);
                    DMContractDefs.DMAnomaly.Reputation.ParamReward  = AnomalyRepNode.parse("ParamReward", (float)0);
                    DMContractDefs.DMAnomaly.Reputation.ParamFailure = AnomalyRepNode.parse("ParamFailure", (float)0);
                }
            }

            if (DMAsteroidNode != null)
            {
                DMContractDefs.DMAsteroid.maxOffers = DMAsteroidNode.parse("maxOffers", (int)2);
                DMContractDefs.DMAsteroid.maxActive = DMAsteroidNode.parse("maxActive", (int)3);

                DMContractDefs.DMAsteroid.trivialScienceRequests     = DMAsteroidNode.parse("Max_Trivial_Science_Requests", (int)3);
                DMContractDefs.DMAsteroid.significantScienceRequests = DMAsteroidNode.parse("Max_Significant_Science_Requests", (int)4);
                DMContractDefs.DMAsteroid.exceptionalScienceRequests = DMAsteroidNode.parse("Max_Exceptional_Science_Requests", (int)6);

                DMContractDefs.DMAsteroid.backStory = DMAsteroidNode.parse("Backstory", '|', new List <string>(1)
                {
                    "Something, Something, Something..."
                });

                DMContractDefs.DMAsteroid.backStory = DMUtils.formatFixStringList(DMContractDefs.DMAsteroid.backStory);

                ConfigNode AsteroidExpireNode = DMAsteroidNode.GetNode("Expire");
                ConfigNode AsteroidFundsNode  = DMAsteroidNode.GetNode("Funds");
                ConfigNode AsteroidSciNode    = DMAsteroidNode.GetNode("Science");
                ConfigNode AsteroidRepNode    = DMAsteroidNode.GetNode("Reputation");

                if (AsteroidExpireNode != null)
                {
                    DMContractDefs.DMAsteroid.Expire.MinimumExpireDays = AsteroidExpireNode.parse("MinimumExpireDays", (int)4);
                    DMContractDefs.DMAsteroid.Expire.MaximumExpireDays = AsteroidExpireNode.parse("MaximumExpireDays", (int)10);
                    DMContractDefs.DMAsteroid.Expire.DeadlineYears     = AsteroidExpireNode.parse("DeadlineYears", (float)3.8);
                }

                if (AsteroidFundsNode != null)
                {
                    DMContractDefs.DMAsteroid.Funds.BaseAdvance  = AsteroidFundsNode.parse("BaseAdvance", (float)8000);
                    DMContractDefs.DMAsteroid.Funds.BaseReward   = AsteroidFundsNode.parse("BaseReward", (float)9500);
                    DMContractDefs.DMAsteroid.Funds.BaseFailure  = AsteroidFundsNode.parse("BaseFailure", (float)7000);
                    DMContractDefs.DMAsteroid.Funds.ParamReward  = AsteroidFundsNode.parse("ParamReward", (float)5000);
                    DMContractDefs.DMAsteroid.Funds.ParamFailure = AsteroidFundsNode.parse("ParamFailure", (float)0);
                }

                if (AsteroidSciNode != null)
                {
                    DMContractDefs.DMAsteroid.Science.BaseReward  = AsteroidSciNode.parse("BaseReward", (float)0);
                    DMContractDefs.DMAsteroid.Science.ParamReward = AsteroidSciNode.parse("ParamReward", (float)0.25);
                }

                if (AsteroidRepNode != null)
                {
                    DMContractDefs.DMAsteroid.Reputation.BaseReward   = AsteroidRepNode.parse("BaseReward", (float)8);
                    DMContractDefs.DMAsteroid.Reputation.BaseFailure  = AsteroidRepNode.parse("BaseFailure", (float)6);
                    DMContractDefs.DMAsteroid.Reputation.ParamReward  = AsteroidRepNode.parse("ParamReward", (float)0);
                    DMContractDefs.DMAsteroid.Reputation.ParamFailure = AsteroidRepNode.parse("ParamFailure", (float)0);
                }
            }

            if (DMMagNode != null)
            {
                DMContractDefs.DMMagnetic.maxOffers = DMMagNode.parse("maxOffers", (int)2);
                DMContractDefs.DMMagnetic.maxActive = DMMagNode.parse("maxActive", (int)4);

                DMContractDefs.DMMagnetic.trivialTimeModifier     = DMMagNode.parse("Trivial_Mission_Length", (double)100);
                DMContractDefs.DMMagnetic.significantTimeModifier = DMMagNode.parse("Significant_Mission_Length", (double)150);
                DMContractDefs.DMMagnetic.exceptionalTimeModifier = DMMagNode.parse("Exceptional_Mission_Length", (double)200);

                DMContractDefs.DMMagnetic.trivialEccentricityMultiplier     = DMMagNode.parse("Trivial_Eccentricity_Modifier", (double)0.2);
                DMContractDefs.DMMagnetic.significantEccentricityMultiplier = DMMagNode.parse("Significant_Eccentricity_Modifier", (double)0.35);
                DMContractDefs.DMMagnetic.exceptionalEccentricityMultiplier = DMMagNode.parse("Exceptional_Eccentricity_Modifier", (double)0.5);

                DMContractDefs.DMMagnetic.trivialInclinationMultiplier     = DMMagNode.parse("Trivial_Inclination_Modifier", (double)20);
                DMContractDefs.DMMagnetic.significantInclinationMultiplier = DMMagNode.parse("Significant_Inclination_Modifier", (double)40);
                DMContractDefs.DMMagnetic.exceptionalInclinationMultiplier = DMMagNode.parse("Exceptional_Inclination_Modifier", (double)60);

                DMContractDefs.DMMagnetic.magnetometerExperimentTitle = DMMagNode.parse("Magnetometer_Experiment_Title", "Magnetometer Scan");
                DMContractDefs.DMMagnetic.rpwsExperimentTitle         = DMMagNode.parse("RPWS_Experiment_Title", "Radio Plasma Wave Scan");

                DMContractDefs.DMMagnetic.useVesselWaypoints = DMMagNode.parse("Use_Vessel_Waypoints", (bool)true);

                DMContractDefs.DMMagnetic.magParts = DMMagNode.parse("Magnetometer_Parts", ',', new List <string>(2)
                {
                    "dmmagBoom", "dmUSMagBoom"
                });
                DMContractDefs.DMMagnetic.rpwsParts = DMMagNode.parse("RPWS_Parts", ',', new List <string>(2)
                {
                    "rpwsAnt", "USRPWS"
                });

                DMContractDefs.DMMagnetic.backStory = DMMagNode.parse("Backstory", '|', new List <string>(1)
                {
                    "Something, Something, Something..."
                });

                DMContractDefs.DMMagnetic.backStory = DMUtils.formatFixStringList(DMContractDefs.DMMagnetic.backStory);

                ConfigNode MagExpireNode = DMMagNode.GetNode("Expire");
                ConfigNode MagFundsNode  = DMMagNode.GetNode("Funds");
                ConfigNode MagSciNode    = DMMagNode.GetNode("Science");
                ConfigNode MagRepNode    = DMMagNode.GetNode("Reputation");

                if (MagExpireNode != null)
                {
                    DMContractDefs.DMMagnetic.Expire.MinimumExpireDays = MagExpireNode.parse("MinimumExpireDays", (int)4);
                    DMContractDefs.DMMagnetic.Expire.MaximumExpireDays = MagExpireNode.parse("MaximumExpireDays", (int)10);
                    DMContractDefs.DMMagnetic.Expire.DeadlineModifier  = MagExpireNode.parse("DeadlineModifier", (float)3.7);
                }

                if (MagFundsNode != null)
                {
                    DMContractDefs.DMMagnetic.Funds.BaseAdvance  = MagFundsNode.parse("BaseAdvance", (float)21000);
                    DMContractDefs.DMMagnetic.Funds.BaseReward   = MagFundsNode.parse("BaseReward", (float)25000);
                    DMContractDefs.DMMagnetic.Funds.BaseFailure  = MagFundsNode.parse("BaseFailure", (float)23000);
                    DMContractDefs.DMMagnetic.Funds.ParamReward  = MagFundsNode.parse("ParamReward", (float)4000);
                    DMContractDefs.DMMagnetic.Funds.ParamFailure = MagFundsNode.parse("ParamFailure", (float)0);
                }

                if (MagSciNode != null)
                {
                    DMContractDefs.DMMagnetic.Science.BaseReward  = MagSciNode.parse("BaseReward", (float)24);
                    DMContractDefs.DMMagnetic.Science.ParamReward = MagSciNode.parse("ParamReward", (float)2);
                }

                if (MagRepNode != null)
                {
                    DMContractDefs.DMMagnetic.Reputation.BaseReward   = MagRepNode.parse("BaseReward", (float)8);
                    DMContractDefs.DMMagnetic.Reputation.BaseFailure  = MagRepNode.parse("BaseFailure", (float)7);
                    DMContractDefs.DMMagnetic.Reputation.ParamReward  = MagRepNode.parse("ParamReward", (float)0);
                    DMContractDefs.DMMagnetic.Reputation.ParamFailure = MagRepNode.parse("ParamFailure", (float)0);
                }
            }

            if (DMReconNode != null)
            {
                DMContractDefs.DMRecon.maxOffers = DMReconNode.parse("maxOffers", (int)2);
                DMContractDefs.DMRecon.maxActive = DMReconNode.parse("maxActive", (int)4);

                DMContractDefs.DMRecon.trivialTimeModifier     = DMReconNode.parse("Trivial_Mission_Length", (double)50);
                DMContractDefs.DMRecon.significantTimeModifier = DMReconNode.parse("Significant_Mission_Length", (double)100);
                DMContractDefs.DMRecon.exceptionalTimeModifier = DMReconNode.parse("Exceptional_Mission_Length", (double)150);

                DMContractDefs.DMRecon.useVesselWaypoints = DMReconNode.parse("Use_Vessel_Waypoints", (bool)true);

                DMContractDefs.DMRecon.trivialExperimentTitle     = DMReconNode.parse("Trivial_Experiment_Title", "Recon Scan");
                DMContractDefs.DMRecon.significantExperimentTitle = DMReconNode.parse("Significant_Experiment_Title", "SIGINT Scan");
                DMContractDefs.DMRecon.exceptionalExperimentTitle = DMReconNode.parse("Exceptional_Experiment_Title", "Recon Scan");

                DMContractDefs.DMRecon.reconTrivialParts = DMReconNode.parse("Trivial_Parts", ',', new List <string>(1)
                {
                    "dmReconSmall"
                });
                DMContractDefs.DMRecon.reconSignificantParts = DMReconNode.parse("Significant_Parts", ',', new List <string>(3)
                {
                    "dmSIGINT", "dmSIGINT.Small", "dmSIGINT.End"
                });
                DMContractDefs.DMRecon.reconExceptionalParts = DMReconNode.parse("Exceptional_Parts", ',', new List <string>(1)
                {
                    "dmReconLarge"
                });

                DMContractDefs.DMRecon.backStory = DMReconNode.parse("Backstory", '|', new List <string>(1)
                {
                    "Something, Something, Something..."
                });

                DMContractDefs.DMRecon.backStory = DMUtils.formatFixStringList(DMContractDefs.DMRecon.backStory);

                ConfigNode ReconExpireNode = DMReconNode.GetNode("Expire");
                ConfigNode ReconFundsNode  = DMReconNode.GetNode("Funds");
                ConfigNode ReconSciNode    = DMReconNode.GetNode("Science");
                ConfigNode ReconRepNode    = DMReconNode.GetNode("Reputation");

                if (ReconExpireNode != null)
                {
                    DMContractDefs.DMRecon.Expire.MinimumExpireDays = ReconExpireNode.parse("MinimumExpireDays", (int)4);
                    DMContractDefs.DMRecon.Expire.MaximumExpireDays = ReconExpireNode.parse("MaximumExpireDays", (int)10);
                    DMContractDefs.DMRecon.Expire.DeadlineModifier  = ReconExpireNode.parse("DeadlineModifier", (float)3.9);
                }

                if (ReconFundsNode != null)
                {
                    DMContractDefs.DMRecon.Funds.BaseAdvance  = ReconFundsNode.parse("BaseAdvance", (float)50000);
                    DMContractDefs.DMRecon.Funds.BaseReward   = ReconFundsNode.parse("BaseReward", (float)60000);
                    DMContractDefs.DMRecon.Funds.BaseFailure  = ReconFundsNode.parse("BaseFailure", (float)38000);
                    DMContractDefs.DMRecon.Funds.ParamReward  = ReconFundsNode.parse("ParamReward", (float)8000);
                    DMContractDefs.DMRecon.Funds.ParamFailure = ReconFundsNode.parse("ParamFailure", (float)0);
                }

                if (ReconSciNode != null)
                {
                    DMContractDefs.DMRecon.Science.BaseReward  = ReconSciNode.parse("BaseReward", (float)10);
                    DMContractDefs.DMRecon.Science.ParamReward = ReconSciNode.parse("ParamReward", (float)2);
                }

                if (ReconRepNode != null)
                {
                    DMContractDefs.DMRecon.Reputation.BaseReward   = ReconRepNode.parse("BaseReward", (float)12);
                    DMContractDefs.DMRecon.Reputation.BaseFailure  = ReconRepNode.parse("BaseFailure", (float)10);
                    DMContractDefs.DMRecon.Reputation.ParamReward  = ReconRepNode.parse("ParamReward", (float)0);
                    DMContractDefs.DMRecon.Reputation.ParamFailure = ReconRepNode.parse("ParamFailure", (float)0);
                }
            }

            if (DMSurveyNode != null)
            {
                DMContractDefs.DMSurvey.maxOffers = DMSurveyNode.parse("maxOffers", (int)2);
                DMContractDefs.DMSurvey.maxActive = DMSurveyNode.parse("maxActive", (int)4);

                DMContractDefs.DMSurvey.trivialScienceRequests     = DMSurveyNode.parse("Max_Trivial_Science_Requests", (int)4);
                DMContractDefs.DMSurvey.significantScienceRequests = DMSurveyNode.parse("Max_Significant_Science_Requests", (int)6);
                DMContractDefs.DMSurvey.exceptionalScienceRequests = DMSurveyNode.parse("Max_Exceptional_Science_Requests", (int)8);

                DMContractDefs.DMSurvey.backStory = DMSurveyNode.parse("Backstory", '|', new List <string>(1)
                {
                    "Something, Something, Something..."
                });

                DMContractDefs.DMSurvey.backStory = DMUtils.formatFixStringList(DMContractDefs.DMSurvey.backStory);

                ConfigNode SurveyExpireNode = DMSurveyNode.GetNode("Expire");
                ConfigNode SurveyFundsNode  = DMSurveyNode.GetNode("Funds");
                ConfigNode SurveySciNode    = DMSurveyNode.GetNode("Science");
                ConfigNode SurveyRepNode    = DMSurveyNode.GetNode("Reputation");

                if (SurveyExpireNode != null)
                {
                    DMContractDefs.DMSurvey.Expire.MinimumExpireDays = SurveyExpireNode.parse("MinimumExpireDays", (int)4);
                    DMContractDefs.DMSurvey.Expire.MaximumExpireDays = SurveyExpireNode.parse("MaximumExpireDays", (int)10);
                    DMContractDefs.DMSurvey.Expire.DeadlineYears     = SurveyExpireNode.parse("DeadlineYears", (float)1.7);
                }

                if (SurveyFundsNode != null)
                {
                    DMContractDefs.DMSurvey.Funds.BaseAdvance  = SurveyFundsNode.parse("BaseAdvance", (float)8500);
                    DMContractDefs.DMSurvey.Funds.BaseReward   = SurveyFundsNode.parse("BaseReward", (float)10500);
                    DMContractDefs.DMSurvey.Funds.BaseFailure  = SurveyFundsNode.parse("BaseFailure", (float)7500);
                    DMContractDefs.DMSurvey.Funds.ParamReward  = SurveyFundsNode.parse("ParamReward", (float)3000);
                    DMContractDefs.DMSurvey.Funds.ParamFailure = SurveyFundsNode.parse("ParamFailure", (float)0);
                }

                if (SurveySciNode != null)
                {
                    DMContractDefs.DMSurvey.Science.BaseReward  = SurveySciNode.parse("BaseReward", (float)0);
                    DMContractDefs.DMSurvey.Science.ParamReward = SurveySciNode.parse("ParamReward", (float)0.25);
                }

                if (SurveyRepNode != null)
                {
                    DMContractDefs.DMSurvey.Reputation.BaseReward   = SurveyRepNode.parse("BaseReward", (float)12);
                    DMContractDefs.DMSurvey.Reputation.BaseFailure  = SurveyRepNode.parse("BaseFailure", (float)10);
                    DMContractDefs.DMSurvey.Reputation.ParamReward  = SurveyRepNode.parse("ParamReward", (float)0);
                    DMContractDefs.DMSurvey.Reputation.ParamFailure = SurveyRepNode.parse("ParamFailure", (float)0);
                }
            }
        }
Ejemplo n.º 21
0
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int bodyID, sitID;

            string[] anomalyString = node.GetValue("Target_Anomaly").Split('|');
            hash = anomalyString[0];
            if (int.TryParse(anomalyString[1], out bodyID))
            {
                body = FlightGlobals.Bodies[bodyID];
            }
            else
            {
                DMUtils.Logging("Failed To Load Anomaly Contract Target Body Value; Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            name = anomalyString[2];
            DMUtils.availableScience["All"].TryGetValue(name, out scienceContainer);
            if (scienceContainer == null)
            {
                DMUtils.Logging("Failed To Load Anomaly Contract Science Container Variables; Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            else
            {
                partName = scienceContainer.sciPart;
            }
            if (int.TryParse(anomalyString[3], out sitID))
            {
                situation = (ExperimentSituations)sitID;
            }
            else
            {
                DMUtils.Logging("Failed To Load Anomaly Contract Situation Value; Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            if (!bool.TryParse(anomalyString[4], out collected))
            {
                DMUtils.Logging("Failed To Load Anomaly Contract Collected State; Reset Parameter");
                collected = false;
            }
            if (HighLogic.LoadedSceneIsFlight)
            {
                try
                {
                    city = new DMAnomalyObject((UnityEngine.Object.FindObjectsOfType(typeof(PQSCity)) as PQSCity[]).FirstOrDefault(c => c.name == hash && c.transform.parent.name == body.name));
                }
                catch
                {
                    DMUtils.Logging("Failed To Load Anomaly Contract Object; Parameter Removed");
                    this.Unregister();
                    this.Root.RemoveParameter(this);
                    return;
                }
            }
            subject = string.Format("{0}@{1}{2}", scienceContainer.exp.id, body.name, situation);
        }
Ejemplo n.º 22
0
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int targetBodyID;

            string[] anomalyString = node.GetValue("Target_Anomaly").Split('|');
            hash = anomalyString[0];
            if (int.TryParse(anomalyString[1], out targetBodyID))
            {
                body = FlightGlobals.Bodies[targetBodyID];
            }
            else
            {
                DMUtils.Logging("Failed To Load Anomaly Contract Target Body");
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
            if (HighLogic.LoadedSceneIsFlight)
            {
                try
                {
                    targetAnomaly = new DMAnomalyObject((UnityEngine.Object.FindObjectsOfType(typeof(PQSCity)) as PQSCity[]).FirstOrDefault(c => c.name == hash && c.transform.parent.name == body.name));
                    lat           = targetAnomaly.lat;
                    lon           = targetAnomaly.lon;
                }
                catch
                {
                    DMUtils.Logging("Failed To Load Anomaly Contract Object");
                    this.Unregister();
                    ContractSystem.Instance.Contracts.Remove(this);
                    return;
                }
            }
            else
            {
                if (!double.TryParse(anomalyString[2], out lat))
                {
                    DMUtils.Logging("Failed To Load Anomaly Lat Values");
                    lat = 0.000d;
                }
                if (!double.TryParse(anomalyString[3], out lon))
                {
                    DMUtils.Logging("Failed To Load Anomaly Long Values");
                    lon = 0.000d;
                }
            }
            fudgedLat = fudgeLat(lat);
            fudgedLon = fudgeLon(lon);
            cardNS    = NSDirection(lat);
            cardEW    = EWDirection(lon);
            if (this.ParameterCount == 0)
            {
                DMUtils.Logging("No Parameters Loaded For This Anomaly Contract; Removing Now...");
                this.Unregister();
                ContractSystem.Instance.Contracts.Remove(this);
                return;
            }
        }
Ejemplo n.º 23
0
        protected override void OnLoad(ConfigNode node)
        {
            //if (DMScienceScenario.SciScenario != null)
            //	if (DMScienceScenario.SciScenario.contractsReload)
            //		DMUtils.resetContracts();
            int target;

            string[] orbitString = node.GetValue("Orbital_Parameter").Split('|');
            if (!int.TryParse(orbitString[0], out type))
            {
                DMUtils.Logging("Failed To Load Type Variables; Mag Orbital Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            if (int.TryParse(orbitString[1], out target))
            {
                body = FlightGlobals.Bodies[target];
            }
            else
            {
                DMUtils.Logging("Failed To Load Target Body Variables; Mag Orbital Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            vName = orbitString[2];
            if (!double.TryParse(orbitString[3], out orbitalParameter))
            {
                DMUtils.Logging("Failed To Load Orbital Variables; Mag Orbital Parameter Removed");
                this.Unregister();
                this.Root.RemoveParameter(this);
                return;
            }
            if (!HighLogic.LoadedSceneIsEditor)
            {
                if (!string.IsNullOrEmpty(vName))
                {
                    List <Guid> ids = stringSplitGuid(vName);
                    if (ids.Count > 0)
                    {
                        foreach (Guid id in ids)
                        {
                            try
                            {
                                Vessel V = FlightGlobals.Vessels.FirstOrDefault(v => v.id == id);
                                suitableV.Add(V);
                                DMUtils.DebugLog("Vessel {0} Loaded", V.vesselName);
                            }
                            catch
                            {
                                DMUtils.Logging("Failed To Load Vessel; Mag Orbital Parameter Reset");
                                if (HighLogic.LoadedSceneIsFlight)
                                {
                                    DMUtils.Logging("Checking If Currently Loaded Vessel Is Appropriate");
                                    vesselOrbit(FlightGlobals.ActiveVessel, FlightGlobals.currentMainBody);
                                }
                            }
                        }
                    }
                }
            }
            this.disableOnStateChange = false;
        }
Ejemplo n.º 24
0
        private void configLoad()
        {
            //Load in global multipliers
            foreach (ConfigNode setNode in GameDatabase.Instance.GetConfigNodes("DM_CONTRACT_SETTINGS"))
            {
                if (setNode.GetValue("name") == "Contract Settings")
                {
                    DMUtils.science     = float.Parse(setNode.GetValue("Global_Science_Return"));
                    DMUtils.reward      = float.Parse(setNode.GetValue("Global_Fund_Reward"));
                    DMUtils.forward     = float.Parse(setNode.GetValue("Global_Fund_Forward"));
                    DMUtils.penalty     = float.Parse(setNode.GetValue("Global_Fund_Penalty"));
                    DMUtils.deadline    = float.Parse(setNode.GetValue("Global_Deadline"));
                    DMUtils.maxSurvey   = int.Parse(setNode.GetValue("Max_Survey"));
                    DMUtils.maxAsteroid = int.Parse(setNode.GetValue("Max_Asteroid"));
                    DMUtils.maxAnomaly  = int.Parse(setNode.GetValue("Max_Anomaly"));
                    DMUtils.maxMagnetic = int.Parse(setNode.GetValue("Max_Magnetic"));

                    DMUtils.Logging("Contract Variables Set; Science Reward: {0} ; Completion Reward: {1} ; Forward Amount: {2} ; Penalty Amount: {3} ; Deadline Length: {4}",
                                    DMUtils.science, DMUtils.reward, DMUtils.forward, DMUtils.penalty, DMUtils.deadline);
                    DMUtils.Logging("Max Contract Variables Set: Survey: {0} ; Asteroid: {1} ; Anomaly: {2} ; Magnetic: {3}",
                                    DMUtils.maxSurvey, DMUtils.maxAsteroid, DMUtils.maxAnomaly, DMUtils.maxMagnetic);
                    break;
                }
            }
            //Load in experiment definitions
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("DM_CONTRACT_EXPERIMENT"))
            {
                string             name, part, agent = "";
                int                sitMask, bioMask, type = 0;
                float              transmit  = 0;
                DMScienceContainer DMscience = null;
                ScienceExperiment  exp       = null;

                //Some apparently not impossible errors can cause deplicate experiments to be added to the R&D science experiment dictionary
                try
                {
                    exp = ResearchAndDevelopment.GetExperiment(node.GetValue("experimentID"));
                }
                catch (Exception e)
                {
                    Debug.LogError("[DM] Whoops. Something really wrong happened here; stopping this contract experiment from loading..." + e);
                    continue;
                }
                if (exp != null)
                {
                    name = node.GetValue("name");
                    if (!int.TryParse(node.GetValue("sitMask"), out sitMask))
                    {
                        continue;
                    }
                    if (!int.TryParse(node.GetValue("bioMask"), out bioMask))
                    {
                        continue;
                    }
                    if (!int.TryParse(node.GetValue("type"), out type))
                    {
                        continue;
                    }
                    if (!float.TryParse(node.GetValue("xmitDataScalar"), out transmit))
                    {
                        continue;
                    }
                    if (node.HasValue("part"))
                    {
                        part = node.GetValue("part");
                    }
                    else
                    {
                        part = "None";
                    }
                    if (node.HasValue("agent"))
                    {
                        agent = node.GetValue("agent");
                    }
                    else
                    {
                        agent = "Any";
                    }
                    if (DMUtils.whiteListed)
                    {
                        exp.situationMask = (uint)sitMask;
                    }
                    exp.biomeMask = (uint)bioMask;
                    DMscience     = new DMScienceContainer(exp, sitMask, bioMask, (DMScienceType)type, part, agent, transmit);
                    if (((DMScienceType)type & DMScienceType.Surface) == DMScienceType.Surface && !DMUtils.availableScience[DMScienceType.Surface.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Surface.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Aerial) == DMScienceType.Aerial && !DMUtils.availableScience[DMScienceType.Aerial.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Aerial.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Space) == DMScienceType.Space && !DMUtils.availableScience[DMScienceType.Space.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Space.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Biological) == DMScienceType.Biological && !DMUtils.availableScience[DMScienceType.Biological.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Biological.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Asteroid) == DMScienceType.Asteroid && !DMUtils.availableScience[DMScienceType.Asteroid.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Asteroid.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Anomaly) == DMScienceType.Anomaly && !DMUtils.availableScience[DMScienceType.Anomaly.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Anomaly.ToString()].Add(name, DMscience);
                    }
                    if (!DMUtils.availableScience["All"].ContainsKey(name))
                    {
                        DMUtils.availableScience["All"].Add(name, DMscience);
                    }
                    DMUtils.DebugLog("New Experiment: [{0}] Available For Contracts", name);
                }
            }
            DMUtils.Logging("Successfully Added {0} New Experiments To Contract List", DMUtils.availableScience["All"].Count);
            DMUtils.DebugLog("Successfully Added {0} New Surface Experiments To Contract List", DMUtils.availableScience[DMScienceType.Surface.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Aerial Experiments To Contract List", DMUtils.availableScience[DMScienceType.Aerial.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Orbital Experiments To Contract List", DMUtils.availableScience[DMScienceType.Space.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Biological Experiments To Contract List", DMUtils.availableScience[DMScienceType.Biological.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Asteroid Experiments To Contract List", DMUtils.availableScience[DMScienceType.Asteroid.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Anomaly Experiments To Contract List", DMUtils.availableScience[DMScienceType.Anomaly.ToString()].Count);
            //Load in custom contract descriptions
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("DM_SCIENCE_STORY_DEF"))
            {
                foreach (ConfigNode storyNode in node.GetNodes("DM_SCIENCE_BACKSTORY"))
                {
                    foreach (string st in storyNode.GetValues("generic"))
                    {
                        if (!string.IsNullOrEmpty(st))
                        {
                            string story = st.Replace("[", "{");
                            story = story.Replace("]", "}");
                            DMUtils.backStory["generic"].Add(story);
                        }
                    }
                    foreach (string so in storyNode.GetValues("survey"))
                    {
                        if (!string.IsNullOrEmpty(so))
                        {
                            string story_o = so.Replace("[", "{");
                            story_o = story_o.Replace("]", "}");
                            DMUtils.backStory["survey"].Add(story_o);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("biological"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["biological"].Add(story_b);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("asteroid"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["asteroid"].Add(story_b);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("anomaly"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["anomaly"].Add(story_b);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("magnetic"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["magnetic"].Add(story_b);
                        }
                    }
                }
            }
            DMUtils.Logging("Added {0} New Generic Backstories; {1} New Survey Backstories; {2} New Biological Backstories; {3} New Asteroid Backstories; {4} New Anomaly Backstories; {5} New Magnetic Backstories To The List", DMUtils.backStory["generic"].Count, DMUtils.backStory["survey"].Count, DMUtils.backStory["biological"].Count, DMUtils.backStory["asteroid"].Count, DMUtils.backStory["anomaly"].Count, DMUtils.backStory["magnetic"].Count);
        }
Ejemplo n.º 25
0
        private void configLoad()
        {
            //Load in global multipliers
            foreach (ConfigNode setNode in GameDatabase.Instance.GetConfigNodes("DM_CONTRACT_SETTINGS"))
            {
                if (setNode != null)
                {
                    if (!float.TryParse(setNode.GetValue("Global_Science_Return"), out DMUtils.science))
                    {
                        DMUtils.science = 1;
                    }
                    if (!float.TryParse(setNode.GetValue("Global_Fund_Reward"), out DMUtils.reward))
                    {
                        DMUtils.reward = 1;
                    }
                    if (!float.TryParse(setNode.GetValue("Global_Fund_Forward"), out DMUtils.forward))
                    {
                        DMUtils.forward = 1;
                    }
                    if (!float.TryParse(setNode.GetValue("Global_Fund_Penalty"), out DMUtils.penalty))
                    {
                        DMUtils.penalty = 1;
                    }
                    if (!float.TryParse(setNode.GetValue("Global_Deadline"), out DMUtils.deadline))
                    {
                        DMUtils.deadline = 1;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Survey_Offered"), out DMUtils.maxSurveyOffered))
                    {
                        DMUtils.maxSurveyOffered = 2;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Survey_Active"), out DMUtils.maxSurveyActive))
                    {
                        DMUtils.maxSurveyActive = 4;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Asteroid_Offered"), out DMUtils.maxAsteroidOffered))
                    {
                        DMUtils.maxAsteroidOffered = 1;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Asteroid_Active"), out DMUtils.maxAsteroidActive))
                    {
                        DMUtils.maxAsteroidActive = 3;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Anomaly_Offered"), out DMUtils.maxAnomalyOffered))
                    {
                        DMUtils.maxAnomalyOffered = 1;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Anomaly_Active"), out DMUtils.maxAnomalyActive))
                    {
                        DMUtils.maxAnomalyActive = 3;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Magnetic_Offered"), out DMUtils.maxMagneticOffered))
                    {
                        DMUtils.maxMagneticOffered = 2;
                    }
                    if (!int.TryParse(setNode.GetValue("Max_Magnetic_Active"), out DMUtils.maxMagneticActive))
                    {
                        DMUtils.maxMagneticActive = 4;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Near_Pod_Min_Distance"), out DMSeismicHandler.nearPodMinDistance))
                    {
                        DMSeismicHandler.nearPodMinDistance = 10;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Near_Pod_Max_Distance"), out DMSeismicHandler.nearPodMaxDistance))
                    {
                        DMSeismicHandler.nearPodMaxDistance = 2500;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Near_Pod_Threshold"), out DMSeismicHandler.nearPodThreshold))
                    {
                        DMSeismicHandler.nearPodThreshold = 500;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Far_Pod_Min_Distance"), out DMSeismicHandler.farPodMinDistance))
                    {
                        DMSeismicHandler.farPodMinDistance = 2500;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Far_Pod_Max_Distance"), out DMSeismicHandler.farPodMaxDistance))
                    {
                        DMSeismicHandler.farPodMaxDistance = 15000;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Far_Pod_Threshold"), out DMSeismicHandler.farPodThreshold))
                    {
                        DMSeismicHandler.farPodThreshold = 4000;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Pod_Min_Angle"), out DMSeismicHandler.podMinAngle))
                    {
                        DMSeismicHandler.podMinAngle = 20;
                    }
                    if (!float.TryParse(setNode.GetValue("Seismic_Pod_Angle_Threshold"), out DMSeismicHandler.podAngleThreshold))
                    {
                        DMSeismicHandler.podAngleThreshold = 90;
                    }

                    DMUtils.Logging("Contract Variables Set; Science Reward: {0} ; Completion Reward: {1} ; Forward Amount: {2} ; Penalty Amount: {3} ; Deadline Length: {4}",
                                    DMUtils.science, DMUtils.reward, DMUtils.forward, DMUtils.penalty, DMUtils.deadline);
                    DMUtils.Logging("Max Contract Variables Set: Survey Offers: {0}; Active: {1} -- Asteroid Offers: {2}; Active: {3} -- Anomaly Offers: {4}; Active: {5} -- Magnetic Offers: {6}; Active: {7}",
                                    DMUtils.maxSurveyOffered, DMUtils.maxSurveyActive, DMUtils.maxAsteroidOffered, DMUtils.maxAsteroidActive, DMUtils.maxAnomalyOffered, DMUtils.maxAnomalyActive, DMUtils.maxMagneticOffered, DMUtils.maxMagneticActive);

                    break;
                }
                else
                {
                    DMUtils.Logging("Broken Config.....");
                }
            }

            //Load in experiment definitions
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("DM_CONTRACT_EXPERIMENT"))
            {
                if (node != null)
                {
                    string             name      = "";
                    string             part      = "";
                    string             agent     = "";
                    int                sitMask   = 0;
                    int                bioMask   = 0;
                    int                type      = 0;
                    float              transmit  = 0;
                    DMScienceContainer DMscience = null;
                    ScienceExperiment  exp       = null;

                    //Some apparently not impossible errors can cause duplicate experiments to be added to the R&D science experiment dictionary
                    try
                    {
                        exp = ResearchAndDevelopment.GetExperiment(node.GetValue("experimentID"));
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("[DM] Whoops. Something really wrong happened here; stopping this contract experiment from loading..." + e);
                        continue;
                    }
                    if (exp != null)
                    {
                        if (!node.HasValue("name"))
                        {
                            continue;
                        }
                        name = node.GetValue("name");
                        if (!int.TryParse(node.GetValue("sitMask"), out sitMask))
                        {
                            continue;
                        }
                        if (!int.TryParse(node.GetValue("bioMask"), out bioMask))
                        {
                            continue;
                        }
                        if (!int.TryParse(node.GetValue("type"), out type))
                        {
                            continue;
                        }
                        if (!float.TryParse(node.GetValue("xmitDataScalar"), out transmit))
                        {
                            continue;
                        }
                        if (node.HasValue("part"))
                        {
                            part = node.GetValue("part");
                        }
                        else
                        {
                            part = "None";
                        }
                        if (node.HasValue("agent"))
                        {
                            agent = node.GetValue("agent");
                        }
                        else
                        {
                            agent = "Any";
                        }
                        if (DMUtils.whiteListed)
                        {
                            exp.situationMask = (uint)sitMask;
                            exp.biomeMask     = (uint)bioMask;
                        }

                        DMscience = new DMScienceContainer(exp, sitMask, bioMask, (DMScienceType)type, part, agent, transmit);

                        foreach (var sciType in Enum.GetValues(typeof(DMScienceType)))
                        {
                            string typeString = ((DMScienceType)sciType).ToString();
                            if (!string.IsNullOrEmpty(typeString))
                            {
                                if (DMUtils.availableScience.ContainsKey(typeString))
                                {
                                    if ((DMScienceType)sciType == DMScienceType.All)
                                    {
                                        if (!DMUtils.availableScience[typeString].ContainsKey(name))
                                        {
                                            DMUtils.availableScience[typeString].Add(name, DMscience);
                                        }
                                    }
                                    else if (((DMScienceType)type & (DMScienceType)sciType) == (DMScienceType)sciType)
                                    {
                                        if (!DMUtils.availableScience[typeString].ContainsKey(name))
                                        {
                                            DMUtils.availableScience[typeString].Add(name, DMscience);
                                        }
                                    }
                                }
                            }
                        }

                        //DMUtils.DebugLog("New Experiment: [{0}] Available For Contracts", name);
                    }
                }
            }

            DMUtils.Logging("Successfully Added {0} New Experiments To Contract List", DMUtils.availableScience["All"].Count);

            //foreach (var sciType in Enum.GetValues(typeof(DMScienceType)))
            //{
            //	string type = ((DMScienceType)sciType).ToString();
            //	if (!string.IsNullOrEmpty(type))
            //	{
            //		if (DMUtils.availableScience.ContainsKey(type))
            //		{
            //			if (type != "All")
            //				DMUtils.DebugLog("Successfully Added {0} New {1} Experiments To Contract List", DMUtils.availableScience[type].Count, type);
            //		}
            //	}
            //}

            //Load in custom contract descriptions
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("DM_SCIENCE_STORY_DEF"))
            {
                if (node != null)
                {
                    foreach (ConfigNode storyNode in node.GetNodes("DM_SCIENCE_BACKSTORY"))
                    {
                        if (storyNode != null)
                        {
                            if (storyNode.HasValue("survey"))
                            {
                                foreach (string so in storyNode.GetValues("survey"))
                                {
                                    if (!string.IsNullOrEmpty(so))
                                    {
                                        string story_o = so.Replace("[", "{");
                                        story_o = story_o.Replace("]", "}");
                                        DMUtils.backStory["survey"].Add(story_o);
                                    }
                                }
                            }
                            if (storyNode.HasValue("asteroid"))
                            {
                                foreach (string sb in storyNode.GetValues("asteroid"))
                                {
                                    if (!string.IsNullOrEmpty(sb))
                                    {
                                        string story_b = sb.Replace("[", "{");
                                        story_b = story_b.Replace("]", "}");
                                        DMUtils.backStory["asteroid"].Add(story_b);
                                    }
                                }
                            }
                            if (storyNode.HasValue("anomaly"))
                            {
                                foreach (string sb in storyNode.GetValues("anomaly"))
                                {
                                    if (!string.IsNullOrEmpty(sb))
                                    {
                                        string story_b = sb.Replace("[", "{");
                                        story_b = story_b.Replace("]", "}");
                                        DMUtils.backStory["anomaly"].Add(story_b);
                                    }
                                }
                            }
                            if (storyNode.HasValue("magnetic"))
                            {
                                foreach (string sb in storyNode.GetValues("magnetic"))
                                {
                                    if (!string.IsNullOrEmpty(sb))
                                    {
                                        string story_b = sb.Replace("[", "{");
                                        story_b = story_b.Replace("]", "}");
                                        DMUtils.backStory["magnetic"].Add(story_b);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            DMUtils.Logging("Added {0} New Survey Backstories; {1} New Asteroid Backstories; {2} New Anomaly Backstories; {3} New Magnetic Backstories To The List", DMUtils.backStory["survey"].Count, DMUtils.backStory["asteroid"].Count, DMUtils.backStory["anomaly"].Count, DMUtils.backStory["magnetic"].Count);
        }