void DetermineRange()
        {
            var crewList  = EL_Utils.GetCrewList(part);
            int bestLevel = -2;

            foreach (var crew in crewList)
            {
                int level = -1;
                if (EL_Utils.HasSkill <ExSurveySkill> (crew))
                {
                    level = crew.experienceLevel;
                }
                if (level > bestLevel)
                {
                    bestLevel = level;
                }
            }
            if (bestLevel > 5)
            {
                bestLevel = 5;
            }
            range = site_ranges[bestLevel + 2];
            if (canBuild)
            {
                StartCoroutine(WaitAndFindSites());
            }
        }
Ejemplo n.º 2
0
        public void UpdateProductivity()
        {
            double kh = 0;

            enableSkilled   = false;
            enableUnskilled = false;
            var crewList = EL_Utils.GetCrewList(part);

            foreach (var crew in crewList)
            {
                if (crew.GetEffect <ELConstructionSkill> () != null)
                {
                    if (crew.experienceLevel >= 4)
                    {
                        enableSkilled = true;
                    }
                    if (crew.experienceLevel >= 5)
                    {
                        enableUnskilled = true;
                    }
                }
            }
            foreach (var crew in crewList)
            {
                kh += KerbalContribution(crew);
            }
            Productivity = kh * ProductivityFactor + UnmannedProductivity;
            //Debug.LogFormat("[ELWorkshop] UpdateProductivity: {0}", Productivity);
        }
        public override string GetInfo()
        {
            ConversionRecipe recipe = LoadRecipe(Rate);
            StringBuilder    sb     = StringBuilderCache.Acquire();

            sb.Append(ConverterName);
            if (recipe.Inputs.Count > 0)
            {
                sb.Append("\n\n<color=#bada55>" + LocalStrings.Inputs + ":</color>");                //Inputs
                for (int i = 0, c = recipe.Inputs.Count; i < c; i++)
                {
                    EL_Utils.PrintResource(sb, recipe.Inputs[i], "t");
                }
            }
            if (recipe.Outputs.Count > 0)
            {
                sb.Append("\n<color=#bada55>" + LocalStrings.Outputs + ":</color>");                //Outputs
                for (int i = 0, c = recipe.Outputs.Count; i < c; i++)
                {
                    EL_Utils.PrintResource(sb, recipe.Outputs[i], "t");
                }
            }
            if (recipe.Requirements.Count > 0)
            {
                sb.Append("\n<color=#bada55>" + LocalStrings.Requirements + ":</color>");             //Requirements
                for (int i = 0, c = recipe.Requirements.Count; i < c; i++)
                {
                    EL_Utils.PrintResource(sb, recipe.Requirements[i], "t");
                }
            }
            return(sb.ToStringAndRelease());
        }
Ejemplo n.º 4
0
        void DetermineRange()
        {
            var crewList  = EL_Utils.GetCrewList(part);
            int bestLevel = -2;

            foreach (var crew in crewList)
            {
                int level = -1;
                if (crew.GetEffect <ELSurveySkill> () != null)
                {
                    level = crew.experienceLevel;
                }
                if (level > bestLevel)
                {
                    bestLevel = level;
                }
                Debug.LogFormat("[EL SurveyStation] Kerbal: {0} {1} {2} {3}",
                                crew.name,
                                crew.GetEffect <ELSurveySkill> () != null,
                                crew.experienceLevel, level);
            }
            if (bestLevel > 5)
            {
                bestLevel = 5;
            }
            range = site_ranges[bestLevel + 2];
            Debug.LogFormat("[EL SurveyStation] best level: {0}, range: {1}",
                            bestLevel, range);
            if (canBuild)
            {
                StartCoroutine(WaitAndFindSites());
            }
        }
