Skip to content

Commit

Permalink
Eliminate GetDepositUnder method
Browse files Browse the repository at this point in the history
  • Loading branch information
Majiir committed Sep 2, 2014
1 parent 16b9532 commit 105f9c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 0 additions & 5 deletions Plugin/KethaneData.cs
Expand Up @@ -34,11 +34,6 @@ public static KethaneData Current
private Dictionary<string, ConfigNode> generatorNodes = new Dictionary<string, ConfigNode>();
private Dictionary<string, IResourceGenerator> generators = new Dictionary<string, IResourceGenerator>();

public ICellResource GetDepositUnder(string resourceName, Vessel vessel)
{
return GetCellDeposit(resourceName, vessel.mainBody, MapOverlay.GetCellUnder(vessel.mainBody, vessel.transform.position));
}

public ICellResource GetCellDeposit(string resourceName, CelestialBody body, Cell cell)
{
if (resourceName == null || body == null || !PlanetDeposits.ContainsKey(resourceName) || !PlanetDeposits[resourceName].ContainsKey(body.name)) { return null; }
Expand Down
9 changes: 7 additions & 2 deletions Plugin/PartModules/KethaneExtractor.cs
Expand Up @@ -182,7 +182,7 @@ public void Update()
{
if (animator.CurrentState == ExtractorState.Deployed)
{
emitter.Emit = hit && KethaneData.Current.GetDepositUnder("Kethane", this.vessel) != null;
emitter.Emit = hit && GetDepositUnder("Kethane") != null;
}
else
{
Expand All @@ -209,7 +209,7 @@ public override void OnFixedUpdate()

foreach (var resource in resources)
{
var deposit = KethaneData.Current.GetDepositUnder(resource.Name, this.vessel);
var deposit = GetDepositUnder(resource.Name);
if (deposit == null) { continue; }

double amount = TimeWarp.fixedDeltaTime * resource.Rate * energyRatio;
Expand All @@ -218,6 +218,11 @@ public override void OnFixedUpdate()
}
}

private ICellResource GetDepositUnder(string resourceName)
{
return KethaneData.Current.GetCellDeposit(resourceName, this.vessel.mainBody, MapOverlay.GetCellUnder(this.vessel.mainBody, this.vessel.transform.position));
}

private bool raycastGround()
{
RaycastHit hitInfo;
Expand Down

0 comments on commit 105f9c3

Please sign in to comment.