Beispiel #1
0
        public static void TryListingPermissionsFrom(string line)
        {
            int length = "journeypermission_".Length;

            if (line.Length < length || !line.ToLower().StartsWith("journeypermission_"))
            {
                return;
            }
            string[] strArray = line.Substring(length).Split('=');
            int      result;

            if (strArray.Length != 2 || !int.TryParse(strArray[1].Trim(), out result))
            {
                return;
            }
            PowerPermissionLevel powerPermissionLevel = (PowerPermissionLevel)Utils.Clamp <int>(result, 0, 2);
            string lower = strArray[0].Trim().ToLower();

            CreativePowerManager.Initialize();
            ICreativePower creativePower;

            if (!CreativePowerManager.Instance._powersByName.TryGetValue(lower, out creativePower))
            {
                return;
            }
            creativePower.DefaultPermissionLevel = powerPermissionLevel;
            creativePower.CurrentPermissionLevel = powerPermissionLevel;
        }
        public static void TryListingPermissionsFrom(string line)
        {
            int length = "journeypermission_".Length;

            if (line.Length < length || !line.ToLower().StartsWith("journeypermission_"))
            {
                return;
            }
            string[] array = line.Substring(length).Split('=');
            if (array.Length == 2 && int.TryParse(array[1].Trim(), out int result))
            {
                PowerPermissionLevel powerPermissionLevel = (PowerPermissionLevel)Utils.Clamp(result, 0, 2);
                string key = array[0].Trim().ToLower();
                Initialize();
                if (Instance._powersByName.TryGetValue(key, out ICreativePower value))
                {
                    value.DefaultPermissionLevel = powerPermissionLevel;
                    value.CurrentPermissionLevel = powerPermissionLevel;
                }
            }
        }