コード例 #1
0
 public override void OnAwake()
 {
     print("[AQ:HV] OnAwake");
     Air = new AQAir();
     InstanceAQSettings = new AQsettings();
     base.OnAwake();
 }
コード例 #2
0
        public void UpdateAll(Vessel vessel, AQAir Air, double LivingVolume, double ScaleFactor)
        {
            KeyValuePair <string, double> limitingreagent;

            foreach (AQReaction reaction in Reactions)
            {
                print("[AQ:GRE] Evaluating Reaction " + reaction.Name);
                limitingreagent = reaction.CalculateLimit(ScaleFactor, LivingVolume, Air, vessel, part.protoModuleCrew.Count);
                if (limitingreagent.Value - AQConventions.one < float.Epsilon)
                {
                    print("[AQ:GRE] reaction " + reaction.Name + " is not limited");
                }
                else
                {
                    print("[AQ:GRE] reaction " + reaction.Name + " is limited by reagent " + limitingreagent.Key + " to scale of " + limitingreagent.Value);
                }
                print("[AQ:GRE] reaction " + reaction.Name + " updating resources");
                reaction.UpdateResources(part, ScaleFactor, part.protoModuleCrew.Count);
                print("[AQ:GRE] finished updating resources, limiting factor " + limitingreagent.Value);
                print("[AQ:GRE] reaction " + reaction.Name + " updating AQGases");
                reaction.UpdateAir(Air, LivingVolume, ScaleFactor, part.protoModuleCrew.Count);
                print("[AQ:GRE] Finished simulating " + reaction.Name);
            }
            return;
        }
コード例 #3
0
ファイル: AQReaction.cs プロジェクト: LambdaSix/AirQuality
 public void UpdateAir(AQAir Air, double LivingVolume, double ScaleFactor, double CrewFactor)         //todo get rid of crewfactor as arguement, and air too, use part instead
 {
     if (Type != AQConventions.ReactionTypes.Breathe)
     {
         CrewFactor = AQConventions.one;
     }
     if (Type == AQConventions.ReactionTypes.Leak) //todo split leak into a separate partmodule maybe
     {                                             //Single AQGas reagent is expected, all gases are equally affected, production is interpreted as retention.
         foreach (AQGasReagent gasreagent in GasReagents)
         {
             foreach (string aqgasname in Air.Keys)
             {
                 Air[aqgasname].Pressure *= Math.Pow(gasreagent.Production, ScaleFactor);
             }
         }
     }
     else if (Type == AQConventions.ReactionTypes.Scrub || Type == AQConventions.ReactionTypes.Backfill || Type == AQConventions.ReactionTypes.Breathe)                           //absolute production values in moles
     {
         foreach (AQGasReagent gasreagent in GasReagents)
         {
             if (!Air.ContainsKey(gasreagent.Name))
             {
                 Air.RegisterGas(gasreagent.Name);
             }
             Air[gasreagent.Name].Pressure += CrewFactor * ScaleFactor * LimitingFactor * gasreagent.Production *
                                              AQPhysicalConstants.GasConstant * AQPhysicalConstants.StandardAmbientConditions.Temperature / LivingVolume;
         }
     }
     return;
 }
コード例 #4
0
ファイル: AQReaction.cs プロジェクト: LambdaSix/AirQuality
        public KeyValuePair <string, double> CalculateLimit(double ScaleFactor, double Volume, AQAir Air, Vessel vessel, double CrewFactor)       //todo get rid of crewfactor as arguement
        {
            KeyValuePair <string, double> defaultkvp       = new KeyValuePair <string, double>(AQConventions.Values.EmptyString, AQConventions.one);
            Dictionary <string, double>   LimitingReagents = new Dictionary <string, double>();

            Status = AQConventions.Statuses.Nominal;
            if (Type == AQConventions.ReactionTypes.Leak)
            {
                LimitingFactor  = AQConventions.one;
                LimitingReagent = AQConventions.Values.EmptyString;
                return(defaultkvp);
            }
            if (Type != AQConventions.ReactionTypes.Breathe)
            {
                CrewFactor = AQConventions.one;
            }
            else if (Type == AQConventions.ReactionTypes.Scrub || Type == AQConventions.ReactionTypes.Backfill || Type == AQConventions.ReactionTypes.Breathe)
            {
                LimitingReagents.Add(defaultkvp.Key, defaultkvp.Value);
                foreach (AQGasReagent greagent in GasReagents)
                {
                    if (greagent.IsLimiting && greagent.IsConsumable() &&
                        (Air[greagent.Name].Quantity(Volume) < Math.Abs(greagent.Production) * ScaleFactor * CrewFactor))
                    {
                        LimitingReagents.Add(greagent.Name, Air[greagent.Name].Quantity(Volume) / CrewFactor * ScaleFactor * Math.Abs(greagent.Production));
                    }
                }
                foreach (AQResourceReagent rreagent in ResourceReagents)
                {
                    if (rreagent.IsLimiting && rreagent.IsConsumable() &&
                        (AQGetResourceAmount(vessel, rreagent.Name) < Math.Abs(rreagent.Production) * ScaleFactor * CrewFactor))
                    {
                        LimitingReagents.Add(rreagent.Name, AQGetResourceAmount(vessel, rreagent.Name) / CrewFactor * ScaleFactor * Math.Abs(rreagent.Production));
                    }
                }
            }
            if (LimitingReagents.Min().Value < float.Epsilon)
            {
                Status = AQConventions.Statuses.Lacking + LimitingReagents.Min().Key;
            }
            else if (LimitingReagents.Min().Value < AQConventions.one)
            {
                Status = AQConventions.Statuses.Limited + LimitingReagents.Min().Key;
            }
            LimitingFactor  = LimitingReagents.Min().Value;
            LimitingReagent = LimitingReagents.Min().Key;
            return(LimitingReagents.Min());
        }