-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
352 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@PART[*]:HAS[@MODULE[ModuleDockingNode],!MODULE[ModuleAsteroid],!MODULE[ModuleComet],!MODULE[KerbalEVA]]:NEEDS[KSPRECALL-STAYINGTOGETHER] | ||
{ | ||
%MODULE[LetsStayTogether] | ||
{ | ||
active = True | ||
} | ||
} |
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
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,113 @@ | ||
/* | ||
This file is part of LetsStayTogether, a component of KSP-Recall | ||
(C) 2020-2021 Lisias T : http://lisias.net <support@lisias.net> | ||
KSP-Recall is double licensed, as follows: | ||
* SKL 1.0 : https://ksp.lisias.net/SKL-1_0.txt | ||
* GPL 2.0 : https://www.gnu.org/licenses/gpl-2.0.txt | ||
And you are allowed to choose the License that better suit your needs. | ||
KSP-Recall is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
You should have received a copy of the SKL Standard License 1.0 | ||
along with KSP-Recall. If not, see <https://ksp.lisias.net/SKL-1_0.txt>. | ||
You should have received a copy of the GNU General Public License 2.0 | ||
along with KSP-Recall. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace KSP_Recall { namespace StayingTogether | ||
|
||
{ | ||
[KSPAddon(KSPAddon.Startup.Flight, false)] | ||
public class FlightHelper : MonoBehaviour | ||
{ | ||
private readonly FlightKscTrackingHelper helper = new FlightKscTrackingHelper(); | ||
private void Awake() { this.helper.Awake(); } | ||
private void OnDestroy() { this.helper.OnDestroy(); } | ||
} | ||
|
||
[KSPAddon(KSPAddon.Startup.SpaceCentre, false)] | ||
public class SpaceCentreHelper : MonoBehaviour | ||
{ | ||
private readonly FlightKscTrackingHelper helper = new FlightKscTrackingHelper(); | ||
private void Awake() { this.helper.Awake(); } | ||
private void OnDestroy() { this.helper.OnDestroy(); } | ||
} | ||
|
||
[KSPAddon(KSPAddon.Startup.TrackingStation, false)] | ||
public class TrackingStationHelper : MonoBehaviour | ||
{ | ||
private readonly FlightKscTrackingHelper helper = new FlightKscTrackingHelper(); | ||
private void Awake() { this.helper.Awake(); } | ||
private void OnDestroy() { this.helper.OnDestroy(); } | ||
} | ||
|
||
internal class FlightKscTrackingHelper | ||
{ | ||
#region Unity Life Cycle | ||
|
||
internal void Awake() | ||
{ | ||
Log.dbg("Awake on {0}", HighLogic.LoadedScene); | ||
if (Globals.Instance.Refunding) | ||
{ | ||
GameEvents.onVesselGoOnRails.Add(OnVesselGoOnRails); | ||
GameEvents.onVesselGoOffRails.Add(OnVesselGoOffRails); | ||
} | ||
} | ||
|
||
internal void OnDestroy() | ||
{ | ||
Log.dbg("OnDestroy"); | ||
if (Globals.Instance.Refunding) | ||
{ | ||
GameEvents.onVesselGoOffRails.Add(OnVesselGoOffRails); | ||
GameEvents.onVesselGoOnRails.Remove(OnVesselGoOnRails); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Events Handlers | ||
|
||
private void OnVesselGoOnRails(Vessel vessel) | ||
{ | ||
Log.dbg("OnVesselGo ON Rails {0}", vessel.vesselName); | ||
this.ImmediateUpdate(vessel); | ||
} | ||
|
||
// Continuing from the the OnRails stunt, when the vessel is unpacked we need to remove the Resource from | ||
// the stackable parts, so they could be stackable again. | ||
// | ||
// Since vessels are recovered while flying or while packed, I think this stunt my stick... | ||
private void OnVesselGoOffRails(Vessel vessel) | ||
{ | ||
Log.dbg("OnVesselGo OFF Rails {0}", vessel.vesselName); | ||
this.ImediateRestore(vessel); | ||
} | ||
|
||
#endregion | ||
|
||
private void ImmediateUpdate(Vessel vessel) | ||
{ | ||
foreach (Part p in vessel.Parts) if (p.Modules.Contains<LetsStayTogether>()) | ||
p.Modules.GetModule<LetsStayTogether>().SynchronousUpdate(); | ||
} | ||
|
||
private void ImediateRestore(Vessel vessel) | ||
{ | ||
foreach (Part p in vessel.Parts) if (p.Modules.Contains<LetsStayTogether>()) | ||
p.Modules.GetModule<LetsStayTogether>().SynchronousRestore(); | ||
} | ||
private static KSPe.Util.Log.Logger Log = KSPe.Util.Log.Logger.CreateForType<FlightHelper>("KSP-Recall", "StayingTogether-FlightHelper"); | ||
} | ||
} } |
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,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{ABE56F6A-AB8A-498B-8968-B6FB61EBC1D3}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>LetsStayTogether</RootNamespace> | ||
<AssemblyName>LetsStayTogether</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<BaseIntermediateOutputPath>..\..\obj\$(AssemblyName)</BaseIntermediateOutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\..\bin\Debug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>..\..\bin\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="KSPe.Light.Recall"> | ||
<HintPath>..\..\..\..\..\..\..\..\..\..\Users\lisias\Workspaces\KSP\LIB\plugins\KSPe.Light.Recall.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\..\..\..\..\..\..\..\..\Users\lisias\Workspaces\KSP\LIB\managed\1.4.1\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\..\..\..\..\..\..\..\..\..\Users\lisias\Workspaces\KSP\LIB\managed\1.4.1\UnityEngine.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="FlightHelper.cs" /> | ||
<Compile Include="PartModule.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\KSP-Recall\KSP-Recall.csproj"> | ||
<Project>{40E7A5F2-C30E-43E9-B345-51971959149F}</Project> | ||
<Name>KSP-Recall</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
Oops, something went wrong.