Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified GameData/Waterfall/Plugins/Waterfall.dll
Binary file not shown.
Binary file modified GameData/Waterfall/Plugins/Waterfall.pdb
Binary file not shown.
851 changes: 0 additions & 851 deletions GameData/Waterfall/Templates/waterfall-srb-smoke-1.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion GameData/Waterfall/Versioning/Waterfall.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"MAJOR":0,
"MINOR":10,
"PATCH":3,
"PATCH":5,
"BUILD":0
},
"KSP_VERSION":
Expand Down
2 changes: 1 addition & 1 deletion Source/Waterfall/EffectControllers/CustomPullController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override void Initialize(ModuleWaterfallFX host)
engineController = host.GetComponents<ModuleEngines>().FirstOrDefault(x => x.engineID == engineID);
if (engineController == null)
{
Utils.Log($"[{nameof(CustomPullController)}]: Could not find engine ID {engineID}, using first module if available");
Utils.Log($"[{nameof(CustomPullController)}]: Could not find engine ID {engineID}, using first module if available", LogType.Effects);
engineController = host.part.FindModuleImplementing<ModuleEngines>();
}

Expand Down
66 changes: 66 additions & 0 deletions Source/Waterfall/EffectControllers/EngineOnOffController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.ComponentModel;
using System.Linq;
using UnityEngine;

namespace Waterfall
{
[DisplayName("Engine On State")]
public class EngineOnOffController : WaterfallController
{
public float currentState = 0f;
[Persistent] public string engineID = String.Empty;
[Persistent] public float responseRateUp = 100f;
[Persistent] public float responseRateDown = 100f;
private ModuleEngines engineController;

public bool zeroOnFlameout = true;

public EngineOnOffController() : base() { }
public EngineOnOffController(ConfigNode node) : base(node) { }

public override void Initialize(ModuleWaterfallFX host)
{
base.Initialize(host);

values = new float[1];

engineController = host.GetComponents<ModuleEngines>().FirstOrDefault(x => x.engineID == engineID);
if (engineController == null)
{
Utils.Log($"[EngineOnOffController] Could not find engine ID {engineID}, using first module", LogType.Effects);
engineController = host.part.FindModuleImplementing<ModuleEngines>();
}
else
{
currentState = engineController.isOperational ? 1f : 0f;
}

if (engineController == null)
Utils.LogError("[EngineOnOffController] Could not find engine controller on Initialize");
}

protected override float UpdateSingleValue()
{
if (engineController == null)
{
Utils.LogWarning("[EngineOnOffController] Engine controller not assigned");
return 0f;
}
else if (zeroOnFlameout)
{
float targetThrottle = engineController.isOperational && !engineController.flameout ? 1f : 0f;

if (currentState != targetThrottle)
{
float rampRate = targetThrottle > currentState ? responseRateUp : responseRateDown;
currentState = Mathf.MoveTowards(currentState, targetThrottle, rampRate * TimeWarp.deltaTime);
}

return currentState;
}
return currentState;
}
}
}

28 changes: 18 additions & 10 deletions Source/Waterfall/EffectControllers/RemapController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,28 @@ private IEnumerator FindSourceDelayed()
{
yield return new WaitForEndOfFrame();
source = parentModule.FindController(sourceController);
values = new float[source.Get().Length];
if (source == null)
{
Utils.LogError($"[RemapController] Could not find source controller {sourceController}");
}
else
{
values = new float[source.Get().Length];
}
}

protected override bool UpdateInternal()
{
if (source != null)
if (source == null) return false;

if (!source.awake) return false;

float[] sourceValues = source.Get();
for (int i = sourceValues.Length; i-- > 0;)
{
float[] sourceValues = source.Get();
for (int i = 0; i < sourceValues.Length; ++i)
{
values[i] = mappingCurve.Evaluate(sourceValues[i]);
}
values[i] = mappingCurve.Evaluate(sourceValues[i]);
}
return false;
}
return true;
}
}
}
}
48 changes: 48 additions & 0 deletions Source/Waterfall/EffectControllers/ScalarModuleController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.ComponentModel;
using System.Linq;

