Иконка ресурса

FREE FNoBuildingDecay : 1.0.0 1.0.0

Нет прав для скачивания
C#:
using HarmonyLib;
namespace Oxide.Plugins
{
    [Info("FNoBuildingDecay", "fufel", "1.0.0")]
    public class FNoBuildingDecay : RustPlugin
    {
        Harmony _h;

        void Init()
        {
            _h = new Harmony(Name);
            _h.PatchAll();
        }

        void Unload()
        {
            _h?.UnpatchAll(Name);
        }

        object OnDecayDamage(DecayEntity entity)
        {
            var block = entity as BuildingBlock;
            if (block == null || block.IsDestroyed) return null;
            return true;
        }

        [HarmonyPatch(typeof(BuildingPrivlidge), nameof(BuildingPrivlidge.GetProtectedMinutes))]
        static class GetProtectedMinutesPatch
        {
            static bool Prefix(ref float __result)
            {
                __result = 43200f;
                return false;
            }
        }

        [HarmonyPatch(typeof(BuildingPrivlidge), nameof(BuildingPrivlidge.Save))]
        static class SavePatch
        {
            static void Postfix(BaseNetworkable.SaveInfo info)
            {
                if (info.forDisk || info.msg?.buildingPrivilege == null) return;
                float protectedMinutes = 43200f;
                if ((double)ConVar.Decay.scale > 0.01)
                {
                    info.msg.buildingPrivilege.protectedMinutes = protectedMinutes / ConVar.Decay.scale;
                }
                else
                {
                    info.msg.buildingPrivilege.protectedMinutes = protectedMinutes;
                }
            }
        }
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху