Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
Fixed editor nullref for combo engine/RW parts
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Apr 21, 2015
1 parent 32f78c0 commit c0d2cdd
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 89 deletions.
57 changes: 0 additions & 57 deletions GameData/RW Saturatable/RW.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,6 @@
key = 1 0.025 0 0
}

torqueCurve
{
key = 0 1 -1 -1
key = 1 0 -1 -1
}
}
}

+PART[sasModule]:AFTER[RWSaturatable]
{
@name = sasModule1
@title = Lightweight RW
@mass *= 0.6
@description = A lightweight RW with low momentum capacity but a very high bleed rate and consistent early torque output. Beware the sudden torque decay
@MODULE[RWSaturatable]
{
@saturationScale = 3
!bleedRate,* {}
bleedRate
{
key = 0 0.1 0 0
key = 0 0.1 0 0
}
!torqueCurve,* {}
torqueCurve
{
key = 0 1 0 0
key = 0.66 1 0 -3
key = 1 0 -3 0
}
}
}

+PART[sasModule]:AFTER[RWSaturatable]
{
@name = sasModule2
@title = Heavyweight RW
@mass *= 1.5
@description = A heavy RW with high momentum capacity and increased torque, but has a very slow momentum decay and draws a lot of EC
@MODULE[RWSaturatable]
{
@PitchTorque *= 1.5
@YawTorque *= 1.5
@RollTorque *= 1.5
@RESOURCE
{
@rate *= 3
}

@saturationScale = 20
!bleedRate,* {}
bleedRate
{
key = 0 0.01 0 0
key = 0 0.01 0 0
}
!torqueCurve,* {}
torqueCurve
{
key = 0 1 -1 -1
Expand Down
Binary file modified GameData/RW Saturatable/SaturatableRW.dll
Binary file not shown.
Binary file removed RW SAturatable v1.6.zip
Binary file not shown.
43 changes: 24 additions & 19 deletions SaturatableRW/RWSaturatable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,22 @@ public void ToggleWindow()
public override void OnAwake()
{
base.OnAwake();
// I need a better way to make this module work at any time
this.part.force_activate();

// Float curve initialisation
if (torqueCurve == null)
torqueCurve = new FloatCurve();
if (bleedRate == null)
bleedRate = new FloatCurve();

// I need a better way to make this module work at any time
if (HighLogic.LoadedSceneIsFlight)
this.part.force_activate();
}

public void OnDestroy()
{
if (HighLogic.LoadedSceneIsFlight && Window.Instance != null)
Window.Instance.wheelsToDraw.Remove(this);
if (HighLogic.LoadedSceneIsFlight && Window.Instance != null && Window.Instance.Vessels.ContainsKey(vessel.vesselName))
Window.Instance.Vessels.Remove(vessel.vesselName);
}

public override void OnStart(StartState state)
Expand All @@ -131,18 +133,7 @@ public override void OnStart(StartState state)
saturationLimit = averageTorque * saturationScale;

LoadConfig();
////////////////////////////////////////////////////////////////////////////
/// logging worker /////////////////////////////////////////////////////////
if (config.GetValue("LogDump", false))
StartCoroutine(loggingRoutine());
if (!config.GetValue("DefaultStateIsActive", true))
this.State = ModuleReactionWheel.WheelState.Disabled;

// save the file so it can be activated by anyone
config["LogDump"] = config.GetValue("LogDump", false);
config["DefaultStateIsActive"] = config.GetValue("DefaultStateIsActive", true);
config.save();


StartCoroutine(registerWheel());
}
}
Expand All @@ -151,14 +142,28 @@ IEnumerator registerWheel()
{
for (int i = 0; i < 10; i++)
yield return null;
Window.Instance.wheelsToDraw.Add(this);

if (!Window.Instance.Vessels.ContainsKey(vessel.vesselName))
Window.Instance.Vessels.Add(vessel.vesselName, new VesselInfo(vessel, this.State == WheelState.Active));

Window.Instance.Vessels[vessel.vesselName].wheels.Add(this);
}

public static void LoadConfig()
public void LoadConfig()
{
if (config == null)
config = KSP.IO.PluginConfiguration.CreateForType<RWSaturatable>();
config.load();

if (config.GetValue("LogDump", false))
StartCoroutine(loggingRoutine());
if (!config.GetValue("DefaultStateIsActive", true) && vessel.atmDensity > 0.001)
this.State = ModuleReactionWheel.WheelState.Disabled;

// save the file so it can be activated by anyone
config["LogDump"] = config.GetValue("LogDump", false);
config["DefaultStateIsActive"] = config.GetValue("DefaultStateIsActive", true);
config.save();
}

public override string GetInfo()
Expand Down Expand Up @@ -191,7 +196,7 @@ public override string GetInfo()
return info;
}

public override void OnFixedUpdate()
public void FixedUpdate()
{
base.OnFixedUpdate();

Expand Down
Loading

0 comments on commit c0d2cdd

Please sign in to comment.