-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to controller configurability
- Loading branch information
1 parent
ba09e0f
commit 45babe9
Showing
11 changed files
with
167 additions
and
34 deletions.
There are no files selected for viewing
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
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 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
50 changes: 48 additions & 2 deletions
50
Source/Waterfall/UI/EffectControllersUI/ThrustControllerUIOptions.cs
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,4 +1,50 @@ | ||
namespace Waterfall.UI.EffectControllersUI | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UniLinq; | ||
|
||
namespace Waterfall.UI.EffectControllersUI | ||
{ | ||
public class ThrustControllerUIOptions : DefaultEffectControllerUIOptions<ThrustController> { } | ||
public class ThrustControllerUIOptions : DefaultEffectControllerUIOptions<ThrustController> | ||
{ | ||
private string[] engineIDOptions; | ||
private int engineIndex; | ||
|
||
public ThrustControllerUIOptions() { } | ||
|
||
public override void DrawOptions() | ||
{ | ||
GUILayout.BeginHorizontal(); | ||
GUILayout.Label("Engine ID", UIResources.GetStyle("data_header"), GUILayout.MaxWidth(160f)); | ||
if (engineIDOptions != null && engineIDOptions.Length != 0) | ||
{ | ||
engineIndex = GUILayout.SelectionGrid(engineIndex, engineIDOptions, 2); | ||
} | ||
else | ||
{ | ||
GUILayout.Label("0"); | ||
} | ||
GUILayout.EndHorizontal(); | ||
} | ||
|
||
protected override void LoadOptions(ThrustController controller) | ||
{ | ||
List<ModuleEngines> engineOptions = controller.ParentModule.part.FindModulesImplementing<ModuleEngines>(); | ||
engineIDOptions = engineOptions.Select(x => x.engineID).ToArray(); | ||
engineIndex = engineIDOptions.ToList().IndexOf(controller.engineID); | ||
engineIndex = engineIndex == -1 ? 0 : engineIndex; | ||
} | ||
|
||
public override void DefaultOptions(ModuleWaterfallFX parentModule) | ||
{ | ||
List<ModuleEngines> engineOptions = parentModule.part.FindModulesImplementing<ModuleEngines>(); | ||
engineIDOptions = engineOptions.Select(x => x.engineID).ToArray(); | ||
engineIndex = 0; | ||
} | ||
|
||
protected override ThrustController CreateControllerInternal() => | ||
new() | ||
{ | ||
engineID = engineIDOptions[engineIndex] | ||
}; | ||
} | ||
} |
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