Skip to content

Commit

Permalink
Merge pull request #77 from DMagic1/dev
Browse files Browse the repository at this point in the history
Version 1.3.10
  • Loading branch information
DMagic1 authored Jun 13, 2017
2 parents 7f10a72 + 5302c28 commit 6e8b989
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 56 deletions.
7 changes: 6 additions & 1 deletion GameData/DMagicOrbitalScience/Change Log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
v1.3.9
v1.3.10
- Fix error in ground detection for XRay and Seismic experiments

- Add options to disable the science functions or antenna functions for SIGINT and Soil Moisture

v1.3.9
- Updated for KSP 1.3

- Fix several bugs with SIGINT and Soil Moisture antenna usage
Expand Down
4 changes: 2 additions & 2 deletions GameData/DMagicOrbitalScience/DMagicOrbitalScience.version
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"NAME":"DMagic Orbital Science",
"URL":"https://raw.githubusercontent.com/DMagic1/Orbital-Science/master/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version",
"DOWNLOAD":"https://spacedock.info/mod/128/DMagic%20Orbital%20Science/download/1.3.9",
"DOWNLOAD":"https://spacedock.info/mod/128/DMagic%20Orbital%20Science",
"GITHUB":{
"USERNAME":"DMagic1",
"REPOSITORY":"Orbital-Science",
Expand All @@ -11,7 +11,7 @@
"MAJOR":1,
"MINOR":3,
"PATCH":0,
"BUILD":9
"BUILD":10
},
"KSP_VERSION":{
"MAJOR":1,
Expand Down
8 changes: 7 additions & 1 deletion Source/Part Modules/DMModuleScienceAnimate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private void setup()
enviroList = this.part.FindModulesImplementing<DMEnviroSensor>();
if (waitForAnimationTime == -1 && animSpeed != 0)
waitForAnimationTime = anim[animationName].length / animSpeed;
if (experimentID != null)
if (!string.IsNullOrEmpty(experimentID))
{
scienceExp = ResearchAndDevelopment.GetExperiment(experimentID);
if (scienceExp != null)
Expand Down Expand Up @@ -1017,6 +1017,12 @@ public virtual bool canConduct()
failMessage = customFailMessage;
return false;
}
else if (scienceExp == null)
{
failMessage = "Error: Science Experiment Definition Invalid";
Debug.LogError("[DMOS] Something Went Wrong Here; Null Experiment Returned; Please Report This On The KSP Forum With Output.log Data");
return false;
}
else if (scienceExp.requireAtmosphere && !vessel.mainBody.atmosphere)
{
failMessage = customFailMessage;
Expand Down
42 changes: 36 additions & 6 deletions Source/Part Modules/DMSIGINT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public class DMSIGINT : DMBreakablePart, IDMSurvey, IScalarModule
public bool allowTransmission = true;
[KSPField(guiActive = true, guiName = "Science Transmission")]
public string scienceTransmission = "Enabled";
[KSPField]
public bool noScience = false;
[KSPField]
public bool noAntenna = false;

private readonly string[] dishTransformNames = new string[7] { "dish_Armature.000", "dish_Armature.001", "dish_Armature.002", "dish_Armature.003", "focalColumn", "dishCenter", "focalHead" };
private readonly string[] dishMeshNames = new string[7] { "dish_Mesh.000", "dish_Mesh.001", "dish_Mesh.002", "dish_Mesh.003", "focalColumn", "dishCenter", "focalHead" };
Expand Down Expand Up @@ -74,7 +78,7 @@ public override void OnStart(PartModule.StartState state)

base.OnStart(state);

if (scienceExp != null)
if (scienceExp != null && !noScience)
{
sitMask = (int)scienceExp.situationMask;
bioMask = sitMask;
Expand All @@ -84,8 +88,22 @@ public override void OnStart(PartModule.StartState state)
scalarStep = 1 / anim[animationName].length;

Events["fixPart"].guiName = "Fix Dish";
Fields["scienceTransmission"].guiActive = !noAntenna;
Events["ToggleScienceTransmission"].active = !noAntenna;
Events["ToggleScienceTransmission"].guiName = allowTransmission ? "Disable Science Transmission" : "Enable Science Transmission";
scienceTransmission = allowTransmission ? "Enabled" : "Disabled";
scienceTransmission = allowTransmission && !noAntenna ? "Enabled" : "Disabled";

if (noScience)
{
Actions["DeployAction"].active = false;
Events["CollectDataExternalEvent"].active = false;
Events["ResetExperimentExternal"].active = false;
Events["ResetExperiment"].active = false;
Events["DeployExperiment"].active = false;
Events["TransferDataEvent"].active = false;
Events["CleanUpExperimentExternal"].active = false;
Deployed = true;
}

if (useFairings)
{
Expand Down Expand Up @@ -357,7 +375,7 @@ public bool CanMove
{
get
{
if (!allowTransmission)
if (!allowTransmission || noAntenna)
return false;

if (anim.IsPlaying(animationName))
Expand All @@ -377,7 +395,7 @@ public float GetScalar
{
get
{
if (!allowTransmission)
if (!allowTransmission || noAntenna)
return 0;

if (broken)
Expand Down Expand Up @@ -467,9 +485,21 @@ public string ScalarModuleID
get { return "dmsigint"; }
}

public override void OnUpdate()
protected override void Update()
{
base.OnUpdate();
base.Update();

if (noScience)
{
Events["CollectDataExternalEvent"].active = false;
Events["ResetExperimentExternal"].active = false;
Events["ResetExperiment"].active = false;
Events["DeployExperiment"].active = false;
Events["DeployExperimentExternal"].active = false;
Events["TransferDataEvent"].active = false;
Events["CleanUpExperimentExternal"].active = false;
Deployed = true;
}

if (!moving)
return;
Expand Down
35 changes: 13 additions & 22 deletions Source/Part Modules/DMSeismicHammer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -707,38 +707,29 @@ private bool rayImpact(bool b, Transform t, float s, float max, out float d)
Vector3 p = t.position;
Ray r = new Ray(p, -1f * t.forward);
d = 0f;
int layer = 32769;

Physics.Raycast(r, out hit, max * s);
Physics.Raycast(r, out hit, max * s, layer);
if (hit.collider != null)
{
if (b)
{
Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent<Part>();

if (a != null)
{
if (a.Modules.Contains("ModuleAsteroid"))
{
d = hit.distance;
return true;
}
}
}
else
{
Transform hitT = hit.collider.transform;
int i = 0; //Just to prevent this from getting stuck in a loop
while (hitT != null && i < 30)
if (hit.collider.gameObject.layer == 0)
{
if (hitT == vessel.mainBody.bodyTransform)
Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent<Part>();

if (a != null)
{
d = hit.distance;
return true;
if (a.Modules.Contains("ModuleAsteroid"))
{
d = hit.distance;
return true;
}
}
hitT = hitT.parent;
i++;
}
}
else if (hit.collider.gameObject.layer == 15)
return true;
}
return false;
}
Expand Down
36 changes: 33 additions & 3 deletions Source/Part Modules/DMSoilMoisture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class DMSoilMoisture: DMModuleScienceAnimate, IScalarModule
public bool allowTransmission = true;
[KSPField(guiActive = true, guiName = "Science Transmission")]
public string scienceTransmission = "Enabled";
[KSPField]
public bool noScience = false;
[KSPField]
public bool noAntenna = false;

private bool fullyDeployed = false;
private bool rotating = false;
Expand Down Expand Up @@ -71,8 +75,22 @@ public override void OnStart(PartModule.StartState state)
scalar = 1;
}

Fields["scienceTransmission"].guiActive = !noAntenna;
Events["ToggleScienceTransmission"].active = !noAntenna;
Events["ToggleScienceTransmission"].guiName = allowTransmission ? "Disable Science Transmission" : "Enable Science Transmission";
scienceTransmission = allowTransmission ? "Enabled" : "Disabled";
scienceTransmission = allowTransmission && !noAntenna ? "Enabled" : "Disabled";

if (noScience)
{
Actions["DeployAction"].active = false;
Events["CollectDataExternalEvent"].active = false;
Events["ResetExperimentExternal"].active = false;
Events["ResetExperiment"].active = false;
Events["DeployExperiment"].active = false;
Events["TransferDataEvent"].active = false;
Events["CleanUpExperimentExternal"].active = false;
Deployed = true;
}

if (anim != null && anim[animationName] != null)
scalarStep = 1 / anim[animationName].length;
Expand All @@ -84,6 +102,18 @@ protected override void Update()

if (HighLogic.LoadedSceneIsFlight)
{
if (noScience)
{
Events["CollectDataExternalEvent"].active = false;
Events["ResetExperimentExternal"].active = false;
Events["ResetExperiment"].active = false;
Events["DeployExperiment"].active = false;
Events["DeployExperimentExternal"].active = false;
Events["TransferDataEvent"].active = false;
Events["CleanUpExperimentExternal"].active = false;
Deployed = true;
}

if (IsDeployed && fullyDeployed)
{
rotating = true;
Expand Down Expand Up @@ -190,7 +220,7 @@ public bool CanMove
{
get
{
if (!allowTransmission)
if (!allowTransmission || noAntenna)
return false;

if (anim.IsPlaying(animationName))
Expand All @@ -210,7 +240,7 @@ public float GetScalar
{
get
{
if (!allowTransmission)
if (!allowTransmission || noAntenna)
return 0;

return scalar;
Expand Down
30 changes: 12 additions & 18 deletions Source/Part Modules/DMXRayDiffract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,26 @@ private bool drillImpact(bool b)
Vector3 p = t.position;
Ray r = new Ray(p, -1f * t.forward);
float scale = part.rescaleFactor * drillLength * modelTransform.localScale.y;
int layer = 32769;

Physics.Raycast(r, out hit, drillLength * scale);
Physics.Raycast(r, out hit, drillLength * scale, layer);
if (hit.collider != null)
{
if (b)
{
Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent<Part>();

if (a != null)
if (hit.collider.gameObject.layer == 0)
{
if (a.Modules.Contains("ModuleAsteroid"))
return true;
}
}
else
{
Transform hitT = hit.collider.transform;
int i = 0; //Just to prevent this from getting stuck in a loop
while (hitT != null && i < 200)
{
if (hitT == vessel.mainBody.bodyTransform)
return true;
hitT = hitT.parent;
i++;
Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent<Part>();

if (a != null)
{
if (a.Modules.Contains("ModuleAsteroid"))
return true;
}
}
}
else if (hit.collider.gameObject.layer == 15)
return true;
}
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5428988e-53a6-4d8e-8af4-014572513e22")]

[assembly: AssemblyVersion("1.3.0.9")]
[assembly: AssemblyFileVersion("1.3.0.9")]
[assembly: AssemblyInformationalVersion("v1.3.9")]
[assembly: AssemblyVersion("1.3.0.10")]
[assembly: AssemblyFileVersion("1.3.0.10")]
[assembly: AssemblyInformationalVersion("v1.3.10")]
[assembly: KSPAssembly("DMagic", 1, 4)]

0 comments on commit 6e8b989

Please sign in to comment.