Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
                    }
                }
            }
        }
Ejemplo n.º 6
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());
        }