Skip to content

Commit

Permalink
added unit test (activated with alt+u) and new simplified internal wa…
Browse files Browse the repository at this point in the history
…rp function for testing
  • Loading branch information
AmberCronin committed Apr 28, 2018
1 parent 650d40c commit ae901ab
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
7 changes: 6 additions & 1 deletion KerbalFuture.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KerbalFuture", "KerbalFuture\KerbalFuture.csproj", "{4D44E5E4-E212-4F77-9402-6B0674BC4486}"
EndProject
Global
Expand All @@ -13,6 +15,9 @@ Global
{4D44E5E4-E212-4F77-9402-6B0674BC4486}.Release|x86.ActiveCfg = Release|x86
{4D44E5E4-E212-4F77-9402-6B0674BC4486}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.DotNetNamingPolicy = $1
Expand Down
1 change: 1 addition & 0 deletions KerbalFuture/KerbalFuture.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<Compile Include="Superluminal\SpaceFolder\SpaceFolderWarpChecks.cs" />
<Compile Include="Superluminal\SpaceFolder\SpaceFolderWarpData.cs" />
<Compile Include="Superluminal\SpaceFolder\WarpCheckErrors.cs" />
<Compile Include="UnitTests\UnitTests.cs" />
<Compile Include="Utils\Coords.cs" />
<Compile Include="Utils\SimulationStatus.cs" />
<Compile Include="Utils\Tuple.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using KerbalFuture.Utils;
using KerbalFuture.UnitTests;

namespace KerbalFuture.Superluminal.SpaceFolder
{
Expand All @@ -13,8 +14,17 @@ public class SpaceFolderDriveVesselModule : VesselModule
List<Part> driveList = new List<Part>();
// Dictionary of the part and its respective participation in the warp
Dictionary<Part, double> partECAmount = new Dictionary<Part, double>();
// Warps the vessel, using resources
public bool WarpVessel(SpaceFolderWarpData warpData, out int fault)
// Warps the vessel, using resources
public void Awake()
{
UnitTests.UnitTests.vesselModule = this;
}
internal bool WarpVessel(Vector3d location)
{
vessel.SetPosition(location);
return true;
}
public bool WarpVessel(SpaceFolderWarpData warpData, out int fault)
{
driveList = WarpHelp.PartsWithModule(Vessel, new ModuleSpaceFolderEngine());
int internFault = fault = SpaceFolderWarpChecks.WarpAvailable(warpData, Vessel);
Expand Down
20 changes: 20 additions & 0 deletions KerbalFuture/UnitTests/UnitTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using KerbalFuture.Superluminal.SpaceFolder;
using KerbalFuture.Utils;
using UnityEngine;

namespace KerbalFuture.UnitTests
{
[KSPAddon(KSPAddon.Startup.Flight, false)] //starts every time player enters flight scene
class UnitTests : MonoBehaviour
{
public static SpaceFolderDriveVesselModule vesselModule;
public void Update()
{
if(Input.GetKey(KeyCode.U) && (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)))
{
vesselModule.WarpVessel(new Vector3d(40000, 2100000, 500000000));
}
}
}
}

0 comments on commit ae901ab

Please sign in to comment.