void Awake() { instance = this; string allWeapon = (Resources.Load("Text/WeaponInfo") as TextAsset).text; string[] perWeapon = allWeapon.Split('\n'); foreach (string temp in perWeapon) { BaseWeapon b = new BaseWeapon(); string[] t = temp.Split(','); b.WeaponName = t[0]; b.WeaponClass = (WeaponType)Enum.Parse(typeof(WeaponType), t[1]); if (t[2] != "U/N") { b.Price = int.Parse(t[2]); } if (t[3] != "U/N") { b.MaxBulletQuantity = int.Parse(t[3]); b.CurBulletQuantity = b.MaxBulletQuantity; } if (t[4] != "U/N") { b.BackBulletQuantity = int.Parse(t[4]); b.MaxBackbackBulletQuantity = b.BackBulletQuantity; } b.IsHaveSpecial = bool.Parse(t[5]); weaponDict.Add(t[0], b); } }
internal void SetupInternalDictionaries() { string localizedName = String.Empty; WeaponDictionary weapons = GetWeaponDefines(); WeaponDictionaryByLocalizedName = new Dictionary <string, Weapon>(); foreach (Weapon weapon in weapons) { localizedName = GetLocalized(weapon.Name, String.Format("global.Weapons.{0}", weapon.Name.ToLower())); if (WeaponDictionaryByLocalizedName.ContainsKey(localizedName) == false) { WeaponDictionaryByLocalizedName.Add(localizedName, weapon); } } SpecializationDictionary specializations = GetSpecializationDefines(); SpecializationDictionaryByLocalizedName = new Dictionary <string, Specialization>(); foreach (Specialization specialization in specializations) { localizedName = GetLocalized(specialization.Name, String.Format("global.Specialization.{0}", specialization.Name.ToLower())); if (SpecializationDictionaryByLocalizedName.ContainsKey(localizedName) == false) { SpecializationDictionaryByLocalizedName.Add(localizedName, specialization); } } }
public WeaponDictionary GetWeaponDefines() { WeaponDictionary dicReturn = default(WeaponDictionary); if (_getWeaponDefinesDelegate != null) { dicReturn = _getWeaponDefinesDelegate(); } return(dicReturn); }
public WeaponDictionary GetWeaponDefines() { WeaponDictionary dicReturn = default(WeaponDictionary); if (this.m_delGetWeaponDefines != null) { dicReturn = this.m_delGetWeaponDefines(); } return(dicReturn); }
private DamageTypes GetWeaponDamageType(string weaponName) { WeaponDictionary weapons = this.GetWeaponDefines(); DamageTypes returnDamageType = DamageTypes.None; if (weapons.Contains(weaponName) == true) { returnDamageType = weapons[weaponName].Damage; } return(returnDamageType); }
public void OnPluginLoaded(string strHostName, string strPort, string strPRoConVersion) { rulz_vars = new VarsClass(String.Format("{0}_{1}", strHostName, strPort)); WriteConsole("ProconRulz loaded"); try { weaponDefines = GetWeaponDefines(); } catch { WriteConsole("ProconRulz: ^1failed to load weapon definitions"); } try { specDefines = GetSpecializationDefines(); } catch { WriteConsole("ProconRulz: ^1failed to load spec definitions"); } WriteConsole(String.Format("weaponDefines size = {0}, specDefines size = {1}", weaponDefines.Count, specDefines.Count)); this.RegisterEvents(this.GetType().Name, "OnPlayerSpawned", "OnPlayerKilled", "OnPlayerTeamChange", "OnPlayerSquadChange", "OnPlayerJoin", "OnPlayerLeft", "OnListPlayers", "OnReservedSlotsList", "OnRoundOver", "OnRoundOverPlayers", "OnRoundOverTeamScores", "OnLoadingLevel", // for BFBC2 "OnLevelLoaded", // for BF3 "OnCurrentLevel", // BFBC2 only "OnGlobalChat", "OnTeamChat", "OnSquadChat", "OnServerInfo", "OnPunkbusterPlayerInfo" ); // exec listPlayers to initialise players global ExecuteCommand("procon.protected.send", "admin.listPlayers", "all"); }
private void Awake() { Instance = this; InitializeWeaponData(); }
private void InitialSetup() { if (Game != null) { IsLoadingSavingConnectionConfig = true; AssignEventHandlers(); // Assume full access until we're told otherwise. Layer.Initialize(Parent, this); // I may move these events to within Layer, depends on the end of the restructure. Layer.LayerOnline += new PRoConLayer.LayerEmptyParameterHandler(Layer_LayerOnline); Layer.LayerOffline += new PRoConLayer.LayerEmptyParameterHandler(Layer_LayerOffline); Layer.AccountPrivileges.AccountPrivilegeAdded += new AccountPrivilegeDictionary.AccountPrivilegeAlteredHandler(AccountPrivileges_AccountPrivilegeAdded); Layer.AccountPrivileges.AccountPrivilegeRemoved += new AccountPrivilegeDictionary.AccountPrivilegeAlteredHandler(AccountPrivileges_AccountPrivilegeRemoved); foreach (AccountPrivilege apPriv in Layer.AccountPrivileges) { apPriv.AccountPrivilegesChanged += new AccountPrivilege.AccountPrivilegesChangedHandler(item_AccountPrivilegesChanged); } Privileges = new CPrivileges(CPrivileges.FullPrivilegesFlags); EventsLogging = new EventCaptures(this); Console = new ConnectionConsole(this); PunkbusterConsole = new PunkbusterConsole(this); ChatConsole = new ChatConsole(this); PluginConsole = new PluginConsole(this); MapGeometry = new MapGeometry(this); MapGeometry.MapZones.MapZoneAdded += new MapZoneDictionary.MapZoneAlteredHandler(MapZones_MapZoneAdded); MapGeometry.MapZones.MapZoneChanged += new MapZoneDictionary.MapZoneAlteredHandler(MapZones_MapZoneChanged); MapGeometry.MapZones.MapZoneRemoved += new MapZoneDictionary.MapZoneAlteredHandler(MapZones_MapZoneRemoved); if (CurrentServerInfo == null) { CurrentServerInfo = new CServerInfo(); } ListSettings = new ListsSettings(this); ServerSettings = new ServerSettings(this); PlayerListSettings = new PlayerListSettings(); PlayerList = new PlayerDictionary(); TeamNameList = new List<CTeamName>(); MapListPool = new NotificationList<CMap>(); ReservedSlotList = new NotificationList<string>(); Variables = new VariableDictionary(); SV_Variables = new VariableDictionary(); Reasons = new NotificationList<string>(); FullVanillaBanList = new List<CBanInfo>(); FullTextChatModerationList = new TextChatModerationDictionary(); Weapons = new WeaponDictionary(); Specializations = new SpecializationDictionary(); if (Regex.Match(HostName, @"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$").Success == true) { Variables.SetVariable("SERVER_COUNTRY", Parent.GetCountryName(HostName)); Variables.SetVariable("SERVER_COUNTRY_CODE", Parent.GetCountryCode(HostName)); } else { IPAddress ipServer = FrostbiteConnection.ResolveHostName(HostName); Variables.SetVariable("SERVER_COUNTRY", Parent.GetCountryName(ipServer.ToString())); Variables.SetVariable("SERVER_COUNTRY_CODE", Parent.GetCountryCode(ipServer.ToString())); } Console.Logging = Parent.OptionsSettings.ConsoleLogging; EventsLogging.Logging = Parent.OptionsSettings.EventsLogging; ChatConsole.Logging = Parent.OptionsSettings.ChatLogging; PluginConsole.Logging = Parent.OptionsSettings.PluginLogging; //this.m_blLoadingSavingConnectionConfig = true; if (CurrentServerInfo.GameMod == GameMods.None) { ExecuteConnectionConfig(Game.GameType + ".def", 0, null, false); } else { ExecuteConnectionConfig(Game.GameType + "." + CurrentServerInfo.GameMod + ".def", 0, null, false); } // load override global_vars.def ExecuteGlobalVarsConfig("global_vars.def", 0, null); ExecuteConnectionConfig("reasons.cfg", 0, null, false); lock (Parent) { if (Username.Length == 0 || Parent.OptionsSettings.LayerHideLocalPlugins == false) { CompilePlugins(Parent.OptionsSettings.PluginPermissions); } } if (Parent.OptionsSettings.UsePluginOldStyleLoad == true) { ExecuteConnectionConfig(FileHostNamePort + ".cfg", 0, null, false); } //this.m_blLoadingSavingConnectionConfig = false; // this.ManuallyDisconnected = true; // this.ConnectionError = false; BeginLoginSequence(); if (Parent.OptionsSettings.UsePluginOldStyleLoad == false) { ExecuteConnectionConfig(FileHostNamePort + ".cfg", 0, null, true); } IsLoadingSavingConnectionConfig = false; } }
private void Start() { TestVar = WeaponDictionary.Instance; }
private void InitialSetup() { if (Game != null) { IsLoadingSavingConnectionConfig = true; AssignEventHandlers(); // Assume full access until we're told otherwise. Layer.Initialize(Parent, this); // I may move these events to within Layer, depends on the end of the restructure. Layer.LayerStarted += Layer_LayerOnline; Layer.LayerShutdown += Layer_LayerOffline; Layer.AccountPrivileges.AccountPrivilegeAdded += new AccountPrivilegeDictionary.AccountPrivilegeAlteredHandler(AccountPrivileges_AccountPrivilegeAdded); Layer.AccountPrivileges.AccountPrivilegeRemoved += new AccountPrivilegeDictionary.AccountPrivilegeAlteredHandler(AccountPrivileges_AccountPrivilegeRemoved); foreach (AccountPrivilege apPriv in Layer.AccountPrivileges) { apPriv.AccountPrivilegesChanged += new AccountPrivilege.AccountPrivilegesChangedHandler(item_AccountPrivilegesChanged); } Privileges = new CPrivileges(CPrivileges.FullPrivilegesFlags); EventsLogging = new EventCaptures(this); Console = new ConnectionConsole(this); PunkbusterConsole = new PunkbusterConsole(this); ChatConsole = new ChatConsole(this); PluginConsole = new PluginConsole(this); MapGeometry = new MapGeometry(this); MapGeometry.MapZones.MapZoneAdded += new MapZoneDictionary.MapZoneAlteredHandler(MapZones_MapZoneAdded); MapGeometry.MapZones.MapZoneChanged += new MapZoneDictionary.MapZoneAlteredHandler(MapZones_MapZoneChanged); MapGeometry.MapZones.MapZoneRemoved += new MapZoneDictionary.MapZoneAlteredHandler(MapZones_MapZoneRemoved); if (CurrentServerInfo == null) { CurrentServerInfo = new CServerInfo(); } ListSettings = new ListsSettings(this); ServerSettings = new ServerSettings(this); PlayerListSettings = new PlayerListSettings(); PlayerList = new PlayerDictionary(); TeamNameList = new List<CTeamName>(); MapListPool = new NotificationList<CMap>(); ReservedSlotList = new NotificationList<string>(); SpectatorList = new NotificationList<string>(); Variables = new VariableDictionary(); SV_Variables = new VariableDictionary(); Reasons = new NotificationList<string>(); FullVanillaBanList = new List<CBanInfo>(); FullTextChatModerationList = new TextChatModerationDictionary(); Weapons = new WeaponDictionary(); Specializations = new SpecializationDictionary(); if (Regex.Match(HostName, @"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$").Success == true) { Variables.SetVariable("SERVER_COUNTRY", Parent.GetCountryName(HostName)); Variables.SetVariable("SERVER_COUNTRY_CODE", Parent.GetCountryCode(HostName)); } else { IPAddress ipServer = FrostbiteConnection.ResolveHostName(HostName); Variables.SetVariable("SERVER_COUNTRY", Parent.GetCountryName(ipServer.ToString())); Variables.SetVariable("SERVER_COUNTRY_CODE", Parent.GetCountryCode(ipServer.ToString())); } Console.Logging = Parent.OptionsSettings.ConsoleLogging; EventsLogging.Logging = Parent.OptionsSettings.EventsLogging; ChatConsole.Logging = Parent.OptionsSettings.ChatLogging; PluginConsole.Logging = Parent.OptionsSettings.PluginLogging; //this.m_blLoadingSavingConnectionConfig = true; if (CurrentServerInfo.GameMod == GameMods.None) { ExecuteConnectionConfig(Game.GameType + ".def", 0, null, false); } else { ExecuteConnectionConfig(Game.GameType + "." + CurrentServerInfo.GameMod + ".def", 0, null, false); } // load override global_vars.def ExecuteGlobalVarsConfig("global_vars.def", 0, null); ExecuteConnectionConfig("reasons.cfg", 0, null, false); lock (Parent) { if (Username.Length == 0 || Parent.OptionsSettings.LayerHideLocalPlugins == false) { CompilePlugins(Parent.OptionsSettings.PluginPermissions); } } string configDirectoryPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs"), FileHostNamePort); string oldConfigFilePath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs"), string.Format("{0}.cfg", FileHostNamePort)); if (File.Exists(oldConfigFilePath) == false && Directory.Exists(configDirectoryPath) == true) { string[] pluginConfigPaths = Directory.GetFiles(configDirectoryPath, "*.cfg"); if (Parent.OptionsSettings.UsePluginOldStyleLoad == true) { foreach (string pluginConfigPath in pluginConfigPaths) { ExecuteConnectionConfig(pluginConfigPath, 0, null, false); } } BeginLoginSequence(); if (Parent.OptionsSettings.UsePluginOldStyleLoad == false) { foreach (string pluginConfigPath in pluginConfigPaths) { ExecuteConnectionConfig(pluginConfigPath, 0, null, true); } } IsLoadingSavingConnectionConfig = false; } else { if (Parent.OptionsSettings.UsePluginOldStyleLoad == true) { ExecuteConnectionConfig(FileHostNamePort + ".cfg", 0, null, false); } BeginLoginSequence(); if (Parent.OptionsSettings.UsePluginOldStyleLoad == false) { ExecuteConnectionConfig(FileHostNamePort + ".cfg", 0, null, true); } IsLoadingSavingConnectionConfig = false; SaveConnectionConfig(); try { if (Directory.Exists(configDirectoryPath) == true && File.Exists(Path.Combine(configDirectoryPath, string.Format("{0}.cfg", FileHostNamePort))) == true) { try { if (File.Exists(oldConfigFilePath) == true) { File.Delete(oldConfigFilePath); } } catch (Exception e) { FrostbiteConnection.LogError("RemoveOldConfig", String.Empty, e); } } } catch (Exception e) { FrostbiteConnection.LogError("MigrateConfig", "Error writing new config structure during migration", e); } } } }