C#:
using HarmonyLib;
namespace Oxide.Plugins;
[Info("FRecyclerHqmNerf", "fufeldev", "1.0.0")]
public class FRecyclerHqmNerf : RustPlugin
{
private const string ShortName = "metal.refined";
private const float Multiplier = 0.85f;
private Harmony _harmony;
private void Init()
{
_harmony = new Harmony(Name);
_harmony.PatchAll();
}
private void Unload()
{
_harmony?.UnpatchAll(Name);
}
[HarmonyPatch(typeof(Recycler), nameof(Recycler.MoveItemToOutput))]
private static class MoveItemToOutputPatch
{
private static bool Prefix(Item newItem, ref bool __result)
{
if (newItem?.info?.shortname != ShortName) return true;
int keep = UnityEngine.Mathf.FloorToInt(newItem.amount * Multiplier);
if (keep <= 0 && UnityEngine.Random.Range(0f, 1f) <= newItem.amount * Multiplier) keep = 1;
if (keep > 0)
{
newItem.amount = keep;
return true;
}
newItem.Remove();
__result = true;
return false;
}
}
}