C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
/*
* Copyright (C) 2024 Game4Freak.io
* This mod is provided under the Game4Freak EULA.* Full legal terms can be found at https://game4freak.io/eula/
*/
using Newtonsoft.Json;
using Oxide.Core;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Oxide.Plugins
{
[Info("Furnace Go Brrr", "VisEntities", "1.1.0")]
[Description("Speeds up smelting in ovens.")]
public class FurnaceGoBrrr : RustPlugin
{
#region Fields
private static FurnaceGoBrrr _plugin;
private static Configuration _config;
private CustomSmelterManager _customSmelterManager = new CustomSmelterManager();
private const int CAPPED_SMELTING_SPEED = 20;
private static Dictionary<BaseOven, int> _vanillaOvenSmeltingSpeeds = new Dictionary<BaseOven, int>();
#endregion Fields
#region Configuration
private class Configuration
{
[JsonProperty("Version")]
public string Version { get; set; }
[JsonProperty("Ovens")]
public List<OvenConfig> Ovens { get; set; }
}
private class OvenConfig
{
[JsonProperty("Prefab Short Names")]
public List<string> PrefabShortNames { get; set; }
[JsonProperty("Default Profile")]
public string DefaultProfile { get; set; }
[JsonProperty("Smelting Profiles")]
public Dictionary<string, SmeltingProfileConfig> SmeltingProfiles { get; set; }
}
private class SmeltingProfileConfig
{
[JsonProperty("Priority")]
public int Priority { get; set; }
[JsonProperty("Smelting Speed")]
public int SmeltingSpeed { get; set; }
[JsonProperty("Burnable")]
public BurnableConfig Burnable { get; set; }
[JsonProperty("Cookables")]
public List<CookableConfig> Cookables { get; set; }
[JsonIgnore]
public string Permission { get; set; }
}
private class BurnableConfig
{
[JsonProperty("Fuel Consumption Rate")]
public int FuelConsumptionRate { get; set; }
[JsonProperty("Enable Byproduct Creation")]
public bool EnableByproductCreation { get; set; }
[JsonProperty("Byproduct Creation Rate Per Unit Fuel")]
public int ByproductCreationRatePerUnitFuel { get; set; }
[JsonProperty("Byproduct Creation Chance")]
public int ByproductCreationChance { get; set; }
}
private class CookableConfig
{
[JsonProperty("Raw Item Short Name")]
public string RawItemShortName { get; set; }
[JsonProperty("Units Smelted Per Cooking Cycle")]
public int UnitsSmeltedPerCookingCycle { get; set; }
[JsonProperty("Amount Produced Per Unit Cooked")]
public int AmountProducedPerUnitCooked { get; set; }
}
protected override void LoadConfig()
{
base.LoadConfig();
_config = Config.ReadObject<Configuration>();
if (string.Compare(_config.Version, Version.ToString()) < 0)
UpdateConfig();
ValidateAndCapSmeltingSpeeds();
SaveConfig();
}
protected override void LoadDefaultConfig()
{
_config = GetDefaultConfig();
}
protected override void SaveConfig()
{
Config.WriteObject(_config, true);
}
private void UpdateConfig()
{
PrintWarning("Config changes detected! Updating...");
Configuration defaultConfig = GetDefaultConfig();
if (string.Compare(_config.Version, "1.0.0") < 0)
_config = defaultConfig;
if (string.Compare(_config.Version, "1.1.0") < 0)
{
foreach (OvenConfig ovenConfig in _config.Ovens)
{
foreach (var kvp in ovenConfig.SmeltingProfiles)
{
SmeltingProfileConfig profile = kvp.Value;
if (profile.Priority == 0)
{
if (kvp.Key.Equals("vip", StringComparison.OrdinalIgnoreCase))
profile.Priority = 1;
else
profile.Priority = 0;
}
}
}
}
PrintWarning("Config update complete! Updated from version " + _config.Version + " to " + Version.ToString());
_config.Version = Version.ToString();
}
private Configuration GetDefaultConfig()
{
return new Configuration
{
Version = Version.ToString(),
Ovens = new List<OvenConfig>
{
new OvenConfig
{
PrefabShortNames = new List<string>
{
"furnace",
"legacy_furnace"
},
DefaultProfile = "default",
SmeltingProfiles = new Dictionary<string, SmeltingProfileConfig>
{
{
"default", new SmeltingProfileConfig
{
Priority = 0,
SmeltingSpeed = 3,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "sulfur.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "hq.metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
},
{
"vip", new SmeltingProfileConfig
{
Priority = 1,
SmeltingSpeed = 3,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "sulfur.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "hq.metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
}
}
},
new OvenConfig
{
PrefabShortNames = new List<string>
{
"electricfurnace.deployed",
},
DefaultProfile = "default",
SmeltingProfiles = new Dictionary<string, SmeltingProfileConfig>
{
{
"default", new SmeltingProfileConfig
{
Priority = 0,
SmeltingSpeed = 10,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 0,
EnableByproductCreation = false,
ByproductCreationRatePerUnitFuel = 0,
ByproductCreationChance = 0
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "sulfur.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "hq.metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
},
{
"vip", new SmeltingProfileConfig
{
Priority = 1,
SmeltingSpeed = 10,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 0,
EnableByproductCreation = false,
ByproductCreationRatePerUnitFuel = 0,
ByproductCreationChance = 0
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "sulfur.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "hq.metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
}
}
},
new OvenConfig
{
PrefabShortNames = new List<string>
{
"furnace.large"
},
DefaultProfile = "default",
SmeltingProfiles = new Dictionary<string, SmeltingProfileConfig>
{
{
"default", new SmeltingProfileConfig
{
Priority = 0,
SmeltingSpeed = 15,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "sulfur.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "hq.metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
},
{
"vip", new SmeltingProfileConfig
{
Priority = 1,
SmeltingSpeed = 15,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "sulfur.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "hq.metal.ore",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
}
}
},
new OvenConfig
{
PrefabShortNames = new List<string>
{
"refinery_small_deployed"
},
DefaultProfile = "default",
SmeltingProfiles = new Dictionary<string, SmeltingProfileConfig>
{
{
"default", new SmeltingProfileConfig
{
Priority = 0,
SmeltingSpeed = 3,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "crude.oil",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 3
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
},
{
"vip", new SmeltingProfileConfig
{
Priority = 1,
SmeltingSpeed = 3,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "crude.oil",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 3
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
}
}
},
new OvenConfig
{
PrefabShortNames = new List<string>
{
"campfire",
"skull_fire_pit",
"hobobarrel.deployed"
},
DefaultProfile = "default",
SmeltingProfiles = new Dictionary<string, SmeltingProfileConfig>
{
{
"default", new SmeltingProfileConfig
{
Priority = 0,
SmeltingSpeed = 2,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "bearmeat",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "chicken.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "deermeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "fish.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "horsemeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "humanmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "meat.boar",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "wolfmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
},
{
"vip", new SmeltingProfileConfig
{
Priority = 1,
SmeltingSpeed = 2,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "bearmeat",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "chicken.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "deermeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "fish.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "horsemeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "humanmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "meat.boar",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "wolfmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
}
}
},
new OvenConfig
{
PrefabShortNames = new List<string>
{
"bbq.deployed"
},
DefaultProfile = "default",
SmeltingProfiles = new Dictionary<string, SmeltingProfileConfig>
{
{
"default", new SmeltingProfileConfig
{
Priority = 0,
SmeltingSpeed = 8,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "bearmeat",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "chicken.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "deermeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "fish.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "horsemeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "humanmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "meat.boar",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "wolfmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
},
{
"vip", new SmeltingProfileConfig
{
Priority = 1,
SmeltingSpeed = 8,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1,
EnableByproductCreation = true,
ByproductCreationRatePerUnitFuel = 1,
ByproductCreationChance = 25
},
Cookables = new List<CookableConfig>
{
new CookableConfig
{
RawItemShortName = "bearmeat",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "chicken.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "deermeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "fish.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "horsemeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "humanmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "meat.boar",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "wolfmeat.raw",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 1
},
new CookableConfig
{
RawItemShortName = "can.beans.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 15
},
new CookableConfig
{
RawItemShortName = "can.tuna.empty",
UnitsSmeltedPerCookingCycle = 1,
AmountProducedPerUnitCooked = 10
}
}
}
}
}
},
new OvenConfig
{
PrefabShortNames = new List<string>
{
"tunalight.deployed",
"lantern.deployed",
"chineselantern.deployed",
"chineselantern_white.deployed",
"jackolantern.happy",
"jackolantern.angry",
},
DefaultProfile = "default",
SmeltingProfiles = new Dictionary<string, SmeltingProfileConfig>
{
{
"default", new SmeltingProfileConfig
{
Priority = 0,
SmeltingSpeed = 1,
Burnable = new BurnableConfig
{
FuelConsumptionRate = 1
// ... [Code preview truncated due to length. Full source in attached file] ...