예제 #1
0
        public override void OnGameSettingsApplied()
        {
            //Update seconds per cycle
            secondsPerCycle = SnacksScenario.GetSecondsPerDay() / SnacksProperties.MealsPerDay;

            //Update input amounts
            inputList[0].amount = SnacksProperties.SnacksPerMeal;

            //Update output amounts
            outputList.Clear();
            if (SnacksProperties.RecyclersEnabled)
            {
                ProcessedResource resource = new ProcessedResource(SnacksProperties.SoilResourceName, SnacksProperties.SnacksResourceName, SnacksProperties.SnacksPerMeal, false, false, false);
                outputList.Add(resource);
            }

            //Outcomes
            outcomes.Clear();
            outcomes.Add(new FundingPenalty(true, "Kerbals are hungry for snacks! You have been fined {0:N2} Funds", SnacksProperties.FinePerKerbal));
            outcomes.Add(new RepPenalty(true, SnacksProperties.RepLostWhenHungry, "Kerbals are hungry for snacks! Your reputation has decreased by {0:N3}"));
            outcomes.Add(new SciencePenalty(true));
            if (SnacksProperties.CanStarveToDeath)
            {
                outcomes.Add(new DeathPenalty(SnacksProperties.SnacksResourceName, SnacksProperties.MealsSkippedBeforeDeath, "has died from a lack of Snacks!"));
            }
            if (SnacksProperties.FaintWhenHungry)
            {
                outcomes.Add(new FaintPenalty(SnacksProperties.SnacksResourceName, SnacksProperties.MealsBeforeFainting, SnacksProperties.NapTime * 60f, "has fainted from a lack of Snacks!"));
            }

            if (SnacksScenario.Instance.rosterResources.ContainsKey(StressProcessor.StressResourceName))
            {
                outcomes.Add(new ProduceResource(StressProcessor.StressResourceName, 1.0, false, string.Empty));
            }
        }
예제 #2
0
        public override void AddConsumedAndProducedResources(int crewCount, double secondsPerCycle, List <ResourceRatio> consumedResources, List <ResourceRatio> producedResources)
        {
            if (crewCount <= 0)
            {
                return;
            }

            ResourceRatio resourceRatio;

            //Calculate amount
            //Start with total snacks consumed per day, accounting for crew count.
            double amount = SnacksProperties.SnacksPerMeal * SnacksProperties.MealsPerDay * crewCount;

            //Now get snacks per second consumed.
            amount /= SnacksScenario.GetSecondsPerDay();

            //Finally, account for seconds per cycle
            amount *= secondsPerCycle;

            //Add snacks
            resourceRatio = new ResourceRatio();
            resourceRatio.ResourceName = SnacksProperties.SnacksResourceName;
            resourceRatio.Ratio        = amount;
            consumedResources.Add(resourceRatio);

            //Add soil
            if (SnacksProperties.RecyclersEnabled)
            {
                resourceRatio = new ResourceRatio();
                resourceRatio.ResourceName = SnacksProperties.SoilResourceName;
                resourceRatio.Ratio        = amount;
                producedResources.Add(resourceRatio);
            }
        }
예제 #3
0
        public virtual string GetStatusDisplay()
        {
            StringBuilder status                   = new StringBuilder();
            string        colorTag                 = string.Empty;
            string        endTag                   = string.Empty;
            double        percentRemaining         = amount / maxAmount;
            PartResourceDefinitionList definitions = PartResourceLibrary.Instance.resourceDefinitions;

            //Determine color tag
            if (estimatedTimeRemaining < 0 || percentRemaining > 0.5)
            {
                colorTag = string.Empty;
                endTag   = string.Empty;
            }
            else if (percentRemaining > 0.25)
            {
                colorTag = "<color=yellow>";
                endTag   = "</color>";
            }
            else
            {
                colorTag = "<color=red><b>";
                endTag   = "</b></color>";
            }

            //Resource and amount / maxAmount
            status.Append(colorTag + definitions[resourceName].displayName + ": ");
            status.AppendFormat("{0:f2}/{1:f2}", amount, maxAmount);
            status.AppendLine(endTag);

            //Duration
            if (simulatorInterrupted)
            {
                status.AppendLine("<color=white>Duration: Unavailable</color>");
            }
            else if (estimatedTimeRemaining < 0)
            {
                status.AppendLine("<color=white>Duration: Indefinite</color>");
            }
            else if (isSimulatorRunning)
            {
                status.AppendLine("<color=white>Duration: Calculating...</color>");
            }
            else
            {
                string timeString = SnacksScenario.FormatTime(estimatedTimeRemaining);
                if (amount < 0.0001)
                {
                    timeString = "0 Seconds";
                }
                status.AppendLine(colorTag + "Duration: " + timeString + endTag);
            }

            return(status.ToString());
        }
예제 #4
0
        protected override void OnSave(ConfigNode node)
        {
            base.OnSave(node);

            //Record solar flux for simulations and background processing.
            node.AddValue(ValueSolarFlux, SnacksScenario.GetSolarFlux(vessel));

            node.AddValue(ValueSciencePenalties, sciencePenalties);

            node.AddValue(ValueGeeForce, vessel.graviticAcceleration.magnitude);

            node.AddValue(ValueStaticPressure, vessel.staticPressurekPa);
        }