Ejemplo n.º 5
0
        private void DetermineProductivity()
        {
            float kh = 0;

            enableSkilled   = false;
            enableUnskilled = false;
            var crewList = EL_Utils.GetCrewList(part);

            if (useSkill)
            {
                foreach (var crew in crewList)
                {
                    if (EL_Utils.HasSkill <ExConstructionSkill> (crew))
                    {
                        if (crew.experienceLevel >= 4)
                        {
                            enableSkilled = true;
                        }
                        if (crew.experienceLevel >= 5)
                        {
                            enableUnskilled = true;
                        }
                    }
                }
            }
            foreach (var crew in crewList)
            {
                kh += KerbalContribution(crew, crew.stupidity, crew.courage,
                                         crew.isBadass);
            }
            Productivity = kh * ProductivityFactor;
        }
Ejemplo n.º 6
0
        private void DetermineProductivity()
        {
            float kh = 0;

            enableSkilled   = false;
            enableUnskilled = false;
            var crewList = EL_Utils.GetCrewList(part);

            if (useSkill)
            {
                foreach (var crew in crewList)
                {
                    if (crew.GetEffect <ExConstructionSkill> () != null)
                    {
                        if (crew.experienceLevel >= 4)
                        {
                            enableSkilled = true;
                        }
                        if (crew.experienceLevel >= 5)
                        {
                            enableUnskilled = true;
                        }
                    }
                }
            }
            foreach (var crew in crewList)
            {
                kh += KerbalContribution(crew);
            }
            Productivity = kh * ProductivityFactor;
        }
Ejemplo n.º 7
0
        public override string GetInfo()
        {
            StringBuilder sb = StringBuilderCache.Acquire();

            sb.Append(ConverterName);
            if (Recipe.Inputs.Count > 0)
            {
                sb.Append("\n\n<color=#bada55>Inputs:</color>");
                for (int i = 0, c = Recipe.Inputs.Count; i < c; i++)
                {
                    EL_Utils.PrintResource(sb, Recipe.Inputs[i]);
                }
            }
            if (Recipe.Outputs.Count > 0)
            {
                sb.Append("\n<color=#bada55>Outputs:</color>");
                for (int i = 0, c = Recipe.Outputs.Count; i < c; i++)
                {
                    EL_Utils.PrintResource(sb, Recipe.Outputs[i]);
                }
            }
            if (Recipe.Requirements.Count > 0)
            {
                sb.Append("\n<color=#bada55>Requirements:</color>");
                for (int i = 0, c = Recipe.Requirements.Count; i < c; i++)
                {
                    EL_Utils.PrintResource(sb, Recipe.Requirements[i]);
                }
            }
            return(sb.ToStringAndRelease());
        }
 private void MassLabel(string title, double mass)
 {
     GUILayout.BeginHorizontal();
     GUILayout.Label(title + ":");
     GUILayout.FlexibleSpace();
     GUILayout.Label(EL_Utils.FormatMass(mass));
     GUILayout.EndHorizontal();
 }
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            furnaceTempField = Fields["furnaceTemp"];
            EL_Utils.SetupEVAEvent(Events["StartResourceConverter"], EVARange);
            EL_Utils.SetupEVAEvent(Events["StopResourceConverter"], EVARange);

            coreHeat = part.FindModuleImplementing <ModuleCoreHeat> ();
        }
Ejemplo n.º 10
0
		void PrintRecipe (StringBuilder sb, Recipe recipe, bool disc = false)
		{
			for (int i = 0, c = recipe.ingredients.Count; i < c; i++) {
				if (EL_Utils.PrintIngredient (sb, recipe.ingredients[i], "kg")
					&& disc && recipe.ingredients[i].discardable) {
					sb.Append("+");
				}
			}
		}
