-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathModuleTCA.cs
707 lines (641 loc) · 24.7 KB
/
ModuleTCA.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
// Author:
// Allis Tauri <allista@gmail.com>
//
// Copyright (c) 2015 Allis Tauri
//
// This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
// or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using AT_Utils;
using CommNet;
using AT_Utils.UI;
using JetBrains.Annotations;
namespace ThrottleControlledAvionics
{
public class ModuleTCA : PartModule, ITCAComponent, IModuleInfo, ICommNetControlSource
{
internal static Globals GLB { get { return Globals.Instance; } }
public VesselWrapper VSL { get; private set; }
public VesselConfig CFG { get; set; }
public TCAState State { get { return VSL.State; } set { VSL.State = value; } }
public void SetState(TCAState state) { VSL.State |= state; }
public bool IsStateSet(TCAState state) { return Available && VSL.IsStateSet(state); }
#region Modules
//core modules
public EngineOptimizer ENG;
public RCSOptimizer RCS;
public static List<FieldInfo> CoreModuleFields = typeof(ModuleTCA)
.GetFields(BindingFlags.Public | BindingFlags.Instance)
.Where(fi => fi.FieldType.IsSubclassOf(typeof(TCAModule))).ToList();
//optional modules
public Dictionary<Type, TCAModule> ModulesDB = new Dictionary<Type, TCAModule>();
public List<TCAModule> AllModules = new List<TCAModule>();
public List<TCAModule> ModulePipeline = new List<TCAModule>();
public List<TCAModule> AutopilotPipeline = new List<TCAModule>();
public bool ProfileSyncAllowed { get; private set; } = true;
[KSPField(guiActive = true, guiActiveEditor = true, guiName = "TCA Active")]
public bool TCA_Active;
[KSPField(isPersistant = true)]
public string GID = "";
static string new_GID() => Guid.NewGuid().ToString("N");
[KSPField(guiActive = true, guiActiveEditor = true, guiName = "TCA Group")]
public string GID_Display = "";
[KSPField(isPersistant = true)] public bool GroupMaster;
public M GetModule<M>() where M : TCAModule
{
TCAModule module = null;
return ModulesDB.TryGetValue(typeof(M), out module) ? module as M : null;
}
public TCAModule GetModule(Type T)
{
TCAModule module = null;
return ModulesDB.TryGetValue(T, out module) ? module : null;
}
public object CreateComponent(Type T)
{
var constructor = T.GetConstructor(new[] { typeof(ModuleTCA) });
if(constructor == null)
throw new MissingMemberException(string.Format("No suitable constructor found for {0}", T.Name));
return constructor.Invoke(new[] { this });
}
public List<T> CreateComponents<T>(IList<FieldInfo> fields, object obj = null)
where T : TCAComponent
{
var components = new List<T>();
foreach(var fi in fields)
{
var component = CreateComponent(fi.FieldType) as T;
if(component != null) components.Add(component);
if(obj != null) fi.SetValue(obj, component);
}
return components;
}
public static void SetTCAField(object obj, ModuleTCA tca)
{
var tca_fi = obj.GetType().GetField("TCA");
if(tca_fi != null && tca_fi.FieldType == typeof(ModuleTCA))
tca_fi.SetValue(obj, tca);
}
public void SetTCAField(object obj) => SetTCAField(obj, this);
public void InitModuleFields(object obj)
{
var ModuleFields = TCAModulesDatabase.GetAllModuleFields(obj.GetType());
ModuleFields.ForEach(fi => fi.SetValue(obj, GetModule(fi.FieldType)));
}
public static void ResetModuleFields(object obj)
{
var ModuleFields = TCAModulesDatabase.GetAllModuleFields(obj.GetType());
ModuleFields.ForEach(fi => fi.SetValue(obj, null));
}
public void SquadAction(Action<ModuleTCA> action)
{
var SQD = GetModule<SquadControl>();
if(SQD == null) action(this);
else SQD.Apply(action);
}
public void SquadConfigAction(Action<VesselConfig> action)
{
var SQD = GetModule<SquadControl>();
if(SQD == null) action(CFG);
else SQD.ApplyCFG(action);
}
#endregion
#region Public Info
public bool Available => TCA_Active && VSL != null;
public bool Valid => vessel != null && part != null && Available;
public bool IsControllable =>
Valid
&& (vessel.CurrentControlLevel == Vessel.ControlLevel.FULL
|| vessel.CurrentControlLevel == Vessel.ControlLevel.PARTIAL_MANNED);
#endregion
#region Initialization
public void OnReloadGlobals()
{
AllModules.ForEach(m => m.Cleanup());
VSL.Reset();
VSL.Init();
AllModules.ForEach(m => m.Init());
VSL.ConnectAutopilotOutput();
}
public override string ToString()
{
return string.Format("{0} GID: {1}, Master: {2}, Active: {3}",
this.GetID(), GID, GroupMaster, TCA_Active);
}
public override string GetInfo() => "Software can be installed";
internal const string TCA_NAME = "TCA";
public string GetModuleTitle() => TCA_NAME;
public string GetPrimaryField() => "<b>TCA:</b> " + TCAScenario.ModuleStatusString();
public Callback<Rect> GetDrawModulePanelCallback() { return null; }
public override void OnAwake()
{
base.OnAwake();
GameEvents.onVesselWasModified.Add(onVesselModify);
GameEvents.onStageActivate.Add(onStageActive);
GameEvents.onVesselGoOffRails.Add(onVesselGoOffRails);
}
internal void OnDestroy()
{
if(vessel != null && vessel.connection != null)
vessel.connection.UnregisterCommandSource(this);
GameEvents.CommNet.OnNetworkInitialized.Remove(OnNetworkInitialised);
GameEvents.onVesselWasModified.Remove(onVesselModify);
GameEvents.onStageActivate.Remove(onStageActive);
GameEvents.onVesselGoOffRails.Remove(onVesselGoOffRails);
reset();
}
public override void OnSave(ConfigNode node)
{
if(GroupMaster && CFG != null)
{
SaveToConfig();
CFG.SaveInto(node);
//this.Log("OnSave: GroupMaster: {}", this);//debug
}
base.OnSave(node);
}
public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
var SavedCFG = node.GetNode(VesselConfig.NODE_NAME);
if(SavedCFG != null)
{
CFG = ConfigNodeObject.FromConfig<VesselConfig>(SavedCFG);
GroupMaster = true;
//this.Log("OnLoad: GroupMaster: {}", this);//debug
}
if(!string.IsNullOrEmpty(GID))
SetGID(GID);
//deprecated config conversion
enabled = isEnabled = true;
}
public override void OnStart(StartState state)
{
base.OnStart(state);
EnableTCA(false);
if(state == StartState.None || !TCAScenario.HasTCA)
return;
if(vessel != null)
activate_master_TCA(vessel);
else if(string.IsNullOrEmpty(GID))
SetGID(new_GID());
if(state != StartState.Editor)
StartCoroutine(delayed_init());
}
void onVesselGoOffRails(Vessel vsl)
{
if(vsl != vessel) return;
if(vessel.situation == Vessel.Situations.PRELAUNCH)
{
if(VSL != null && CFG != null &&
CFG.ActiveProfile != null &&
CFG.ActiveProfile.HasActiveEngines)
{
vessel.ctrlState.mainThrottle = 0;
if(VSL.IsActiveVessel)
FlightInputHandler.state.mainThrottle = 0;
}
}
}
void onVesselModify(Vessel vsl)
{
if(vsl == null || vsl != vessel) return;
//this.Log("onVesselModify: vsl.id {}, old.id {}", vsl.id,
//VSL != null && VSL.vessel != null? VSL.vessel.id.ToString() : "null");//debug
AllModules.ForEach(m => m.SaveToConfig());
activate_master_TCA(vessel);
if(GroupMaster)
ChangeGID();
if(!TCA_Active) reset();
else if(VSL == null || VSL.vessel == null || vsl.id != VSL.vessel.id)
{
reset();
if(CFG != null)
CFG = CFG.Clone<VesselConfig>();
init();
}
else
{
VSL.Engines.ForceUpdateParts = true;
StartCoroutine(updateUnpackDistance());
}
}
void onStageActive(int stage)
{
if(VSL == null || !CFG.Enabled || !VSL.IsActiveVessel) return;
if(!CFG.EnginesProfiles.ActivateOnStage(stage, VSL.Engines.All))
StartCoroutine(activeProfileUpdate());
}
IEnumerator<YieldInstruction> delayed_init()
{
if(vessel == null) yield break;
if(!vessel.loaded) yield return null;
yield return new WaitForSeconds(0.5f);
init();
}
IEnumerator<YieldInstruction> activeProfileUpdate()
{
ProfileSyncAllowed = false;
yield return new WaitForSeconds(0.5f);
if(TCA_Active)
{
VSL.UpdateParts();
CFG.ActiveProfile.Update(VSL.Engines.All, true);
}
ProfileSyncAllowed = true;
}
IEnumerator<YieldInstruction> updateUnpackDistance()
{
if(!CFG.Enabled) yield break;
yield return new WaitForSeconds(0.5f);
if(VSL != null)
VSL.SetUnpackDistance(GLB.UnpackDistance);
}
[UsedImplicitly]
[KSPAction("Update TCA Profile")]
private void onActionUpdate(KSPActionParam param) { StartCoroutine(activeProfileUpdate()); }
/// <summary>
/// It is a component message handler.
/// The "DisableAttitudeControl" message is sent from CargoAccelerators mod when
/// its own attitude control is enabled.
/// </summary>
[UsedImplicitly]
private void DisableAttitudeControl(object value)
{
if(value.Equals(this))
return;
if(!Valid)
return;
CFG.AT.XOff();
CFG.BR.XOff();
}
/// <summary>
/// It is a component message handler.
/// The "ExecuteManeuverNode" message is sent from CargoAccelerators mod when
/// it adds a correction node that should be executed immediately.
/// </summary>
[UsedImplicitly]
private void ExecuteManeuverNode(object value)
{
if(!Valid)
return;
if(GetModule<ManeuverAutopilot>() == null)
return;
if(value is ManeuverNode node)
{
Utils.ClearManeuverNodes(VSL.vessel);
if(vessel.patchedConicSolver != null)
Utils.AddNodeRaw(vessel, node.DeltaV, node.UT);
else
Utils.AddNodeRawToFlightPlanNode(vessel, node.DeltaV, node.UT);
}
CFG.AP1.XOn(Autopilot1.Maneuver);
}
[UsedImplicitly]
[KSPEvent(guiActive = false, active = true)]
private void onLaunchedFromHangar(BaseEventDetails data)
{
if(!Valid)
return;
if(!data.GetBool("fromFairings"))
return;
var pm = data.Get<PartModule>("hangar");
if(pm == null || pm.vessel == null)
return;
var tca = AvailableTCA(pm.vessel);
if(tca == null)
return;
reset();
CFG = tca.CloneConfig();
init();
}
public void SetGID(string gid)
{
GID = gid;
GID_Display = gid.Substring(Math.Max(gid.Length - 6, 0));
}
public string ChangeGID()
{
var gid = new_GID();
var group = GetGroup();
if(group != null)
group.ForEach(tca => tca.SetGID(gid));
else
SetGID(gid);
//this.Log("change group: {}, {}", GID, GetGroup());//debug
return gid;
}
ModuleTCA select_group_master(List<ModuleTCA> all_tca)
{
var master = all_tca.FirstOrDefault(tca => tca.GID == GID);
GroupMaster = master == this;
//this.Log("select group master: {}, {}", master, GroupMaster);//debug
return master;
}
void activate_master_TCA(IShipconstruct ship)
{
EnableTCA(false);
var all_tca = AllTCA(ship);
if(string.IsNullOrEmpty(GID))
{
var other = all_tca.FirstOrDefault(tca => !string.IsNullOrEmpty(tca.GID));
SetGID(other != null ? other.GID : new_GID());
//this.Log("init group: {}", GID);//debug
}
var masters = new Dictionary<string, ModuleTCA>();
foreach(var tca in all_tca.Where(tca => tca.GroupMaster))
{
ModuleTCA m;
if(masters.TryGetValue(tca.GID, out m))
{
this.Log("WARNING: found another TCA instance {} that claims to be the master of {}",
tca.GetID(), m.GID);
m.GroupMaster = false;
}
else
masters[tca.GID] = tca;
}
if(!masters.ContainsKey(GID))
{
var master = select_group_master(all_tca);
if(master != null)
masters[GID] = master;
}
if(GroupMaster)
EnableTCA(masters.Count == 1 ||
masters.Values.SelectMax(m =>
{
try { return -m.part.Modules.IndexOf(m) - ship.Parts.IndexOf(m.part) * 1000; }
catch(NullReferenceException) { return float.NegativeInfinity; }
}) == this);
//this.Log("TCA Active: {}, GroupMaster {}, masters {}, top master {}",
//TCA_Active, GroupMaster, masters,
//masters.Values.SelectMax(m => -m.part.Modules.IndexOf(m) - ship.Parts.IndexOf(m.part) * 1000));//debug
}
public void EnableTCA(bool enable = true)
{
TCA_Active = enable;
Actions["ToggleTCA"].active = enable;
Actions["onActionUpdate"].active = enable;
//this.Log("TCA Module enabled: {}", enable);//debug
}
public void DeleteModules()
{
ModulesDB.Clear();
AllModules.Clear();
ModulePipeline.Clear();
AutopilotPipeline.Clear();
foreach(var core_field in CoreModuleFields)
core_field.SetValue(this, null);
}
public static List<ModuleTCA> AllTCA(IShipconstruct ship)
{
//get all ModuleTCA instances in the vessel
var TCA_Modules = new List<ModuleTCA>();
if(ship.Parts != null)
{
(from p in ship.Parts
where p.Modules != null
select p.Modules.GetModules<ModuleTCA>())
.ForEach(TCA_Modules.AddRange);
}
return TCA_Modules;
}
public static ModuleTCA AvailableTCA(IShipconstruct ship)
{
ModuleTCA tca = null;
for(int i = 0, shipPartsCount = ship.Parts.Count; i < shipPartsCount; i++)
{
tca = ship.Parts[i].Modules
.GetModules<ModuleTCA>()
.FirstOrDefault(m => m.Available);
if(tca != null) break;
}
return tca;
}
public static ModuleTCA EnabledTCA(IShipconstruct ship)
{
var tca = AvailableTCA(ship);
return tca != null && tca.CFG != null && tca.CFG.Enabled ? tca : null;
}
public List<ModuleTCA> GetGroup() =>
vessel != null ? AllTCA(vessel).Where(tca => tca.GID == GID).ToList() : null;
public void SaveToConfig() => AllModules.ForEach(m => m.SaveToConfig());
public VesselConfig CloneConfig()
{
var tca = this;
if(!TCA_Active)
tca = AvailableTCA(vessel);
if(tca == null)
return null;
tca.SaveToConfig();
return tca.CFG.Clone<VesselConfig>();
}
void updateCFG()
{
var group = GetGroup();
var master = group.FirstOrDefault(tca => tca.GroupMaster);
if(this == master)
{
if(CFG == null)
CFG = new VesselConfig();
group.ForEach(tca => tca.CFG = CFG);
}
}
void init()
{
if(!TCA_Active) return;
updateCFG();
VSL = new VesselWrapper(this);
EnableTCA(VSL.Engines.All.Count > 0 ||
VSL.Engines.RCS.Count > 0 ||
VSL.Torque.Wheels.Count > 0);
if(!TCA_Active) { VSL = null; return; }
VSL.Init();
TCAModulesDatabase.InitModules(this);
VSL.ConnectAutopilotOutput();//should follow module initialization
vessel.OnPreAutopilotUpdate += OnPreAutopilotUpdate;
vessel.OnPostAutopilotUpdate += OnPostAutopilotUpdate;
TCAGui.Reinitialize(this);
StartCoroutine(updateUnpackDistance());
Actions["onActionUpdate"].active = true;
Actions["ToggleTCA"].actionGroup = CFG.ActionGroup;
CFG.Resume(this);
}
void reset()
{
if(VSL != null)
{
vessel.OnPreAutopilotUpdate -= OnPreAutopilotUpdate;
vessel.OnPostAutopilotUpdate -= OnPostAutopilotUpdate;
VSL.Reset();
AllModules.ForEach(m => m.Cleanup());
CFG.ClearCallbacks();
}
DeleteModules();
VSL = null;
}
#endregion
#region Controls
[KSPAction("Toggle TCA")]
public void ToggleTCA(KSPActionParam param = null)
{
CFG.Enabled = !CFG.Enabled;
if(CFG.Enabled)
CFG.ActiveProfile.Update(VSL.Engines.All, true);
AllModules.ForEach(m => m.OnEnableTCA(CFG.Enabled));
VSL.OnEnableTCA(CFG.Enabled);
}
[KSPEvent(guiName = "Activate TCA", guiActive = true, active = true)]
public void ActivateTCA()
{
if(TCA_Active) return;
var all_tca = AllTCA(vessel);
all_tca.ForEach(tca =>
{
if(tca.TCA_Active)
tca.SaveToConfig();
tca.EnableTCA(false);
tca.reset();
});
if(!GroupMaster)
{
all_tca
.Where(tca => tca.GID == GID)
.ForEach(tca => tca.GroupMaster = false);
GroupMaster = true;
}
EnableTCA(true);
init();
ShowGroup();
}
[KSPEvent(guiName = "Show TCA Group", guiActive = true, active = true)]
public void ShowGroup()
{
var group = GetGroup();
group.ForEach(m => m.part.HighlightAlways(m.TCA_Active ?
Colors.Enabled :
(m.GroupMaster ?
Colors.Selected2 :
Colors.Selected1)));
StartCoroutine(CallbackUtil.DelayedCallback(3.0f, () => group.ForEach(m =>
{
if(m != null && m.part != null)
m.part.SetHighlightDefault();
})));
}
#endregion
#region ICommNetControlSource
public void UpdateNetwork() { }
VesselControlState localControlState;
public VesselControlState GetControlSourceState() { return localControlState; }
public bool IsCommCapable() { return false; }
//this code adapted from the ModuleCommand
//why not do it in OnStart?
public virtual void Start()
{
if(HighLogic.LoadedSceneIsGame && !HighLogic.LoadedSceneIsEditor &&
HighLogic.LoadedScene != GameScenes.SPACECENTER)
{
if(CommNetNetwork.Initialized)
{ if(vessel.Connection != null) OnNetworkInitialised(); }
GameEvents.CommNet.OnNetworkInitialized.Add(OnNetworkInitialised);
}
}
protected virtual void OnNetworkInitialised()
{ vessel.connection.RegisterCommandSource(this); }
#endregion
void ClearFrameState()
{
VSL.ClearFrameState();
AllModules.ForEach(m => m.ClearFrameState());
#if DEBUG
if(VSL.IsActiveVessel) TCAGui.ClearDebugMessage();
#endif
}
void Update() //works both in Editor and in flight
{
if(!TCA_Active) return;
if(CFG != null)
CFG.ActionGroup = Actions["ToggleTCA"].actionGroup;
}
public override void OnUpdate()
{
if(Valid && CFG.Enabled)
{
//update heavy to compute parameters
VSL.Geometry.Update();
var ATC = GetModule<AttitudeControl>();
if(ATC != null) ATC.UpdateCues();
}
}
public void OnPreAutopilotUpdate(FlightCtrlState s)
{
if(!Valid) return;
//initialize systems
VSL.PreUpdateState(s);
State = TCAState.Disabled;
if(CFG.Enabled)
{
State = TCAState.Enabled;
localControlState = VesselControlState.None;
if(!VSL.Info.ElectricChargeAvailible)
{
if(VSL.Controls.WarpToTime > 0)
VSL.Controls.AbortWarp();
return;
}
localControlState = VesselControlState.ProbePartial;
SetState(TCAState.HaveEC);
ClearFrameState();
//update VSL
VSL.UpdatePhysics();
if(VSL.Engines.Check()) SetState(TCAState.HaveActiveEngines);
Actions["onActionUpdate"].actionGroup = VSL.Engines.ActionGroups;
VSL.UpdateEngines();
//update modules
ModulePipeline.ForEach(m => m.OnFixedUpdate());
VSL.OnModulesUpdated();
}
}
public void OnPostAutopilotUpdate(FlightCtrlState s)
{
if(!Valid || !CFG.Enabled) return;
//handle engines
VSL.PostUpdateState(s);
VSL.Engines.Tune();
if(VSL.Engines.NumActive > 0)
{
//:preset manual limits for translation if needed
var translation = VSL.Controls.EnginesTranslation;
if(VSL.Controls.HasTranslation)
translation += VSL.Controls.Translation;
if(!translation.IsZero())
{
EngineOptimizer.PresetLimitsForTranslation(VSL.Engines.Active.Maneuver, translation.normalized);
if(CFG.VSCIsActive && !VSL.Controls.HasTranslation)
EngineOptimizer.LimitInDirection(VSL.Engines.Active.Maneuver, VSL.Physics.UpL);
}
ENG.Steer();
}
RCS.Steer();
VSL.Engines.SetControls();
VSL.FinalUpdate();
}
void FixedUpdate()
{
if(Valid &&
TimeWarp.CurrentRate > 1 &&
TimeWarp.WarpMode == TimeWarp.Modes.HIGH)
{
OnPreAutopilotUpdate(vessel.ctrlState);
OnPostAutopilotUpdate(vessel.ctrlState);
}
}
}
}