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

FREE FireTimer : 1.0.3 1.0.3

Нет прав для скачивания
C#:
using System;
using System.Reflection;
using Newtonsoft.Json;

namespace Oxide.Plugins
{
    [Info("FireTimer", "tofurahie", "1.0.3")]
    internal class FireTimer : RustPlugin
    {
        #region Static

        private const BindingFlags DEBRIS_MEMBERS = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

        private static readonly FieldInfo TooHotUntil = typeof(HelicopterDebris).GetField("tooHotUntil", DEBRIS_MEMBERS);
        private static readonly MethodInfo OnCooledDown = typeof(HelicopterDebris).GetMethod("OnCooledDown", DEBRIS_MEMBERS);

        private Configuration _config;

        #region Classes

        private class Configuration
        {
            [JsonProperty("Minimum burning time")]
            public int minBurningTime = 5;

            [JsonProperty("Maximum burning time")]
            public int maxBurningTime = 15;

            [JsonProperty("How long will it take to get a tank? (seconds)")]
            public int timer = 15;
        }

        #endregion

        #endregion

        #region Config

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                _config = Config.ReadObject<Configuration>();
                if (_config == null) throw new Exception();
                SaveConfig();
            }
            catch
            {
                PrintError("Your configuration file contains an error. Using default configuration values.");
                LoadDefaultConfig();
            }
        }

        protected override void SaveConfig() => Config.WriteObject(_config);

        protected override void LoadDefaultConfig() => _config = new Configuration();

        #endregion

        #region OxideHooks

        private void Init()
        {
            if (TooHotUntil == null && OnCooledDown == null)
                throw new InvalidOperationException("HelicopterDebris has neither 'tooHotUntil' nor 'OnCooledDown': this Rust build needs a FireTimer update");
        }

        private void OnEntitySpawned(HelicopterDebris debris)
        {
            if (debris == null)
                return;

            if (TooHotUntil != null)
            {
                TooHotUntil.SetValue(debris, UnityEngine.Time.realtimeSinceStartup + _config.timer);
                return;
            }

            Action coolDown = (Action)Delegate.CreateDelegate(typeof(Action), debris, OnCooledDown);
            debris.CancelInvoke(coolDown);
            debris.Invoke(coolDown, _config.timer);
        }

        private void OnEntitySpawned(FireBall ball) =>
            NextTick(() =>
            {
                if (ball == null || ball.PrefabName == "assets/bundled/prefabs/fireball_small.prefab" || !ball.HasParent())
                    return;

                ball.Invoke(ball.Extinguish, UnityEngine.Random.Range(_config.minBurningTime, _config.maxBurningTime + 1));
            });

        #endregion
    }
}

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