Skip to content

Commit

Permalink
Merge pull request #45 from ZiwKerman/v1.0-beta-legacyIR-binding
Browse files Browse the repository at this point in the history
Fixing Revert to Hangar Bug and keys for multiple sequences
  • Loading branch information
ZiwKerman committed Mar 3, 2016
2 parents fd22c48 + b32538f commit 5fefd21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion IRSequencer/IRSequencer/Gui/SequencerGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void OnEditorShipModified(ShipConstruct ship)
{
var seqModule = sequencerParts[i].FindModuleImplementing<ModuleSequencer>();
sequencers.Add(seqModule);
seqModule.LoadData ();
seqModule.loadPending = true;
}

}
Expand Down
25 changes: 18 additions & 7 deletions IRSequencer/IRSequencer/Module/ModuleSequencer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ModuleSequencer : PartModule
private float lastKeyPressedTime = 0f;
private const float keyCooldown = 0.2f;

private bool loadPending = false;
internal bool loadPending = false;
private float lastSavedUT = 0f;

public SequencerState currentState;
Expand Down Expand Up @@ -187,7 +187,7 @@ public bool TryParseState(string s, out SequencerState st)
{
if (s == "" || !s.Contains(":"))
{
Logger.Log("TryParseSequence, invalid format s=" + s, Logger.Level.Debug);
Logger.Log("TryParseState, invalid format s=" + s, Logger.Level.Debug);
st = null;
return false;
}
Expand Down Expand Up @@ -403,6 +403,8 @@ protected void CheckInputs()
if (sequences == null)
return;


bool keyTriggered = false;
for(int i=0; i<sequences.Count; i++)
{
var s = sequences [i];
Expand All @@ -415,10 +417,13 @@ protected void CheckInputs()
else
s.Start (currentState);

lastKeyPressedTime = Time.time;
keyTriggered = true;
}
}
}

if (keyTriggered)
lastKeyPressedTime = Time.time;
}

public void Update()
Expand Down Expand Up @@ -726,22 +731,28 @@ public void OnStateChange(SequencerState oldState, SequencerState newState)

}

public override void OnLoad(ConfigNode config)
public override void OnLoad(ConfigNode node)
{
base.OnLoad (config);
base.OnLoad (node);

//LoadData ();
//to ensure everything loads properly load data on the next FixedUpdate.
loadPending = true;
}

public override void OnSave(ConfigNode node)
/*public override void OnSave(ConfigNode node)
{
base.OnSave(node);
SaveData ();
}
}*/

public override void OnInitialize ()
{
base.OnInitialize ();

loadPending = true;
}

public override string GetInfo()
{
Expand Down

0 comments on commit 5fefd21

Please sign in to comment.