-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from KSP2Community/dev
Version 0.10.0
- Loading branch information
Showing
13 changed files
with
215 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build the solution | ||
run: dotnet build "CommunityFixes.sln" -c Release | ||
|
||
- name: Find zip | ||
id: find-zip | ||
run: | | ||
echo "zip=$(ls -1 dist/CommunityFixes-*.zip | head -n 1)" >> $GITHUB_ENV | ||
echo "artifact_name=CommunityFixesRelease" >> $GITHUB_ENV | ||
- name: Upload zip artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.artifact_name }} | ||
path: ${{ env.zip }} |
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,28 @@ | ||
name: Upload release | ||
|
||
on: | ||
release: | ||
types: [ "published" ] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build the solution | ||
run: | | ||
dotnet build "CommunityFixes.sln" -c Release | ||
echo "zip=$(ls -1 dist/CommunityFixes-*.zip | head -n 1)" >> $GITHUB_ENV | ||
- name: Upload zip to release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ env.upload_url }} | ||
asset_path: ${{ env.zip }} | ||
asset_name: ${{ env.artifact_name }} | ||
asset_content_type: application/zip |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
name: Verify swinfo.json | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
verify: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Verify KSP2 Mod | ||
uses: Rexicon226/[email protected] |
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,5 @@ | ||
:missions #KSP2Mission_Secondary_Pol_Flag > missionStages > _0 > ConditionSet > PropertyCondition { | ||
isInput: false; | ||
Inputstring: ""; | ||
TestWatchedstring: "Pol"; | ||
} |
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
100 changes: 100 additions & 0 deletions
100
src/CommunityFixes/Fix/ExperimentBiomePauseFix/ExperimentBiomePauseFix.cs
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,100 @@ | ||
using HarmonyLib; | ||
using KSP.Game.Science; | ||
using KSP.Sim.impl; | ||
using KSP.Modules; | ||
using System.Reflection; | ||
|
||
namespace CommunityFixes.Fix.ExperimentBiomePauseFix; | ||
|
||
[Fix("Fix experiments pausing when switching biome for scenarios where biome is irrelevant")] | ||
public class ExperimentBiomePauseFix : BaseFix | ||
{ | ||
private static ExperimentBiomePauseFix _instance; | ||
|
||
// This fix makes assumptions about the game's code and reads/writes private state, which can end up in save files. | ||
// In order to avoid accidentally breaking anything, we only apply the patch to known-broken versions of the game. | ||
private static readonly HashSet<string> KnownBrokenVersions = new() { "0.2.0.0.30291" }; | ||
|
||
private static readonly string GameVersion = typeof(VersionID) | ||
.GetField("VERSION_TEXT", BindingFlags.Static | BindingFlags.Public) | ||
?.GetValue(null) as string; | ||
|
||
public override void OnInitialized() | ||
{ | ||
_instance = this; | ||
if (KnownBrokenVersions.Contains(GameVersion)) | ||
{ | ||
HarmonyInstance.PatchAll(typeof(ExperimentBiomePauseFix)); | ||
} | ||
else | ||
{ | ||
Logger.LogError($"Not enabling experiment biome pause fix - game version {GameVersion} may not be broken"); | ||
} | ||
} | ||
|
||
// RefreshLocationsValidity has a bug where it unconditionally pauses experiments when switching biome, even if the | ||
// experiment is still valid and doesn't care about the biome. To fix this, we prevent the function from being | ||
// called if the part has running experiments, the experiments don't care about the biome, and the other parameters | ||
// of the experiment are unchanged. | ||
// To avoid breaking things when we skip RefreshLocationsValidity, we also update some private state that the method | ||
// is responsible for when skipping it. | ||
[HarmonyPatch( | ||
typeof(PartComponentModule_ScienceExperiment), | ||
nameof(PartComponentModule_ScienceExperiment.RefreshLocationsValidity) | ||
)] | ||
[HarmonyPrefix] | ||
public static bool RefreshLocationsValidityPrefix( | ||
// ReSharper disable once InconsistentNaming | ||
ref VesselComponent ____vesselComponent, | ||
// ReSharper disable once InconsistentNaming | ||
ref ResearchLocation ____currentLocation, | ||
// ReSharper disable once InconsistentNaming | ||
ref Data_ScienceExperiment ___dataScienceExperiment | ||
) | ||
{ | ||
if (____vesselComponent?.mainBody == null || | ||
____vesselComponent?.VesselScienceRegionSituation.ResearchLocation == null) | ||
{ | ||
return true; | ||
} | ||
|
||
var newLocation = new ResearchLocation( | ||
requiresRegion: true, // Placeholder, assigned per-experiment below | ||
bodyName: ____vesselComponent.mainBody.bodyName, | ||
scienceSituation: ____vesselComponent.VesselScienceRegionSituation.ResearchLocation.ScienceSituation, | ||
scienceRegion: ____vesselComponent.VesselScienceRegionSituation.ResearchLocation.ScienceRegion | ||
); | ||
|
||
bool safeToSkip = true; | ||
var newRegions = new List<string>(); | ||
foreach (var standing in ___dataScienceExperiment.ExperimentStandings) | ||
{ | ||
if (standing.CurrentExperimentState == ExperimentState.RUNNING && | ||
!standing.RegionRequired && | ||
standing.ExperimentLocation.BodyName == newLocation.BodyName && | ||
standing.ExperimentLocation.ScienceSituation == newLocation.ScienceSituation) | ||
{ | ||
newLocation.RequiresRegion = standing.RegionRequired; | ||
newRegions.Add(newLocation.ScienceRegion); | ||
continue; | ||
} | ||
|
||
safeToSkip = false; | ||
} | ||
|
||
if (safeToSkip) | ||
{ | ||
_instance.Logger.LogInfo( | ||
"Skipping PartComponentModule_ScienceExperiment.RefreshLocationsValidity - experiment is still valid." | ||
); | ||
|
||
____currentLocation = newLocation; | ||
for (int i = 0; i < newRegions.Count; i++) | ||
{ | ||
___dataScienceExperiment.ExperimentStandings[i].ExperimentLocation.SetScienceRegion(newRegions[i]); | ||
} | ||
} | ||
|
||
return !safeToSkip; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
namespace CommunityFixes.Fix.KSP2SaveFix; | ||
|
||
[Fix("KSP 2 Save Fix")] | ||
public class KSP2SaveFix: BaseFix | ||
public class KSP2SaveFix : BaseFix | ||
{ | ||
public static KSP2SaveFix Instance; | ||
|
||
public KSP2SaveFix() | ||
{ | ||
Instance = this; | ||
} | ||
|
||
public override void OnInitialized() | ||
{ | ||
HarmonyInstance.PatchAll(typeof(KSP2SaveFix_GetState)); | ||
} | ||
} | ||
} |
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