internal void Initialize() { Environment.Initialize(); try { Implementation.OnRocketImplementationInitialized += () => { gameObject.TryAddComponent <TaskDispatcher>(); gameObject.TryAddComponent <AutomaticShutdownWatchdog>(); if (Settings.Instance.RCON.Enabled) { gameObject.TryAddComponent <RCONServer>(); } }; Settings = new XMLFileAsset <RocketSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Permissions = gameObject.TryAddComponent <RocketPermissionsManager>(); Plugins = gameObject.TryAddComponent <RocketPluginManager>(); Commands = gameObject.TryAddComponent <RocketCommandManager>(); if (Settings.Instance.MaxFrames < 10 && Settings.Instance.MaxFrames != -1) { Settings.Instance.MaxFrames = 10; } Application.targetFrameRate = Settings.Instance.MaxFrames; OnRockedInitialized.TryInvoke(); } catch (Exception ex) { Logger.LogException(ex); } }
static bool Prefix(RocketCommandManager __instance, IRocketPlayer player, IRocketCommand command, ref double __result) { if (!(player is UnturnedPlayer uPlayer)) { return(true); } __result = (int)GetCooldown(__instance, player, command, uPlayer.Reputation); return(false); }
public static double GetCooldown(RocketCommandManager manager, IRocketPlayer player, IRocketCommand command, int reputation) { IList cooldown = (IList)CooldownField.GetValue(manager); object rocketCommandCooldown = null; foreach (object iteration in cooldown) { IRocketCommand rocketCommand = (IRocketCommand)CommandField.GetValue(iteration); if (rocketCommand != command) { continue; } IRocketPlayer rocketPlayer = (IRocketPlayer)PlayerField.GetValue(iteration); if (rocketPlayer.Id != player.Id) { continue; } rocketCommandCooldown = iteration; break; } if (rocketCommandCooldown == null) { return(-1.0); } DateTime commandRequested = (DateTime)CommandRequestedField.GetValue(rocketCommandCooldown); Permission applyingPermission = (Permission)PermissionField.GetValue(rocketCommandCooldown); double totalSeconds = (DateTime.Now - commandRequested).TotalSeconds; double trueCooldown = applyingPermission.Cooldown; if (!player.HasPermission("repcooldown.exempt")) { trueCooldown *= ReputationCooldowns.Instance.GetCooldownMultiplier(reputation); } if (trueCooldown <= totalSeconds) { cooldown.Remove(rocketCommandCooldown); return(-1.0); } return(Math.Ceiling(trueCooldown - totalSeconds)); }
internal void Initialize() { Environment.Initialize(); try { Implementation.OnRocketImplementationInitialized += () => { gameObject.TryAddComponent <TaskDispatcher>(); gameObject.TryAddComponent <AutomaticShutdownWatchdog>(); if (Settings.Instance.RCON.Enabled) { gameObject.TryAddComponent <RCONServer>(); } }; Settings = new XMLFileAsset <RocketSettings>(Environment.SettingsFile); var settings = Settings.Instance; Translation = new XMLFileAsset <TranslationList>(string.Format(Environment.TranslationFile, settings.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Permissions = gameObject.TryAddComponent <RocketPermissionsManager>(); //Plugins = gameObject.TryAddComponent<RocketPluginManager>(); Plugins = new RocketPluginManager(); RocketPluginManager.Awake(); Commands = new RocketCommandManager(); Commands.Awake(); // Load Commands from Rocket.Core.Commands. Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); if (settings.MaxFrames < 10 && settings.MaxFrames != -1) { settings.MaxFrames = 10; } Application.targetFrameRate = settings.MaxFrames; OnRockedInitialized.TryInvoke(); Plugins.loadPlugins(); } catch (Exception ex) { Logging.Logger.LogException(ex); } }