Skip to content

Commit 0566f96

Browse files
committed
Deprecated TerrainRegistry.PatchTerrain.
1 parent 83c3999 commit 0566f96

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

README.md

+13-23
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,18 @@ mod uses Terrain Patcher, anyone using your mod needs to have Terrain Patcher in
4747

4848
### Patch Loading
4949

50-
There are two ways to load a terrain patch. The easiest way is to distribute your `.optoctreepatch`
51-
file alongside your mod. **Terrain Patcher will find and load all `.optoctreepatch` files placed
52-
anywhere in the `BepInEx/plugins` folder or any subfolder.**
50+
To load a terrain patch, just distribute your `.optoctreepatch` file alongside your mod. **Terrain
51+
Patcher will find and load all `.optoctreepatch` files placed anywhere in the `BepInEx/plugins`
52+
folder or any subfolder**, so you don't need to do anything else to make sure your terrain patch
53+
gets loaded.
5354

54-
Alternatively, you can add your `.optoctreepatch` file to your project as an embedded resource and
55-
add `TerrainPatcher.dll` as a reference. You can then use `Assembly.GetManifestResourceStream` (as
56-
demonstrated in [`ExampleMod.cs`](./examples/ExampleMod.cs)) to load the resource. If you pass this
57-
stream to `TerrainRegistry.PatchTerrain`, Terrain Patcher will apply your patch file. Below is an
58-
example of how to do this.
59-
60-
```cs
61-
var asm = System.Reflection.Assembly.GetExecutingAssembly();
62-
var patch = asm.GetManifestResourceStream("MyModName.my-file-name.optoctreepatch");
63-
TerrainPatcher.TerrainRegistry.PatchTerrain("my-file-name", patch);
64-
```
65-
66-
Using `TerrainRegistry.PatchTerrain` to load terrain patches may be deprecated in a future release.
55+
Terrain patcher also currently supports loading patches via the
56+
`TerrainPatcher.TerrainRegistry.PatchTerrain` method, but this method is deprecated and may be
57+
removed in a future release of Terrain Patcher.
6758

6859
### Dependency Registration
6960

70-
Regardless of which method you use to load terrain patches, you'll need to add Terrain Patcher as a
71-
dependency of your mod.
61+
If your mod contains terrain patches, you should add Terrain Patcher as a dependency of your mod.
7262

7363
If your mod **requires** Terrain Patcher to function, add the
7464
`[BepInDependency("Esper89.TerrainPatcher")]` attribute to your mod's entry point (below the
@@ -94,11 +84,11 @@ internal class Mod : BaseUnityPlugin { /* ... */ }
9484

9585
Terrain Patcher is licensed under the GNU AGPL, which says that derivative works must also be
9686
licensed under the GNU AGPL. If your mod directly interacts with Terrain Patcher (e.g. by
97-
referencing `TerrainPatcher.dll` and calling `TerrainPatcher.TerrainRegistry.PatchTerrain`), it
98-
might be considered a derivative work. To avoid any possible copyright issues, if your mod isn't
99-
licensed under the GNU AGPL, you should avoid referencing `TerrainPatcher.dll` or otherwise
100-
interacting with Terrain Patcher directly. Patches can still be loaded without referencing Terrain
101-
Patcher by distributing them alongside your mod as separate `.optoctreepatch` files.
87+
referencing `TerrainPatcher.dll`), it might be considered a derivative work. To avoid any possible
88+
copyright issues, if your mod isn't licensed under the GNU AGPL, you should avoid referencing
89+
`TerrainPatcher.dll` or otherwise interacting with Terrain Patcher directly. Terrain patches are
90+
loaded without referencing Terrain Patcher by distributing them alongside your mod as separate
91+
`.optoctreepatch` files.
10292

10393
## Patch Format
10494

src/FileLoading.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void LoadPatch(string filepath)
151151
return;
152152
}
153153

154-
TerrainRegistry.PatchTerrain(patchName, file);
154+
TerrainRegistry.ApplyTerrainPatch(patchName, file, forceOriginal: false);
155155
file.Close();
156156
}
157157
}

src/Terrain.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ namespace TerrainPatcher
1010
/// <summary>The global registry of terrain patches.</summary>
1111
public static class TerrainRegistry
1212
{
13-
/// <summary>Applies a terrain patch file to the game's terrain.</summary>
13+
/// <summary>Applies a terrain patch file to the game's terrain. Deprecated</summary>
1414
/// <param name="patchName">The name of the patch file to apply.</param>
1515
/// <param name="patchFile">The patch file to apply.</param>
1616
/// <param name="forceOriginal">Force-overwrites batches in this patch, resetting them to
1717
/// their original states before applying patches.</param>
18+
[Obsolete(
19+
"This method is deprecated; instead, load terrain patches by distributing them as"
20+
+ " individual files alongside your mod."
21+
)]
1822
public static void PatchTerrain(
1923
string patchName,
2024
Stream patchFile,
@@ -26,6 +30,15 @@ public static void PatchTerrain(
2630
throw new ArgumentNullException($"Argument '{nameof(patchFile)}' must not be null");
2731
}
2832

33+
ApplyTerrainPatch(patchName, patchFile, forceOriginal);
34+
}
35+
36+
internal static void ApplyTerrainPatch(
37+
string patchName,
38+
Stream patchFile,
39+
bool forceOriginal
40+
)
41+
{
2942
try
3043
{
3144
string message = $"Applying patch '{patchName}'";

0 commit comments

Comments
 (0)