public static void Process(WeaponData weapon) { var components = WeaponComponentCollection.GetComponentsFromHash(weapon.hash); foreach (var component in components) { if (weapon.components.ContainsKey((uint)component)) { continue; } var displayName = WeaponComponent.GetComponentDisplayNameFromHash(weapon.hash, component); var name = "COMPONENT_" + Enum.GetName(typeof(WeaponComponentHash), component)?.ToUnderscoreCase().ToUpper(); name = FixNameProcessor.FixWeaponName(name); var comp = new WeaponComponentData { name = name, displayName = displayName, displayDescription = displayName.ReplaceAt(2, 'D') }; comp.Hash(); if (comp.hash != component) { Console.Error("WRONG HASH! -> " + name); } Main.WeaponStorage.AddWeaponComponent(weapon, comp); } }
public static void Abort(string filename) { String basedirectory = ScriptDomain.CurrentDomain.AppDomain.BaseDirectory; filename = Path.Combine(basedirectory, filename); if (!File.Exists(filename)) { Console.Error("The file '" + filename + "' was not found"); return; } ScriptDomain.CurrentDomain.AbortScript(filename); }
public static void Load(string filename) { String basedirectory = ScriptDomain.CurrentDomain.AppDomain.BaseDirectory; if (!File.Exists(Path.Combine(basedirectory, filename))) { string[] files = Directory.GetFiles(basedirectory, filename, SearchOption.AllDirectories); if (files.Length != 1) { Console.Error("The file '" + filename + "' was not found in '" + basedirectory + "'"); return; } Console.Warn("The file '" + filename + "' was not found in '" + basedirectory + "', loading from '" + Path.GetDirectoryName(files[0].Substring(basedirectory.Length + 1)) + "' instead"); filename = files[0].Substring(basedirectory.Length + 1); } else { filename = Path.Combine(basedirectory, filename); } filename = Path.GetFullPath(filename); String extension = Path.GetExtension(filename).ToLower(); if (extension != ".cs" && extension != ".vb" && extension != ".dll") { Console.Error("The file '" + filename + "' was not recognized as a script file"); return; } foreach (var script in ScriptDomain.CurrentDomain.RunningScripts) { if (filename.Equals(script.Filename, StringComparison.OrdinalIgnoreCase) && script._running) { Console.Error("The script is already running"); return; } } ScriptDomain.CurrentDomain.StartScript(filename); }