-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support RemoteTech Antennas in Automation (#119)
* Support RemoteTech antennas in Automation * Added support for unloaded vessel * Undo changes to Kerbalism.csproj
- Loading branch information
1 parent
b40acc3
commit 3363174
Showing
4 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using KSP.Localization; | ||
|
||
|
||
namespace KERBALISM | ||
{ | ||
|
||
public sealed class RemoteTechAntennaDevice : Device | ||
{ | ||
public RemoteTechAntennaDevice(PartModule antenna) | ||
{ | ||
this.antenna = antenna; | ||
} | ||
|
||
public override string Name() | ||
{ | ||
return "antenna"; | ||
} | ||
|
||
public override uint Part() | ||
{ | ||
return antenna.part.flightID; | ||
} | ||
|
||
public override string Info() | ||
{ | ||
return Lib.ReflectionValue<bool>(antenna, "IsRTActive") | ||
? "<color=cyan>" + Localizer.Format("#KERBALISM_Generic_ACTIVE") + "</color>" | ||
: "<color=red>" + Localizer.Format("#KERBALISM_Generic_INACTIVE") + "</color>"; | ||
} | ||
|
||
public override void Ctrl(bool value) | ||
{ | ||
Lib.ReflectionValue(antenna, "IsRTActive", value); | ||
} | ||
|
||
public override void Toggle() | ||
{ | ||
Ctrl(!Lib.ReflectionValue<bool>(antenna, "IsRTActive")); | ||
} | ||
|
||
PartModule antenna; | ||
} | ||
|
||
public sealed class ProtoRemoteTechAntennaDevice : Device | ||
{ | ||
public ProtoRemoteTechAntennaDevice(ProtoPartModuleSnapshot antenna, PartModule module_prefab, Vessel v, uint part_id) | ||
{ | ||
this.antenna = antenna; | ||
this.module_prefab = module_prefab; | ||
this.vessel = v; | ||
this.part_id = part_id; | ||
} | ||
|
||
public override string Name() | ||
{ | ||
return "antenna"; | ||
} | ||
|
||
public override uint Part() | ||
{ | ||
return part_id; | ||
} | ||
|
||
public override string Info() | ||
{ | ||
return Lib.Proto.GetBool(antenna, "IsRTActive") | ||
? "<color=cyan>" + Localizer.Format("#KERBALISM_Generic_ACTIVE") + "</color>" | ||
: "<color=red>" + Localizer.Format("#KERBALISM_Generic_INACTIVE") + "</color>"; | ||
} | ||
|
||
public override void Ctrl(bool value) | ||
{ | ||
Lib.Proto.Set(antenna, "IsRTActive", value); | ||
} | ||
|
||
public override void Toggle() | ||
{ | ||
Ctrl(!Lib.Proto.GetBool(antenna, "IsRTActive")); | ||
} | ||
|
||
private readonly ProtoPartModuleSnapshot antenna; | ||
private readonly PartModule module_prefab; | ||
private readonly Vessel vessel; | ||
private readonly uint part_id; | ||
} | ||
|
||
} // KERBALISM | ||
|