Ejemplo n.º 11
0
        double ResourceProgress(string label, BuildResource br,
                                BuildResource req, bool forward)
        {
            double fraction = 1;

            if (req.amount > 0)
            {
                fraction = (req.amount - br.amount) / req.amount;
            }
            double required  = br.amount;
            double available = control.padResources.ResourceAmount(br.name);
            double alarmTime;
            string percent = (fraction * 100).ToString("G4") + "%";

            if (control.paused)
            {
                percent   = percent + "[paused]";
                alarmTime = 0;                 // need assignment or compiler complains about use of unassigned variable
            }
            else
            {
                double eta = BuildETA(br, req, forward);
                alarmTime = Planetarium.GetUniversalTime() + eta;
                percent   = percent + " " + EL_Utils.TimeSpanString(eta);
            }

            GUILayout.BeginHorizontal();

            // Resource name
            GUILayout.Box(label, ELStyles.white, GUILayout.Width(125),
                          GUILayout.Height(40));

            GUILayout.BeginVertical();

            ELStyles.bar.Draw((float)fraction, percent, 300);
            GUILayout.EndVertical();

            // Calculate if we have enough resources to build
            GUIStyle requiredStyle = ELStyles.green;

            if (required > available)
            {
                requiredStyle = ELStyles.yellow;
            }
            // Required and Available
            GUILayout.Box(displayAmount(required),
                          requiredStyle, GUILayout.Width(100),
                          GUILayout.Height(40));
            GUILayout.Box(displayAmount(available),
                          ELStyles.white, GUILayout.Width(100),
                          GUILayout.Height(40));
            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();
            return(alarmTime);
        }
Ejemplo n.º 12
0
 public override void OnStart(PartModule.StartState state)
 {
     if (state == PartModule.StartState.None ||
         state == PartModule.StartState.Editor)
     {
         return;
     }
     if (EVARange > 0)
     {
         EL_Utils.SetupEVAEvent(Events["ShowRenameUI"], EVARange);
     }
     control.OnStart();
 }
        double ResourceProgress(string label, BuildResource br,
                                BuildResource req, bool forward)
        {
            double fraction = 1;

            if (req.amount > 0)
            {
                fraction = (req.amount - br.amount) / req.amount;
            }
            double required  = br.amount;
            double available = control.padResources.ResourceAmount(br.name);
            double eta       = 0;
            string percent   = (fraction * 100).ToString("G4") + "%";

            if (control.paused)
            {
                percent = percent + "[paused]";
            }
            else
            {
                eta     = BuildETA(br, req, forward);
                percent = percent + " " + EL_Utils.TimeSpanString(eta);
            }

            GUILayout.BeginHorizontal();

            // Resource name
            GUILayout.Box(label, ELStyles.white, width125, height40);

            GUILayout.BeginVertical();

            ELStyles.bar.Draw((float)fraction, percent, 300);
            GUILayout.EndVertical();

            // Calculate if we have enough resources to build
            GUIStyle requiredStyle = ELStyles.green;

            if (required > available)
            {
                requiredStyle = ELStyles.yellow;
            }
            // Required and Available
            GUILayout.Box(displayAmount(required),
                          requiredStyle, width100, height40);
            GUILayout.Box(displayAmount(available),
                          ELStyles.white, width100, height40);
            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();
            return(eta);
        }
 public override void OnStart(PartModule.StartState state)
 {
     if (state == PartModule.StartState.None ||
         state == PartModule.StartState.Editor)
     {
         return;
     }
     control.OnStart();
     if (EVARange > 0)
     {
         EL_Utils.SetupEVAEvent(Events["ShowRenameUI"], EVARange);
     }
     GameEvents.onVesselSituationChange.Add(onVesselSituationChange);
     GameEvents.onCrewTransferred.Add(onCrewTransferred);
     StartCoroutine(WaitAndDetermineRange());
     ELSurveyTracker.onSiteAdded.Add(onSiteAdded);
     ELSurveyTracker.onSiteRemoved.Add(onSiteRemoved);
     ELSurveyTracker.onSiteModified.Add(onSiteModified);
 }
