-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new item + changed recipe for the blade.
- Loading branch information
1 parent
34804b2
commit f7c618c
Showing
8 changed files
with
191 additions
and
22 deletions.
There are no files selected for viewing
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,25 @@ | ||
using BepInEx.Configuration; | ||
using Nautilus.Options; | ||
using UnityEngine; | ||
|
||
namespace CureBlade | ||
{ | ||
public class CureBladeOptions : ModOptions | ||
{ | ||
public CureBladeOptions() : base("Cure Blade Options") | ||
{ | ||
|
||
AddItem(Plugin.cureKnifeRange.ToModSliderOption(minValue: 0.1f, maxValue: 2.0f, step: 0.01f, floatFormat: "{0:F2}x")); | ||
AddItem(Plugin.cureKnifeDamage.ToModSliderOption(minValue: 0.1f, maxValue: 5.0f, step: 0.1f, floatFormat: "{0:F1}x")); | ||
|
||
ModSliderOption emissionStrength = Plugin.cureKnifeEmissionStrength.ToModSliderOption(minValue: 0.1f, maxValue: 2.0f, step: 0.01f, floatFormat: "{0:F2}x"); | ||
emissionStrength.OnChanged += emissionStrengthChanged; | ||
AddItem(emissionStrength); | ||
} | ||
|
||
public void emissionStrengthChanged( object sender, SliderChangedEventArgs e) | ||
{ | ||
Object.FindObjectsOfType<CureBladeComp>().ForEach(x => x.Refresh()); | ||
} | ||
} | ||
} |
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,39 @@ | ||
using Nautilus.Assets; | ||
using Nautilus.Assets.Gadgets; | ||
using Nautilus.Assets.PrefabTemplates; | ||
using Nautilus.Crafting; | ||
using Ingredient = CraftData.Ingredient; | ||
using UnityEngine; | ||
using System.Collections.Generic; | ||
|
||
namespace CureBlade.Items.Consumables | ||
{ | ||
internal class BrineBottleItem | ||
{ | ||
public static PrefabInfo Info { get; private set; } | ||
public static void Patch() | ||
{ | ||
Info = Utilities.CreatePrefabInfo("BrineSolution", "Concentrated Brine", "Usually used in curing meat, however using this high a concentration could potentially poison the consumer!", Utilities.GetSprite("brine_bottle_sprite"), 1, 1); | ||
|
||
var prefab = new CustomPrefab(Info); | ||
|
||
var clonePrefab = new CloneTemplate(Info, TechType.FilteredWater); | ||
|
||
clonePrefab.ModifyPrefab += obj => | ||
{ | ||
var eatable = obj.GetComponent<Eatable>(); | ||
|
||
eatable.waterValue = -50; | ||
|
||
var renderer = obj.GetComponentInChildren<MeshRenderer>(true); | ||
obj.GetComponentsInChildren<MeshRenderer>(true).ForEach(x => x.material.mainTexture = Utilities.GetTexture("brine_bottle")); | ||
}; | ||
|
||
prefab.SetGameObject(clonePrefab); | ||
prefab.SetUnlock(TechType.HeatBlade).CompoundTechsForUnlock = new List<TechType>() { TechType.FiltrationMachine }; | ||
|
||
prefab.Register(); | ||
|
||
} | ||
} | ||
} |
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,86 @@ | ||
using CureBlade.Items.Consumables; | ||
using HarmonyLib; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Reflection.Emit; | ||
using UnityEngine; | ||
|
||
namespace CureBlade.Patches | ||
{ | ||
[HarmonyPatch(typeof(FiltrationMachine))] | ||
internal class FiltrationMachinePatch | ||
{ | ||
[HarmonyPatch(typeof(FiltrationMachine), nameof(FiltrationMachine.TryFilterWater))] | ||
[HarmonyTranspiler] | ||
static IEnumerable<CodeInstruction> TranspilerWater(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
return new CodeMatcher(instructions).MatchForward(true, | ||
new CodeMatch(OpCodes.Callvirt), | ||
new CodeMatch(OpCodes.Ldc_I4, (int)TechType.BigFilteredWater)) | ||
.InsertAndAdvance( new CodeInstruction(OpCodes.Ldarg_0) ) | ||
.SetInstruction( new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(FiltrationMachinePatch), "GetBiomeForWater", parameters: new[] { typeof(FiltrationMachine) })) ) | ||
.InstructionEnumeration(); | ||
} | ||
|
||
static TechType GetBiomeForWater(FiltrationMachine __instance) { | ||
// Get Biome code goes here | ||
string biome = LargeWorld.main.GetBiome(__instance.transform.position); | ||
|
||
// Check if biome returns true -> return new techtype | ||
if(biome.Contains("LostRiver")) | ||
{ | ||
UWE.CoroutineHost.StartCoroutine(SetInstanceWaterPrefab(__instance, TechType.FilteredWater)); | ||
return TechType.FilteredWater; | ||
} | ||
// Else -> return old techtype | ||
|
||
UWE.CoroutineHost.StartCoroutine(SetInstanceWaterPrefab(__instance, TechType.BigFilteredWater)); | ||
return TechType.BigFilteredWater; | ||
} | ||
public static IEnumerator SetInstanceWaterPrefab(FiltrationMachine __instance, TechType waterTechType) | ||
{ | ||
TaskResult<GameObject> result = new TaskResult<GameObject>(); | ||
yield return CraftData.GetPrefabForTechTypeAsync(waterTechType, false, result); | ||
var gameObject = result.Get(); | ||
|
||
__instance.waterPrefab = gameObject; | ||
} | ||
|
||
[HarmonyPatch(typeof(FiltrationMachine), nameof(FiltrationMachine.TryFilterSalt))] | ||
[HarmonyTranspiler] | ||
static IEnumerable<CodeInstruction> TranspilerSalt(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
return new CodeMatcher(instructions).MatchForward(true, | ||
new CodeMatch(OpCodes.Callvirt), | ||
new CodeMatch(OpCodes.Ldc_I4_S, (sbyte)TechType.Salt)) | ||
.InsertAndAdvance(new CodeInstruction(OpCodes.Ldarg_0)) | ||
.SetInstruction(new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(FiltrationMachinePatch), "GetBiomeForSalt", parameters: new[] { typeof(FiltrationMachine) }))) | ||
.InstructionEnumeration(); | ||
} | ||
|
||
static TechType GetBiomeForSalt(FiltrationMachine __instance) | ||
{ | ||
// Get Biome code goes here | ||
string biome = LargeWorld.main.GetBiome(__instance.transform.position); | ||
|
||
// Check if biome returns true -> return new techtype | ||
if (biome.Contains("LostRiver")) | ||
{ | ||
UWE.CoroutineHost.StartCoroutine(SetInstanceSaltPrefab(__instance, BrineBottleItem.Info.TechType)); | ||
return TechType.FilteredWater; | ||
} | ||
// Else -> return old techtype | ||
|
||
UWE.CoroutineHost.StartCoroutine(SetInstanceSaltPrefab(__instance, TechType.Salt)); | ||
return TechType.Salt; | ||
} | ||
public static IEnumerator SetInstanceSaltPrefab(FiltrationMachine __instance, TechType saltTechType) | ||
{ | ||
TaskResult<GameObject> result = new TaskResult<GameObject>(); | ||
yield return CraftData.GetPrefabForTechTypeAsync(saltTechType, false, result); | ||
var gameObject = result.Get(); | ||
|
||
__instance.waterPrefab = gameObject; | ||
} | ||
} | ||
} |
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