Skip to content

Commit

Permalink
Commented out NearestVessel code; is incomplete feature and causes pl…
Browse files Browse the repository at this point in the history
…ayback to fail unless another vessel is in Flight scene.

Signed-off-by: Brendan_ <schpoorky@gmail.com>
  • Loading branch information
schpoorky committed Sep 6, 2017
1 parent 097bd73 commit f9de67a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TestResults
*.suo
*.user
*.sln.docstates
*.userprefs

# Build results
[Dd]ebug/
Expand Down
6 changes: 6 additions & 0 deletions SoundtrackEditor/EventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void AddMinAltitude(float minAlt)
}

// Nearest vessel
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
public Vessel NearestVessel;
public bool MonitorNearestVessel { get; private set; }
private float _maxVesselDist = float.MaxValue;
Expand All @@ -89,6 +91,7 @@ public void AddMinVesselDistance(float minVesselDist)
MonitorNearestVessel = true;
_minVesselDist = Math.Max(_minVesselDist, minVesselDist);
}
*/

public static EventManager Instance { get; private set; }

Expand Down Expand Up @@ -175,6 +178,8 @@ private void UpdateSituation()
}
}

// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
if (MonitorNearestVessel)
{
Vessel newVessel = Utils.GetNearestVessel(_minVesselDist, _maxVesselDist, v);
Expand All @@ -184,6 +189,7 @@ private void UpdateSituation()
changed = true;
}
}
*/
}
}
else if (SoundtrackEditor.CurrentSituation.scene == Enums.Scenes.SpaceCentre)
Expand Down
6 changes: 6 additions & 0 deletions SoundtrackEditor/Persistor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public static List<Playlist> LoadPlaylists()
if (p.playWhen.minAltitude != float.MinValue)
EventManager.Instance.AddMinAltitude(p.playWhen.minAltitude);
}
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
if (playWhen.HasValue("maxVesselDistance"))
{
p.playWhen.maxVesselDistance = float.Parse(playWhen.GetValue("maxVesselDistance"));
Expand All @@ -186,6 +188,7 @@ public static List<Playlist> LoadPlaylists()
if (p.playWhen.minVesselDistance != float.MinValue)
EventManager.Instance.AddMinVesselDistance(p.playWhen.minVesselDistance);
}
*/
}

playlists.Add(p);
Expand Down Expand Up @@ -472,10 +475,13 @@ public static void SavePlaylists(List<Playlist> playlists)
preReq.AddValue("maxAltitude", pl.playWhen.maxAltitude);
if (pl.playWhen.minAltitude != float.MinValue && pl.playWhen.minAltitude != float.MaxValue)
preReq.AddValue("minAltitude", pl.playWhen.minAltitude);
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
if (pl.playWhen.maxVesselDistance != float.MaxValue)
preReq.AddValue("maxVesselDistance", pl.playWhen.maxVesselDistance);
if (pl.playWhen.minVesselDistance != 0)
preReq.AddValue("minVesselDistance", pl.playWhen.minVesselDistance);
*/
if (pl.playWhen.scene != Enums.Scenes.Any)
preReq.AddValue("scene", pl.playWhen.scene.ToString().Replace(", ", " | "));
if (pl.playWhen.situation != Enums.AnyVesselSituation)
Expand Down
18 changes: 18 additions & 0 deletions SoundtrackEditor/Playlist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,11 @@ public class Prerequisites
public float minVelocityOrbital = float.MinValue;
public float maxAltitude = float.MaxValue;
public float minAltitude = float.MinValue;
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
public float maxVesselDistance = float.MaxValue;
public float minVesselDistance = 0f;
*/

public Prerequisites() {}
public Prerequisites(Prerequisites p)
Expand Down Expand Up @@ -381,10 +384,13 @@ public bool CheckAltitude(Vessel v)
return (maxAltitude >= v.altitude) && (minAltitude <= v.altitude);
}

// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
public bool CheckVesselDistance(Vessel v)
{
return Utils.GetNearestVessel(minVesselDistance, maxVesselDistance, v) != null;
}
*/

