Skip to content

Commit

Permalink
Add ID specification to engine event controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisAdderley committed Sep 22, 2024
1 parent 45babe9 commit bd7ff25
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Binary file modified GameData/Waterfall/Plugins/Waterfall.dll
Binary file not shown.
11 changes: 4 additions & 7 deletions Source/Waterfall/EffectControllers/EngineEventController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

namespace Waterfall
{
/// <summary>
/// </summary>
[DisplayName("Engine Event")]
public class EngineEventController : WaterfallController
{
Expand All @@ -27,7 +25,7 @@ public class EngineEventController : WaterfallController
private static readonly Dictionary<string, Func<ModuleEngines, bool>> EngineStateFuncs = new()
{
{ "flameout", (engineModule) => engineModule.flameout || !engineModule.EngineIgnited},
{ "ignition", (engineModule) => engineModule.EngineIgnited},
{ "ignition", (engineModule) => engineModule.EngineIgnited}
};

public EngineEventController() : base() { }
Expand All @@ -49,11 +47,10 @@ public override void Initialize(ModuleWaterfallFX host)

values = new float[1];


engineModule = host.GetComponents<ModuleEngines>().FirstOrDefault(x => x.engineID == engineID);
if (engineModule == null)
{
Utils.Log($"[EngineEventController] Could not find engine ID {engineID}, using first module");
Utils.Log($"[EngineEventController] Could not find engine ID {engineID}, using first module", LogType.Effects);
engineModule = host.part.FindModuleImplementing<ModuleEngines>();
}
multiEngine = host.GetComponent<MultiModeEngine>();
Expand Down Expand Up @@ -90,7 +87,7 @@ public float CheckStateChange()
/// Check if engine state flipped
if (getEngineStateFunc(engineModule))
{
Utils.Log($"[EngineEventController] {eventName} fired", LogType.Modifiers);
Utils.Log($"[EngineEventController] {eventName} fired on {engineID}", LogType.Effects);
eventReady = false;
eventPlaying = true;
eventTime = TimeWarp.deltaTime;
Expand All @@ -108,7 +105,7 @@ public float CheckStateChange()
// Check to see if event can be reset
if (!getEngineStateFunc(engineModule))
{
Utils.Log($"[EngineEventController] {eventName} ready", LogType.Modifiers);
Utils.Log($"[EngineEventController] {eventName} ready on {engineID}", LogType.Effects);
eventReady = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Waterfall.UI.EffectControllersUI
public class EngineEventControllerUIOptions : DefaultEffectControllerUIOptions<EngineEventController>
{

private readonly string[] eventTypes = { "ignition", "flameout" };
private readonly string[] eventTypes = { "ignition", "flameout"};
private string[] engineIDOptions;
private int engineIndex;

Expand All @@ -20,7 +20,6 @@ public class EngineEventControllerUIOptions : DefaultEffectControllerUIOptions<E
private float eventDuration = 2f;
private string eventDurationString;
private Texture2D miniCurve;
private UICurveEditWindow curveEditor;

public EngineEventControllerUIOptions()
{
Expand All @@ -44,7 +43,8 @@ public override void DrawOptions()
{
GUILayout.Label("0");
}
GUILayout.Label("Event name");
GUILayout.EndHorizontal();
GUILayout.Label("Event Name");
int eventFlagChanged = GUILayout.SelectionGrid(eventFlag, eventTypes, Mathf.Min(eventTypes.Length, 4), UIResources.GetStyle("radio_text_button"));

eventFlag = eventFlagChanged;
Expand Down Expand Up @@ -74,6 +74,7 @@ protected override void LoadOptions(EngineEventController controller)
eventCurve = controller.eventCurve;
eventDuration = controller.eventDuration;
eventDurationString = controller.eventDuration.ToString();

List<ModuleEngines> engineOptions = controller.ParentModule.part.FindModulesImplementing<ModuleEngines>();
engineIDOptions = engineOptions.Select(x => x.engineID).ToArray();
engineIndex = engineIDOptions.ToList().IndexOf(controller.engineID);
Expand Down Expand Up @@ -101,7 +102,7 @@ protected override EngineEventController CreateControllerInternal() =>
private void EditCurve(FloatCurve toEdit, CurveUpdateFunction function)
{
Utils.Log($"Started editing curve {toEdit.Curve}", LogType.UI);
curveEditor = WaterfallUI.Instance.OpenCurveEditor(toEdit, function);
WaterfallUI.Instance.OpenCurveEditor(toEdit, function);
}

private void GenerateCurveThumbs()
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ v0.10.0
- Fixed engine light layers targeting IVA layers (#130)
- Thrust and Throttle controllers can now have their EngineID set in the UI (#125)
- Added a UI option for Perlin noise to have its seed to an option that will randomize it on effect startup (#127)
- It is now possible to set Engine ID in Engine Event Controllers, and those controllers will only fire on events asocaited with that engine ID (#126)
- Various logging cleanups and improvements
- Reworked most Editor window UIs to look cleaner and work better
- Refactored a lot of UI code for more coherency
Expand Down

0 comments on commit bd7ff25

Please sign in to comment.