using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Configuration;
using System.Collections.Generic;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("SpeedSmelt", "YourName", "1.0.0")]
class SpeedSmelt : RustPlugin
{
private DynamicConfigFile configData;
private Dictionary<string, float> furnaceSpeeds = new Dictionary<string, float>();
private Dictionary<string, float> resourceSpeeds = new Dictionary<string, float>();
private void LoadDefaultConfig()
{
Config["FurnaceSpeed"] = new Dictionary<string, float>
{
{ "furnace.large", 2.0 },
{ "furnace.small", 1.5 }
// Добавьте сюда другие типы печей и их скорости работы по умолчанию
};
Config["ResourceSpeed"] = new Dictionary<string, float>
{
{ "metal.ore", 2.0 },
{ "sulfur.ore", 1.5 },
{ "wood", 1.0 }
// Добавьте сюда другие ресурсы и их скорости плавки по умолчанию
};
}
private void Init()
{
configData = Interface.Oxide.DataFileSystem.GetFile("SpeedSmeltConfig");
LoadDefaultConfig();
LoadConfigValues();
}
private void LoadConfigValues()
{
furnaceSpeeds = configData.ReadObject<Dictionary<string, float>>("FurnaceSpeed");
resourceSpeeds = configData.ReadObject<Dictionary<string, float>>("ResourceSpeed");
}
private void SaveConfigValues()
{
configData.WriteObject(furnaceSpeeds, true);
configData.WriteObject(resourceSpeeds, "ResourceSpeed", true);
}
private void ApplySpeedSmelt()
{
foreach (BaseOven oven in BaseOven.ovenList)
{
float speed;
if (furnaceSpeeds.TryGetValue(oven.ShortPrefabName, out speed))
{
oven.cookingSpeed = speed;
}
foreach (Item item in oven.inventory.itemList)
{
if (resourceSpeeds.TryGetValue(item.info.shortname, out speed))
{
item.amount *= speed;
}
}
oven.SendNetworkUpdateImmediate();
}
}
void OnServerInitialized()
{
ApplySpeedSmelt();
}
void Unload()
{
SaveConfigValues();
}
}
}