-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crops persistence #2137
Open
tornac1234
wants to merge
5
commits into
SubnauticaNitrox:master
Choose a base branch
from
tornac1234:crops-persistence
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Crops persistence #2137
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f29ed9
Add crops persistence (for water parks, and pots and all)
tornac1234 54d32c3
Sync trash can
tornac1234 775cf86
Add sync for plant exact slot in the planter
tornac1234 88eae5a
Add sync for prefab picking deleting the giver object (required for m…
tornac1234 76dbd05
Sync fruit growing and harvesting (from plants and objects like kelp)
tornac1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Nitrox.Test/Patcher/Patches/Dynamic/GrowingPlant_SpawnGrownModelAsync_PatchTest.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,16 @@ | ||
using HarmonyLib; | ||
using NitroxTest.Patcher; | ||
|
||
namespace NitroxPatcher.Patches.Dynamic; | ||
|
||
[TestClass] | ||
public class GrowingPlant_SpawnGrownModelAsync_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(GrowingPlant_SpawnGrownModelAsync_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = GrowingPlant_SpawnGrownModelAsync_Patch.Transpiler(originalIl); | ||
transformedIl.Count().Should().Be(originalIl.Count() - 1); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Nitrox.Test/Patcher/Patches/Dynamic/PickPrefab_AddToContainerAsync_PatchTest.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,16 @@ | ||
using HarmonyLib; | ||
using NitroxTest.Patcher; | ||
|
||
namespace NitroxPatcher.Patches.Dynamic; | ||
|
||
[TestClass] | ||
public class PickPrefab_AddToContainerAsync_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(PickPrefab_AddToContainerAsync_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = PickPrefab_AddToContainerAsync_Patch.Transpiler(originalIl); | ||
transformedIl.Count().Should().Be(originalIl.Count() + 4); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Nitrox.Test/Patcher/Patches/Dynamic/Trashcan_Update_PatchTest.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,16 @@ | ||
using HarmonyLib; | ||
using NitroxTest.Patcher; | ||
|
||
namespace NitroxPatcher.Patches.Dynamic; | ||
|
||
[TestClass] | ||
public class Trashcan_Update_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(Trashcan_Update_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = Trashcan_Update_Patch.Transpiler(originalIl); | ||
transformedIl.Count().Should().Be(originalIl.Count() + 3); | ||
} | ||
} |
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
49 changes: 0 additions & 49 deletions
49
NitroxClient/GameLogic/Containers/ContainerAddItemPostProcessor.cs
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
NitroxClient/GameLogic/Containers/NoOpContainerAddItemPostProcessor.cs
This file was deleted.
Oops, something went wrong.
80 changes: 0 additions & 80 deletions
80
NitroxClient/GameLogic/Containers/PlantableContainerAddItemPostProcessor.cs
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
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
22 changes: 22 additions & 0 deletions
22
NitroxClient/GameLogic/Spawning/Metadata/Extractor/FruitPlantMetadataExtractor.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,22 @@ | ||
using System.Linq; | ||
using NitroxClient.GameLogic.Spawning.Metadata.Extractor.Abstract; | ||
using NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
|
||
namespace NitroxClient.GameLogic.Spawning.Metadata.Extractor; | ||
|
||
public class FruitPlantMetadataExtractor : EntityMetadataExtractor<FruitPlant, FruitPlantMetadata> | ||
{ | ||
public override FruitPlantMetadata Extract(FruitPlant fruitPlant) | ||
{ | ||
bool[] prefabsPicked = fruitPlant.fruits.Select(prefab => prefab.pickedState).ToArray(); | ||
|
||
// If fruit spawn is disabled (certain plants like kelp don't regrow their fruits) and if none of the fruits were picked (all picked = false) | ||
// then we don't need to save this data because the plant is spawned like this by default | ||
if (!fruitPlant.fruitSpawnEnabled && prefabsPicked.All(b => !b)) | ||
{ | ||
return null; | ||
} | ||
|
||
return new(prefabsPicked, fruitPlant.timeNextFruit); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would add a comment here that the
FruitPlantMetadata
field is not checked bc it's (hopefully) only temporary.