-
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.
Added npc encounter patch (#131) which allows npc encounters to spawn…
… again
- Loading branch information
Showing
4 changed files
with
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using HarmonyLib; | ||
using Sandbox.Game.World.Generator; | ||
using SEWorldGenPlugin.Session; | ||
using VRage.Library.Utils; | ||
using VRage.Noise; | ||
|
||
namespace SEWorldGenPlugin.Patches | ||
{ | ||
/// <summary> | ||
/// Patch class to patch vanilla asteroid generation, so that encounter generation is still possible | ||
/// </summary> | ||
public class PatchAsteroidGeneration : HarmonyPatchBase | ||
{ | ||
public PatchAsteroidGeneration() : base("Asteroid generator patch (encounter fix)") | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prefix patch applied to <see cref="MyProceduralAsteroidCellGenerator.GenerateObjects(System.Collections.Generic.List{MyObjectSeed}, System.Collections.Generic.HashSet{VRage.Game.MyObjectSeedParams})"/> | ||
/// </summary> | ||
/// <param name="cell">Cell to generate objects for</param> | ||
/// <param name="objectSeed">Object to generate for cell</param> | ||
/// <param name="index"></param> | ||
/// <param name="random"></param> | ||
/// <param name="densityFunctionFilled"></param> | ||
/// <param name="densityFunctionRemoved"></param> | ||
/// <returns>True when original method should execute, false if skipped</returns> | ||
public static bool Prefix(MyProceduralCell cell, MyObjectSeed objectSeed, ref int index, MyRandom random, IMyModule densityFunctionFilled, IMyModule densityFunctionRemoved) | ||
{ | ||
if (!MySettingsSession.Static.Settings.Enabled) return true; | ||
|
||
if (MySettingsSession.Static.Settings.GeneratorSettings.AsteroidGenerator != ObjectBuilders.AsteroidGenerationMethod.PLUGIN) return true; | ||
|
||
if(objectSeed.Params.Type == VRage.Game.MyObjectSeedType.Asteroid || objectSeed.Params.Type == VRage.Game.MyObjectSeedType.AsteroidCluster) | ||
{ | ||
return false; // skip original method | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public override void ApplyPatch(Harmony harmony) | ||
{ | ||
base.ApplyPatch(harmony); | ||
|
||
var baseMethod = typeof(MyProceduralAsteroidCellGenerator).GetMethod("GenerateObject", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); | ||
var prefix = typeof(PatchAsteroidGeneration).GetMethod("Prefix"); | ||
|
||
harmony.Patch(baseMethod, prefix: new HarmonyMethod(prefix)); | ||
} | ||
} | ||
} |
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