namespace Waterfall
{
/// <summary>
/// A controller that pulls from RCS throttle
/// </summary>
[Serializable]
[DisplayName("Scalar Module (AnimateGeneric)")]
public class ScalarModuleController : WaterfallController
{
private IScalarModule scalarController;
[Persistent] public string moduleID = String.Empty;

public ScalarModuleController() : base() { }
public ScalarModuleController(ConfigNode node) : base(node) { }

public override void Initialize(ModuleWaterfallFX host)
{
base.Initialize(host);

values = new float[1];

scalarController = host.part.FindModulesImplementing<IScalarModule>().FirstOrDefault(x => x.ScalarModuleID == moduleID);
if (scalarController == null)
{
Utils.LogError($"[ScalarModuleController] Could not find a compatible module with ID {moduleID} on Initialize");
values = new float[0];
return;
}
}

protected override float UpdateSingleValue()
{
if (scalarController == null)
{
Utils.LogWarning("[ScalarModuleController] Scalar module not assigned");
return 0;
}
else
{
return scalarController.GetScalar;
}
}
}
}
2 changes: 1 addition & 1 deletion Source/Waterfall/EffectControllers/ThrottleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Initialize(ModuleWaterfallFX host)
engineController = host.GetComponents<ModuleEngines>().FirstOrDefault(x => x.engineID == engineID);
if (engineController == null)
{
Utils.Log($"[ThrottleController] Could not find engine ID {engineID}, using first module");
Utils.Log($"[ThrottleController] Could not find engine ID {engineID}, using first module", LogType.Effects);
engineController = host.part.FindModuleImplementing<ModuleEngines>();
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Waterfall/EffectControllers/ThrustController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void Initialize(ModuleWaterfallFX host)
engineController = host.GetComponents<ModuleEngines>().FirstOrDefault(x => x.engineID == engineID);
if (engineController == null)
{
Utils.Log($"[ThrustController] Could not find engine ID {engineID}, using first module");
Utils.Log($"[ThrustController] Could not find engine ID {engineID}, using first module", LogType.Effects);
engineController = host.part.FindModuleImplementing<ModuleEngines>();
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Waterfall/Modules/ModuleWaterfallFX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ protected void InitializeEffects()
activeFX.Clear();
foreach (var fx in allFX)
{
Utils.Log($"[ModuleWaterfallFX]: Initializing effect {fx.name}");
Utils.Log($"[ModuleWaterfallFX]: Initializing effect {fx.name}", LogType.Modules);
if (fx.InitializeEffect(this, false, useRelativeScaling))
{
activeFX.Add(fx);
Expand Down
15 changes: 6 additions & 9 deletions Source/Waterfall/UI/EditWindows/UICurveEditWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class UICurveEditWindow : UIPopupWindow

public UICurveEditWindow(FastFloatCurve curveToEdit, bool show) : base(show)
{
Utils.Log($"Started editing curve {curveToEdit}");
Utils.Log($"[UICurveEditWindow] Started editing curve {curveToEdit}", LogType.UI);


if (!showWindow)
Expand All @@ -32,7 +32,7 @@ public UICurveEditWindow(FastFloatCurve curveToEdit, bool show) : base(show)
public UICurveEditWindow(FastFloatCurve curveToEdit, CurveUpdateFunction curveFun, bool show) : base(show)
{
curveUpdateFun = curveFun;
Utils.Log($"Started editing curve {curveToEdit}");
Utils.Log($"[UICurveEditWindow]: Started editing curve {curveToEdit}", LogType.UI);

if (!showWindow)
WindowPosition = new(Screen.width / 2, Screen.height / 2, 678, 600);
Expand All @@ -46,7 +46,7 @@ public UICurveEditWindow(FastFloatCurve curveToEdit, UIModifierWindow modWin, st
{
modifier = modWin;
modifierTag = tag;
Utils.Log($"Started editing curve {curveToEdit}", LogType.UI);
Utils.Log($"[UICurveEditWindow]: Started editing curve {curveToEdit}", LogType.UI);

if (!showWindow)
WindowPosition = new(Screen.width / 2, Screen.height / 2, 678, 600);
Expand All @@ -58,7 +58,7 @@ public UICurveEditWindow(FastFloatCurve curveToEdit, UIModifierWindow modWin, st

public void ChangeCurve(FastFloatCurve curveToEdit)
{
Utils.Log($"Started editing curve {curveToEdit}", LogType.UI);
Utils.Log($"[UICurveEditWindow]: Started editing curve {curveToEdit}", LogType.UI);
curve = curveToEdit;
points = GraphUtils.FastFloatCurveToPoints(curveToEdit);
UpdateCurve(out curve);
Expand All @@ -69,7 +69,7 @@ public void ChangeCurve(FastFloatCurve curveToEdit)
public void ChangeCurve(FastFloatCurve curveToEdit, CurveUpdateFunction curveFun)
{
curveUpdateFun = curveFun;
Utils.Log($"Started editing curve {curveToEdit}", LogType.UI);
Utils.Log($"[UICurveEditWindow]: Started editing curve {curveToEdit}", LogType.UI);
curve = curveToEdit;
points = GraphUtils.FastFloatCurveToPoints(curveToEdit);
UpdateCurve(out curve);
Expand All @@ -81,7 +81,7 @@ public void ChangeCurve(FastFloatCurve curveToEdit, UIModifierWindow modWin, str
{
modifier = modWin;
modifierTag = tag;
Utils.Log($"Started editing curve {curveToEdit}", LogType.UI);
Utils.Log($"[UICurveEditWindow]: Started editing curve {curveToEdit}", LogType.UI);
curve = curveToEdit;
points = GraphUtils.FastFloatCurveToPoints(curveToEdit);
UpdateCurve(out curve);
Expand All @@ -100,13 +100,10 @@ public void UpdateCurve(out FastFloatCurve theCurve)
theCurve.FindMinMax(out float minTime, out minY, out float maxTime, out maxY);
curve = theCurve;
curveUpdateFun(curve);
//WaterfallUI.Instance.UpdateCurve(curve);
textVersion = GraphUtils.PointsToString(points);
graphTexture = GraphUtils.GenerateCurveTexture(texWidth, texHeight, curve, Color.green);
}


//
public bool Compare(FastFloatCurve toCompare)
{
if (GraphUtils.FastFloatCurveToPoints(toCompare) != points)
Expand Down
6 changes: 0 additions & 6 deletions Source/Waterfall/UI/EditWindows/UIGradientEditWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ protected void AddAlphaKey(float selTime)
}
public void DeleteAlphaKey(UIGradientAlphaKey selKey)
{
Utils.Log("Delete Alpha key");
deleteAlphaList.Add(selKey);
if (selectedKey == selKey)
{
Expand Down Expand Up @@ -336,15 +335,13 @@ public void SelectAlphaKey(UIGradientAlphaKey selKey)
}
public void StopAlphaKeyDrag()
{
Utils.Log("Stopped dragging alpha key");
keyDrag = false;
SelectAlphaKey(selectedKey);
RegenerateGradient();
}
bool keyDrag = false;
public void StartKeyDrag()
{
Utils.Log("Started key drag");
keyDrag = true;
}

Expand Down Expand Up @@ -415,7 +412,6 @@ protected void DrawColorKeys(Rect rect)

protected void AddColorKey(float selTime)
{
Utils.Log("Add Color key");
UIGradientColorKey newKey = new UIGradientColorKey(selTime,
new Color(
gradient.Evaluate(selTime).r,
Expand All @@ -428,7 +424,6 @@ protected void AddColorKey(float selTime)
}
public void DeleteColorKey(UIGradientColorKey selKey)
{
Utils.Log("Delete Color key");
deleteColorList.Add(selKey);
if (selectedColorKey == selKey)
{
Expand Down Expand Up @@ -463,7 +458,6 @@ public void SelectColorKey(UIGradientColorKey selKey)
}
public void StopColorKeyDrag()
{
Utils.Log("Stopped dragging color key");
keyDrag = false;
SelectColorKey(selectedColorKey);
RegenerateGradient();
Expand Down
Loading