public bool CheckInAtmosphere(Vessel v)
{
Expand Down Expand Up @@ -431,7 +437,10 @@ public bool PrerequisitesMet()
if (!CheckOrbitalVelocity(v)) return false;
if (!CheckSurfaceVelocity(v)) return false;
if (!CheckAltitude(v)) return false;
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
if (!CheckVesselDistance(v)) return false;
*/
if (!CheckInAtmosphere(v)) return false;

//if (p.playAfter
Expand Down Expand Up @@ -464,8 +473,11 @@ public override bool Equals(System.Object obj)
(this.minVelocityOrbital == p.minVelocityOrbital) &&
(this.maxAltitude == p.maxAltitude) &&
(this.minAltitude == p.minAltitude) &&
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
(this.maxVesselDistance == p.maxVesselDistance) &&
(this.minVesselDistance == p.minVesselDistance) &&
*/
(this.scene == p.scene) &&
(this.situation == p.situation) &&
(this.cameraMode == p.cameraMode) &&
Expand All @@ -490,8 +502,11 @@ public bool Equals(Prerequisites p)
(this.minVelocityOrbital == p.minVelocityOrbital) &&
(this.maxAltitude == p.maxAltitude) &&
(this.minAltitude == p.minAltitude) &&
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
(this.maxVesselDistance == p.maxVesselDistance) &&
(this.minVesselDistance == p.minVesselDistance) &&
*/
(this.scene == p.scene) &&
(this.situation == p.situation) &&
(this.cameraMode == p.cameraMode) &&
Expand All @@ -513,8 +528,11 @@ public override int GetHashCode()
G = minVelocityOrbital,
H = maxAltitude,
I = minAltitude,
// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
J = maxVesselDistance,
K = minVesselDistance,
*/
L = scene,
M = situation,
N = cameraMode,
Expand Down
3 changes: 3 additions & 0 deletions SoundtrackEditor/SoundGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ private void MainGui(int windowID)
GUILayout.Label("<b>Current Situation</b>");
GUILayout.Label(Playlist.Prerequisites.PrintSituation());

// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
Vessel v = Utils.GetNearestVessel();
if (v != null)
GUILayout.Label("Nearest vessel: " + v);
*/

if (sted.LoadingClip != null)
GUILayout.Label("Preloading track " + sted.LoadingClip.name);
Expand Down
33 changes: 12 additions & 21 deletions SoundtrackEditor/SoundtrackEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,42 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\Squad binaries\x64\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\Squad binaries\x64\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Assembly-UnityScript">
<HintPath>..\..\Squad binaries\x64\Assembly-UnityScript.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-UnityScript.dll</HintPath>
</Reference>
<Reference Include="Assembly-UnityScript-firstpass">
<HintPath>..\..\Squad binaries\x64\Assembly-UnityScript-firstpass.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-UnityScript-firstpass.dll</HintPath>
</Reference>
<Reference Include="KSPAssets">
<HintPath>..\..\Squad binaries\x64\KSPAssets.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\KSPAssets.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Core">
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\System.Core.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\Squad binaries\x64\UnityEngine.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Networking">
<HintPath>..\..\Squad binaries\x64\UnityEngine.Networking.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.Networking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\Squad binaries\x64\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityScript.Lang">
<HintPath>..\..\Squad binaries\x64\UnityScript.Lang.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\.steam\steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityScript.Lang.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions SoundtrackEditor/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public static string GetDllDirectoryPath()
return Path.GetDirectoryName(path);
}

// TODO: fix so absence of any other vessel doesn't prevent soundtrack playback
/*
public static Vessel GetNearestVessel()
{
if (HighLogic.LoadedScene == GameScenes.LOADING)
Expand Down Expand Up @@ -120,6 +122,7 @@ public static Vessel GetNearestVessel(float min, float max, Vessel v)
}
return nearestVessel;
}
*/

/*public static Shader GetShader()
{
Expand Down

0 comments on commit f9de67a

Please sign in to comment.