-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from UmbraSpaceIndustries/DEVELOP
Develop
- Loading branch information
Showing
18 changed files
with
669 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
"VERSION":{ | ||
"MAJOR":0, | ||
"MINOR":11, | ||
"PATCH":0, | ||
"PATCH":1, | ||
"BUILD":0 | ||
}, | ||
"KSP_VERSION":{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using System.Collections.Generic; | ||
|
||
namespace USITools | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using UnityEngine; | ||
|
||
namespace USITools | ||
{ | ||
public class ModuleSwapControllerNew : PartModule | ||
{ | ||
[KSPField] | ||
public string ResourceCosts = ""; | ||
|
||
[KSPField] | ||
public string typeName = "Loadout"; | ||
|
||
public List<ResourceRatio> ResCosts; | ||
public List<ModuleSwapOption> Loadouts; | ||
private List<ModuleResourceHarvester_USI> _harvesters; | ||
private List<ModuleResourceConverter_USI> _converters; | ||
|
||
private double lastCheck; | ||
private double checkInterval = 5d; | ||
|
||
public override void OnStart(StartState state) | ||
{ | ||
Loadouts = part.FindModulesImplementing<ModuleSwapOption>(); | ||
_converters = part.FindModulesImplementing<ModuleResourceConverter_USI>(); | ||
_harvesters = part.FindModulesImplementing<ModuleResourceHarvester_USI>(); | ||
SetupResourceCosts(); | ||
} | ||
|
||
private void SetupResourceCosts() | ||
{ | ||
ResCosts = new List<ResourceRatio>(); | ||
if (String.IsNullOrEmpty(ResourceCosts)) | ||
return; | ||
|
||
var resources = ResourceCosts.Split(','); | ||
for (int i = 0; i < resources.Length; i += 2) | ||
{ | ||
ResCosts.Add(new ResourceRatio | ||
{ | ||
ResourceName = resources[i], | ||
Ratio = double.Parse(resources[i + 1]) | ||
}); | ||
} | ||
} | ||
|
||
public override string GetInfo() | ||
{ | ||
if (String.IsNullOrEmpty(ResourceCosts)) | ||
return ""; | ||
|
||
var output = new StringBuilder("Resource Cost:\n\n"); | ||
var resources = ResourceCosts.Split(','); | ||
for (int i = 0; i < resources.Length; i += 2) | ||
{ | ||
output.Append(string.Format("{0} {1}\n", double.Parse(resources[i + 1]), resources[i])); | ||
} | ||
return output.ToString(); | ||
} | ||
|
||
public void ApplyLoadout(int loadIdx, int moduleIdx, bool isConverter) | ||
{ | ||
var loadout = Loadouts[loadIdx]; | ||
if (isConverter) | ||
{ | ||
ApplyConverterChanges(_converters[moduleIdx], loadout); | ||
} | ||
else | ||
{ | ||
ApplyHarvesterChanges(_harvesters[moduleIdx], loadout); | ||
} | ||
} | ||
|
||
private void ApplyConverterChanges(ModuleResourceConverter_USI converter, ModuleSwapOption loadout) | ||
{ | ||
converter.ConverterName = loadout.ConverterName; | ||
converter.StartActionName = loadout.StartActionName; | ||
converter.StopActionName = loadout.StopActionName; | ||
converter.UseSpecialistBonus = loadout.UseSpecialistBonus; | ||
if (converter.UseSpecialistBonus) | ||
converter.ExperienceEffect = loadout.ExperienceEffect; | ||
|
||
converter.inputList.Clear(); | ||
converter.outputList.Clear(); | ||
converter.reqList.Clear(); | ||
|
||
converter.Recipe.Inputs.Clear(); | ||
converter.Recipe.Outputs.Clear(); | ||
converter.Recipe.Requirements.Clear(); | ||
|
||
converter.inputList.AddRange(loadout.inputList); | ||
converter.outputList.AddRange(loadout.outputList); | ||
converter.reqList.AddRange(loadout.reqList); | ||
|
||
converter.Recipe.Inputs.AddRange(loadout.inputList); | ||
converter.Recipe.Outputs.AddRange(loadout.outputList); | ||
converter.Recipe.Requirements.AddRange(loadout.reqList); | ||
} | ||
|
||
private void ApplyHarvesterChanges(ModuleResourceHarvester_USI harvester, ModuleSwapOption loadout) | ||
{ | ||
harvester.Efficiency = loadout.Efficiency; | ||
harvester.ResourceName = loadout.ResourceName; | ||
harvester.ConverterName = loadout.ConverterName; | ||
harvester.StartActionName = loadout.StartActionName; | ||
harvester.StopActionName = loadout.StopActionName; | ||
MonoUtilities.RefreshContextWindows(part); | ||
} | ||
} | ||
} |
Oops, something went wrong.