using System; using Newtonsoft.Json; namespace Oxide.Plugins { [Info("FireTimer", "tofurahie", "1.0.2")] internal class FireTimer : RustPlugin { #region Static 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(); 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 OnEntitySpawned(HelicopterDebris debris) { if (debris == null) return; debris.tooHotUntil = UnityEngine.Time.realtimeSinceStartup + _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 } }