Skip to content

Commit de9b925

Browse files
committed
refactor reflection code into separate files per mod
1 parent f96f992 commit de9b925

File tree

5 files changed

+56
-41
lines changed

5 files changed

+56
-41
lines changed

SCANsat/SCAN_Data/SCANwaypoint.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using FinePrint;
1717
using FinePrint.Utilities;
1818
using UnityEngine;
19+
using SCANsat.SCAN_Reflection;
1920

2021
namespace SCANsat.SCAN_Data
2122
{
@@ -141,7 +142,7 @@ private Waypoint reflectWaypoint(StationaryPointParameter p)
141142
{
142143
if (SCANmainMenuLoader.FinePrintStationaryWaypoint)
143144
{
144-
return SCANreflection.FinePrintStationaryWaypointObject(p);
145+
return SCANfinePrint.FinePrintStationaryWaypointObject(p);
145146
}
146147

147148
return null;
@@ -151,7 +152,7 @@ private FlightBand reflectFlightBand(SurveyWaypointParameter p)
151152
{
152153
if (SCANmainMenuLoader.FinePrintFlightBand)
153154
{
154-
return SCANreflection.FinePrintFlightBandValue(p);
155+
return SCANfinePrint.FinePrintFlightBandValue(p);
155156
}
156157

157158
return FlightBand.NONE;
Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,20 @@
1-
#region license
2-
/*
3-
* [Scientific Committee on Advanced Navigation]
4-
* S.C.A.N. Satellite
5-
*
6-
* SCANreflection - assigns reflection methods at startup
7-
*
8-
* Copyright (c)2014 David Grandy <[email protected]>;
9-
* Copyright (c)2014 technogeeky <[email protected]>;
10-
* Copyright (c)2014 (Your Name Here) <your email here>; see LICENSE.txt for licensing details.
11-
*/
12-
#endregion
13-
14-
using System;
1+
using System;
152
using System.Reflection;
163
using FinePrint;
174
using FinePrint.Contracts.Parameters;
185
using FinePrint.Utilities;
196
using UnityEngine;
207

21-
namespace SCANsat
8+
namespace SCANsat.SCAN_Reflection
229
{
23-
static class SCANreflection
10+
static class SCANfinePrint
2411
{
25-
public const string KOPERNICUSONDEMANDTYPE = "ScaledSpaceOnDemand";
26-
private const string KOPERNICUSONDEMANDLOAD = "LoadTextures";
27-
private const string KOPERNICUSONDEMANDUNLOAD = "UnloadTextures";
28-
2912
private static bool FinePrintFlightBandRun = false;
3013
private static bool FinePrintStationaryWaypointRun = false;
3114

3215
private static FieldInfo _FinePrintFlightBand;
3316
private static FieldInfo _FinePrintStationaryWaypoint;
3417

35-
internal static void LoadOnDemand(MonoBehaviour scaledSpaceOnDemand)
36-
{
37-
scaledSpaceOnDemand.GetType().InvokeMember(KOPERNICUSONDEMANDLOAD
38-
, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.InvokeMethod, null, scaledSpaceOnDemand, null);
39-
}
40-
41-
internal static void UnloadOnDemand(MonoBehaviour scaledSpaceOnDemand)
42-
{
43-
scaledSpaceOnDemand.GetType().InvokeMember(KOPERNICUSONDEMANDUNLOAD
44-
, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.InvokeMethod, null, scaledSpaceOnDemand, null);
45-
}
4618

4719
internal static Waypoint FinePrintStationaryWaypointObject(StationaryPointParameter p)
4820
{
@@ -153,6 +125,5 @@ internal static bool FinePrintFlightBandReflection()
153125

154126
return false;
155127
}
156-
157128
}
158-
}
129+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#region license
2+
/*
3+
* [Scientific Committee on Advanced Navigation]
4+
* S.C.A.N. Satellite
5+
*
6+
* SCANreflection - assigns reflection methods at startup
7+
*
8+
* Copyright (c)2014 David Grandy <[email protected]>;
9+
* Copyright (c)2014 technogeeky <[email protected]>;
10+
* Copyright (c)2014 (Your Name Here) <your email here>; see LICENSE.txt for licensing details.
11+
*/
12+
#endregion
13+
14+
using System;
15+
using System.Reflection;
16+
using FinePrint;
17+
using FinePrint.Contracts.Parameters;
18+
using FinePrint.Utilities;
19+
using UnityEngine;
20+
21+
namespace SCANsat.SCAN_Reflection
22+
{
23+
static class SCANkopernicus
24+
{
25+
public const string KOPERNICUSONDEMANDTYPE = "ScaledSpaceOnDemand";
26+
private const string KOPERNICUSONDEMANDLOAD = "LoadTextures";
27+
private const string KOPERNICUSONDEMANDUNLOAD = "UnloadTextures";
28+
29+
internal static void LoadOnDemand(MonoBehaviour scaledSpaceOnDemand)
30+
{
31+
scaledSpaceOnDemand.GetType().InvokeMember(KOPERNICUSONDEMANDLOAD
32+
, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.InvokeMethod, null, scaledSpaceOnDemand, null);
33+
}
34+
35+
internal static void UnloadOnDemand(MonoBehaviour scaledSpaceOnDemand)
36+
{
37+
scaledSpaceOnDemand.GetType().InvokeMember(KOPERNICUSONDEMANDUNLOAD
38+
, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreReturn | BindingFlags.InvokeMethod, null, scaledSpaceOnDemand, null);
39+
}
40+
}
41+
}

SCANsat/SCANcontroller.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
using FinePrint.Contracts.Parameters;
3434
using UnityEngine.Profiling;
3535
using Log = KSPBuildTools.Log;
36+
using SCANsat.SCAN_Reflection;
3637

3738
namespace SCANsat
3839
{
@@ -1491,14 +1492,14 @@ internal void loadOnDemandScaledSpace(CelestialBody b, mapSource s)
14911492
break;
14921493
}
14931494

1494-
kopernicusScaledSpaceLoader = b.scaledBody.GetComponents<MonoBehaviour>().Where(p => p.GetType().Name == SCANreflection.KOPERNICUSONDEMANDTYPE).FirstOrDefault();
1495+
kopernicusScaledSpaceLoader = b.scaledBody.GetComponents<MonoBehaviour>().Where(p => p.GetType().Name == SCANkopernicus.KOPERNICUSONDEMANDTYPE).FirstOrDefault();
14951496

14961497
if (kopernicusScaledSpaceLoader == null)
14971498
{
14981499
return;
14991500
}
15001501

1501-
SCANreflection.LoadOnDemand(kopernicusScaledSpaceLoader);
1502+
SCANkopernicus.LoadOnDemand(kopernicusScaledSpaceLoader);
15021503

15031504
kopernicusScaledSpaceLoader = null;
15041505

@@ -1569,14 +1570,14 @@ internal void unloadOnDemandScaledSpace(CelestialBody b, mapSource s)
15691570
return;
15701571
}
15711572

1572-
kopernicusScaledSpaceLoader = b.scaledBody.GetComponents<MonoBehaviour>().Where(p => p.GetType().Name == SCANreflection.KOPERNICUSONDEMANDTYPE).FirstOrDefault();
1573+
kopernicusScaledSpaceLoader = b.scaledBody.GetComponents<MonoBehaviour>().Where(p => p.GetType().Name == SCANkopernicus.KOPERNICUSONDEMANDTYPE).FirstOrDefault();
15731574

15741575
if (kopernicusScaledSpaceLoader == null)
15751576
{
15761577
return;
15771578
}
15781579

1579-
SCANreflection.UnloadOnDemand(kopernicusScaledSpaceLoader);
1580+
SCANkopernicus.UnloadOnDemand(kopernicusScaledSpaceLoader);
15801581

15811582
kopernicusScaledSpaceLoader = null;
15821583

SCANsat/SCANmainMenuLoader.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Linq;
1919
using UnityEngine;
2020
using Log = KSPBuildTools.Log;
21+
using SCANsat.SCAN_Reflection;
2122

2223
namespace SCANsat
2324
{
@@ -62,8 +63,8 @@ private void Start()
6263
}
6364

6465
findAssemblies(Assemblies);
65-
FinePrintStationaryWaypoint = SCANreflection.FinePrintStationaryWaypointReflection();
66-
FinePrintFlightBand = SCANreflection.FinePrintFlightBandReflection();
66+
FinePrintStationaryWaypoint = SCANfinePrint.FinePrintStationaryWaypointReflection();
67+
FinePrintFlightBand = SCANfinePrint.FinePrintFlightBandReflection();
6768
SCANconfigLoader.configLoader();
6869
}
6970

0 commit comments

Comments
 (0)