Skip to content

Commit

Permalink
Use TryGetValue
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Nov 1, 2023
1 parent faf0377 commit a060fd7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions MechJeb2/VesselState.cs
Expand Up @@ -1783,9 +1783,9 @@ public void CheckUllageStatus(ModuleEngines e)
private void addResource(int id, double current /* u/sec */, double max /* u/sec */)
{
FuelRequirement req;
if (resourceRequired.ContainsKey(id))
if (resourceRequired.TryGetValue(id, out FuelRequirement value))
{
req = resourceRequired[id];
req = value;
}
else
{
Expand Down Expand Up @@ -1819,9 +1819,9 @@ public void addIntake(ModuleResourceIntake intake)
// drag, etc etc.
List<ModuleResourceIntake> thelist;
int id = PartResourceLibrary.Instance.GetDefinition(intake.resourceName).id;
if (allIntakes.ContainsKey(id))
if (allIntakes.TryGetValue(id, out List<ModuleResourceIntake> allIntake))
{
thelist = allIntakes[id];
thelist = allIntake;
}
else
{
Expand All @@ -1836,9 +1836,9 @@ public void addIntake(ModuleResourceIntake intake)

public List<ModuleResourceIntake> getIntakes(int id)
{
if (allIntakes.ContainsKey(id))
if (allIntakes.TryGetValue(id, out List<ModuleResourceIntake> intakes))
{
return allIntakes[id];
return intakes;
}

return empty;
Expand Down

0 comments on commit a060fd7

Please sign in to comment.