Skip to content

Commit

Permalink
Merge pull request #1549 from tjdeckard/main
Browse files Browse the repository at this point in the history
WOLF recipes and crew xfer nullref fix
  • Loading branch information
tjdeckard authored Oct 4, 2021
2 parents 56803d9 + 29b61b8 commit f3fa1ab
Showing 2 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -5,39 +5,39 @@
name = WOLF_RecipeOption
RecipeDisplayName = #autoLOC_USI_WOLF_FABRICATOR_RECIPE_ALLOYS

InputResources = Maintenance,1,Metals,1,RareMetals,4,Power,1,TechnicianCrewPoint,1
InputResources = Lab,1,Maintenance,1,Metals,1,RareMetals,4,Power,1,ScientistCrewPoint,1
OutputResources = Alloys,1
}
MODULE
{
name = WOLF_RecipeOption
RecipeDisplayName = #autoLOC_USI_WOLF_FABRICATOR_RECIPE_ELECTRONICS

InputResources = Maintenance,1,MaterialKits,5,Power,1,Synthetics,5,TechnicianCrewPoint,1
InputResources = Lab,2,Maintenance,2,MaterialKits,5,Power,2,Synthetics,5,EngineerCrewPoint,1
OutputResources = Electronics,1
}
MODULE
{
name = WOLF_RecipeOption
RecipeDisplayName = #autoLOC_USI_WOLF_FABRICATOR_RECIPE_PROTOTYPES

InputResources = Electronics,5,Maintenance,1,Power,1,Robotics,5,SpecializedParts,5,TechnicianCrewPoint,1
InputResources = Electronics,5,Lab,3,Maintenance,3,Power,3,Robotics,5,SpecializedParts,5,EngineerCrewPoint,1,ScientistCrewPoint,1
OutputResources = Prototypes,1
}
MODULE
{
name = WOLF_RecipeOption
RecipeDisplayName = #autoLOC_USI_WOLF_FABRICATOR_RECIPE_ROBOTICS

InputResources = Alloys,5,Maintenance,1,MaterialKits,5,Power,1,TechnicianCrewPoint,1
InputResources = Alloys,5,Lab,2,Maintenance,2,MaterialKits,5,Power,2,EngineerCrewPoint,1
OutputResources = Robotics,1
}
MODULE
{
name = WOLF_RecipeOption
RecipeDisplayName = #autoLOC_USI_WOLF_FABRICATOR_RECIPE_SYNTHETICS

InputResources = ExoticMinerals,4,Maintenance,1,Polymers,1,Power,1,TechnicianCrewPoint,1
InputResources = ExoticMinerals,4,Lab,1,Maintenance,1,Polymers,1,Power,1,ScientistCrewPoint,1
OutputResources = Synthetics,1
}
}
30 changes: 13 additions & 17 deletions Source/WOLF/WOLF/Modules/WOLF_CrewTransferScenario.cs
Original file line number Diff line number Diff line change
@@ -19,6 +19,13 @@ namespace WOLF
public class WOLF_CrewTransferScenario : ScenarioModule, ICrewTransferController
{
private const float TERMINAL_RANGE = 500f;
private static readonly List<PrefabDefinition> _prefabDefs = new List<PrefabDefinition>
{
new PrefabDefinition<FlightSelector>(PrefabType.Prefab),
new PrefabDefinition<KerbalSelector>(PrefabType.Prefab),
new PrefabDefinition<WarningPanel>(PrefabType.Prefab),
new PrefabDefinition<TerminalWindow>(PrefabType.Window),
};

private readonly ArrivalWarnings _arrivalWarnings = new ArrivalWarnings();
private readonly Dictionary<string, WarningMetadata> _activeWarnings
@@ -729,7 +736,10 @@ public override void OnAwake()
base.OnAwake();

GetLocalizedTextValues();
}

private void Start()
{
var wolfScenario = FindObjectOfType<WOLF_ScenarioModule>();
_wolf = wolfScenario.ServiceManager.GetService<IRegistryCollection>();

@@ -738,30 +748,16 @@ public override void OnAwake()
{
var serviceManager = usiTools.ServiceManager;
var windowManager = serviceManager.GetService<WindowManager>();
var prefabManager = serviceManager.GetService<PrefabManager>();

try
{
// Setup UI prefabs
// Load and register UI prefabs
var filepath = Path.Combine(KSPUtil.ApplicationRootPath,
"GameData/UmbraSpaceIndustries/WOLF/Assets/UI/CrewTransferWindow.prefabs");
var prefabs = AssetBundle.LoadFromFile(filepath);
var flightSelectorPrefab = prefabs.LoadAsset<GameObject>("FlightSelector");
var kerbalSelectorPrefab = prefabs.LoadAsset<GameObject>("KerbalSelector");
var terminalWindowPrefab = prefabs.LoadAsset<GameObject>("TerminalWindow");
var warningPanelPrefab = prefabs.LoadAsset<GameObject>("WarningPanel");

// Register prefabs with window manager
windowManager
.RegisterPrefab<FlightSelector>(flightSelectorPrefab)
.RegisterPrefab<KerbalSelector>(kerbalSelectorPrefab)
.RegisterPrefab<WarningPanel>(warningPanelPrefab)
.RegisterWindow<TerminalWindow>(terminalWindowPrefab);
prefabManager.LoadAssetBundle(filepath, _prefabDefs);
}
catch (ServiceAlreadyRegisteredException) { }
catch (NullReferenceException)
{
// TODO - Create an asset bundle loader service in USITools
}
catch (Exception ex)
{
Debug.LogError($"[WOLF] {ClassName}: {ex.Message}");

0 comments on commit f3fa1ab

Please sign in to comment.