예제 #5
0
        public void drawSpaceCenterWindow()
        {
            GUILayout.Label("<color=white><b>Exempt Kerbals:</b> separate names by semicolon, first name only</color>");
            GUILayout.Label("<color=yellow>These kerbals won't consume Snacks and won't suffer penalties from a lack of Snacks.</color>");
            if (string.IsNullOrEmpty(exemptKerbals))
            {
                exemptKerbals = string.Empty;
            }
            exemptKerbals = GUILayout.TextField(exemptKerbals);

            if (SnacksProperties.DebugLoggingEnabled)
            {
                if (GUILayout.Button("Snack Time!"))
                {
                    SnacksScenario.Instance.RunSnackCyleImmediately(SnacksScenario.GetSecondsPerDay() / SnacksProperties.MealsPerDay);
                }
            }

            drawFlightWindow();
        }
예제 #6
0
        public override void Initialize()
        {
            base.Initialize();

            //Replace the existing roster resource with a customized Stress version. We calculate max roster amount in the processor.
            SnacksRosterResource resource       = SnacksScenario.Instance.rosterResources[StressResourceName];
            StressRosterResource stressResource = new StressRosterResource();

            stressResource.resourceName             = resource.resourceName;
            stressResource.displayName              = resource.displayName;
            stressResource.amount                   = 0;
            stressResource.maxAmount                = 0;
            stressResource.experienceBonusAmount    = 0;
            stressResource.experienceBonusMaxAmount = resource.experienceBonusMaxAmount;
            SnacksScenario.Instance.rosterResources[StressResourceName] = stressResource;
            stressResource.statusFormat = resource.statusFormat;

            secondsPerCycle = SnacksScenario.GetSecondsPerDay();

            outcomes.Add(new OnStrikePenalty(StressConditionName, false, StressPlayerMessage));

            SnacksScenario.onRosterResourceUpdated.Add(onRosterResourceUpdated);
        }
예제 #7
0
 public override void OnAwake()
 {
     base.OnAwake();
     Instance = this;
 }
예제 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Snacks.SnacksEvent"/> class.
        /// </summary>
        /// <param name="node">A ConfigNode specifying the initialization parameters.</param>
        public SnacksEvent(ConfigNode node) : base()
        {
            if (!node.HasValue(SnacksEventName))
            {
                return;
            }

            result = new SnacksProcessorResult();
            result.affectedKerbalCount = 1;
            result.crewCapacity        = 1;
            result.crewCount           = 1;
            result.appliedPerCrew      = true;
            result.afftectedAstronauts = new List <ProtoCrewMember>();

            name = node.GetValue(SnacksEventName);

            if (node.HasValue(SnacksEventCategory))
            {
                eventCategory = (SnacksEventCategories)Enum.Parse(typeof(SnacksEventCategories), node.GetValue(SnacksEventCategory));
            }

            if (node.HasValue(SnacksEventAffectedKerbals))
            {
                affectedKerbals = (KerbalsAffectedTypes)Enum.Parse(typeof(KerbalsAffectedTypes), node.GetValue(SnacksEventAffectedKerbals));
            }

            if (node.HasValue(SnacksEventPlayerMessage))
            {
                playerMessage = node.GetValue(SnacksEventPlayerMessage);
            }

            if (node.HasValue(SnacksEventDaysBetweenChecks))
            {
                double.TryParse(node.GetValue(SnacksEventDaysBetweenChecks), out daysBetweenChecks);
                secondsBetweenChecks = daysBetweenChecks * SnacksScenario.GetSecondsPerDay();
            }
            else if (node.HasValue(SnacksEventSecondsBetweenChecks))
            {
                double.TryParse(node.GetValue(SnacksEventSecondsBetweenChecks), out secondsBetweenChecks);
            }

            //Preconditions
            preconditions = new List <BasePrecondition>();
            if (node.HasNode(BasePrecondition.PRECONDITION))
            {
                ConfigNode[]     nodes = node.GetNodes(BasePrecondition.PRECONDITION);
                BasePrecondition precondition;

                for (int index = 0; index < nodes.Length; index++)
                {
                    precondition = SnacksScenario.Instance.CreatePrecondition(nodes[index]);
                    if (precondition != null)
                    {
                        preconditions.Add(precondition);
                    }
                }
            }

            //Outcomes
            outcomes = new List <BaseOutcome>();
            if (node.HasNode(BaseOutcome.OUTCOME))
            {
                ConfigNode[] nodes = node.GetNodes(BaseOutcome.OUTCOME);
                BaseOutcome  outcome;

                for (int index = 0; index < nodes.Length; index++)
                {
                    outcome = SnacksScenario.Instance.CreateOutcome(nodes[index]);
                    if (outcome != null)
                    {
                        outcomes.Add(outcome);
                    }
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Gets the daily snacks output.
        /// </summary>
        /// <returns>The amount of Snacks produced daily, subjected to game settings.</returns>
        public virtual double GetDailySnacksOutput()
        {
            updateProductionEfficiency();

            return(originalSnacksRatio * productionEfficiency * SnacksScenario.GetSecondsPerDay());
        }