Ejemplo n.º 15
0
 public override void OnStart(StartState state)
 {
     RecycleField = part.FindModelComponent <Collider> (RecycleField_name);
     Debug.Log(String.Format("[EL Recycler] OnStart: {0}", RecycleField));
     if (EVARange > 0)
     {
         EL_Utils.SetupEVAEvent(Events["Activate"], EVARange);
         EL_Utils.SetupEVAEvent(Events["Deactivate"], EVARange);
     }
     if (RecycleField != null)
     {
         RecycleField.enabled   = false;
         RecycleField.isTrigger = true;          //FIXME workaround for KSP 1.1 bug
     }
     if (state == PartModule.StartState.None ||
         state == PartModule.StartState.Editor)
     {
         return;
     }
     sm.Start(RecycleField);
 }
 public override void OnStart(PartModule.StartState state)
 {
     base.OnStart(state);
     if (!HighLogic.LoadedSceneIsFlight)
     {
         return;
     }
     if (resource_providers == null)
     {
         resource_providers = new List <IResourceProvider> ();
         resource_providers.Add(StockResourceProvider.Create());
         var kethane = KethaneResourceProvider.Create();
         if (kethane != null)
         {
             resource_providers.Add(kethane);
         }
     }
     resource_amounts = new double[resource_providers.Count];
     FindTransforms();
     Fields["ResourceStatus"].guiName = ResourceName + " rate";
     EL_Utils.SetupEVAEvent(Events["StartResourceConverter"], EVARange);
     EL_Utils.SetupEVAEvent(Events["StopResourceConverter"], EVARange);
 }
Ejemplo n.º 17
0
        private float KerbalContribution(ProtoCrewMember crew, float stupidity,
                                         float courage, bool isBadass)
        {
            string expstr     = KerbalExt.Get(crew, "experience:task=Workshop");
            float  experience = 0;

            if (expstr != null)
            {
                float.TryParse(expstr, out experience);
            }

            float contribution;

            if (isBadass)
            {
                contribution = Baddass(stupidity, courage, experience);
            }
            else
            {
                contribution = Normal(stupidity, courage, experience);
            }
            if (useSkill)
            {
                if (!EL_Utils.HasSkill <ExConstructionSkill> (crew))
                {
                    if (!enableUnskilled)
                    {
                        // can't work here, but may not know to keep out of the way.
                        contribution = Mathf.Min(contribution, 0);
                    }
                    if (crew.experienceLevel >= 3)
                    {
                        // can resist "ooh, what does this button do?"
                        contribution = Mathf.Max(contribution, 0);
                    }
                }
                else
                {
                    switch (crew.experienceLevel)
                    {
                    case 0:
                        if (!enableSkilled && !SupportInexperienced)
                        {
                            // can't work here, but knows to keep out of the way.
                            contribution = 0;
                        }
                        break;

                    case 1:
                        break;

                    case 2:
                        if (SupportInexperienced)
                        {
                            // He's learned the ropes.
                            contribution = HyperCurve(contribution);
                        }
                        break;

                    default:
                        // He's learned the ropes very well.
                        contribution = HyperCurve(contribution);
                        break;
                    }
                }
            }
            Debug.Log(String.Format("[EL Workshop] Kerbal: "
                                    + "{0} {1} {2} {3} {4}({5}) {6} {7} {8} {9} {10}",
                                    crew.name, stupidity, courage, isBadass,
                                    experience, expstr, contribution,
                                    EL_Utils.HasSkill <ExConstructionSkill> (crew),
                                    crew.experienceLevel,
                                    enableSkilled, SupportInexperienced));
            return(contribution);
        }
Ejemplo n.º 18
0
 private void ResourcePanel(string title,
                            List <BuildResource> resources,
                            ScrollView scroll)
 {
     GUILayout.Label(title + ":");
     GUILayout.BeginVertical(GUILayout.Height(100));
     scroll.Begin();
     foreach (var res in resources)
     {
         GUILayout.BeginHorizontal();
         GUILayout.Label(String.Format("{0}:", res.name));
         GUILayout.FlexibleSpace();
         GUILayout.Label(String.Format("{0} ({1})", res.amount.ToStringSI(4, unit: "u"), EL_Utils.FormatMass(res.mass, 4)));
         GUILayout.EndHorizontal();
     }
     scroll.End();
     GUILayout.EndVertical();
 }
Ejemplo n.º 19
0
		public override void OnStart(PartModule.StartState state)
		{
			base.OnStart (state);
			EL_Utils.SetupEVAEvent (Events["StartResourceConverter"], EVARange);
			EL_Utils.SetupEVAEvent (Events["StopResourceConverter"], EVARange);
		}