float.Parse(string, System.Globalization.NumberStyles, System.IFormatProvider)

Here are the examples of the csharp api float.Parse(string, System.Globalization.NumberStyles, System.IFormatProvider) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

613 Examples 7

19 View Source File : RoadSigns.cs
License : GNU General Public License v3.0
Project Creator : Albo1125

public static void RoadSignsMainLogic()
        {
            GameFiber.StartNew(delegate
            {
                createRoadSignsMenu();
                try
                {
                    while (true)
                    {
                        GameFiber.Yield();
                        if (PlaceSignMenu.Visible && EnablePreviewItem.Checked)
                        {
                            if (TrafficSignPreview.Exists())
                            {
                                if (TrafficSignPreview.DistanceTo2D(DetermineSignSpawn(SpawnDirectionLisreplacedem.Collection[SpawnDirectionLisreplacedem.Index].Value.ToString(), float.Parse(SpawnMultiplierLisreplacedem.Collection[SpawnMultiplierLisreplacedem.Index].Value.ToString()))) > 0.4f)
                                {

                                    TrafficSignPreview.Position = DetermineSignSpawn(SpawnDirectionLisreplacedem.Collection[SpawnDirectionLisreplacedem.Index].Value.ToString(), float.Parse(SpawnMultiplierLisreplacedem.Collection[SpawnMultiplierLisreplacedem.Index].Value.ToString()));
                                    TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f);
                                }
                                TrafficSignPreview.Rotation = RotationToPlaceAt;
                                if (barriersList.Collection[barriersList.Index].Value.ToString() == "Stripes Left")
                                {
                                    //TrafficSignPreview.Heading = Game.LocalPlayer.Character.Heading + 180f;
                                    TrafficSignPreview.Heading += 180f;
                                }
                                TrafficSignPreview.Heading += float.Parse(HeadingItem.Collection[HeadingItem.Index].Value.ToString());
                                int waitCount = 0;
                                
                                while (TrafficSignPreview.HeightAboveGround > 0.01f)
                                {
                                    GameFiber.Yield();
                                    TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z - (TrafficSignPreview.HeightAboveGround * 0.75f));
                                    //Game.LogTrivial("Heighaboveground: " + TrafficSignPreview.HeightAboveGround);
                                    waitCount++;
                                    if (waitCount >= 1000)
                                    {
                                        break;
                                    }

                                }
                                TrafficSignPreview.IsPositionFrozen = true;
                                TrafficSignPreview.Opacity = 0.7f;
                                TrafficSignPreview.NeedsCollision = false;
                                NativeFunction.Natives.SET_ENreplacedY_COLLISION(TrafficSignPreview, false, false);
                            }
                            if (SignTypeToPlace == SignTypes.Barrier && !TrafficSignPreview.Exists())
                            {
                                if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); }
                                TrafficSignPreview = new Rage.Object(barriersToChooseFrom[barriersList.Index], DetermineSignSpawn(SpawnDirectionLisreplacedem.Collection[SpawnDirectionLisreplacedem.Index].Value.ToString(), float.Parse(SpawnMultiplierLisreplacedem.Collection[SpawnMultiplierLisreplacedem.Index].Value.ToString())));
                                TrafficSignPreview.Rotation = RotationToPlaceAt;
                                TrafficSignPreview.NeedsCollision = false;
                                
                            }
                            else if (SignTypeToPlace == SignTypes.Cone && !TrafficSignPreview.Exists())
                            {
                                if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); }
                                TrafficSignPreview = new Rage.Object(conesToChooseFrom[conesList.Index], DetermineSignSpawn(SpawnDirectionLisreplacedem.Collection[SpawnDirectionLisreplacedem.Index].Value.ToString(), float.Parse(SpawnMultiplierLisreplacedem.Collection[SpawnMultiplierLisreplacedem.Index].Value.ToString())));
                                TrafficSignPreview.Rotation = RotationToPlaceAt;
                                TrafficSignPreview.NeedsCollision = false;
                                
                            }
                            
                        }
                        else
                        {
                            if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); }
                            
                        }

                        if (!PlaceSignMenu.Visible)
                        {
                            if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                            {
                                if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(placeSignShortcutKey, placeSignShortcutModifierKey))
                                {
                                    RotationToPlaceAt = Game.LocalPlayer.Character.Rotation;
                                    dropSign(SignTypeToPlace == SignTypes.Barrier ? barriersToChooseFrom[barriersList.Index] : conesToChooseFrom[conesList.Index], false, Game.LocalPlayer.Character.GetOffsetPositionFront(2), 0);
                                    Game.LogTrivial("Shortcut Sign dropped");
                                    Rage.Native.NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0);
                                }
                                else if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(removeAllSignsKey, removeAllSignsModifierKey))
                                {
                                    removeAllSigns();
                                }
                            }
                        }
                    }
                }
                catch
                {
                    removeAllSigns();
                    if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); }
                }
            });
        }

19 View Source File : LegendFont.cs
License : MIT License
Project Creator : AngeloCresta

private void ControlChange(object sender, System.EventArgs e)
		{
			// Set Font style.
			FontStyle fontStyle = FontStyle.Regular;
			if( ItalicCheck.Checked )
				fontStyle = (FontStyle)FontStyle.Italic;
			if( BoldCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Bold;
			if( UnderlineCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Underline;
			if( StrikeoutCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Strikeout;

			// Set replacedle font
			if(this.TheFont.SelectedIndex >= 0 && this.FontSize.SelectedIndex >= 0)
			{
				string font = this.TheFont.SelectedItem.ToString();
				float fontpoint = float.Parse(this.FontSize.SelectedItem.ToString());
				try
				{
					Chart1.Legends["Default"].Font = new Font(font, fontpoint, fontStyle);
				}
				catch
				{
					Chart1.Legends["Default"].Font = new Font("Arial", fontpoint, fontStyle);
				}
			}

			// Set replacedle color
			if(this.FontColorCombo.SelectedIndex >= 0)
			{
				Chart1.Legends["Default"].ForeColor = Color.FromName(this.FontColorCombo.SelectedItem.ToString());
			}
		}

19 View Source File : UGUIVector.cs
License : MIT License
Project Creator : aksyr

private void OnChangeValX(string val) {
			vectorNode.x = float.Parse(valX.text);
		}

19 View Source File : ItemOptionRandomParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<ItemOptionRandomMetadata> Parse()
    {
        List<ItemOptionRandomMetadata> items = new();
        Dictionary<int, List<ItemOptionRandom>> itemOptionsRandom = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("itemoption/option/random"))
            {
                continue;
            }

            XmlDoreplacedent innerDoreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList nodeList = innerDoreplacedent.SelectNodes("/ms2/option");
            string filename = Path.GetFileNameWithoutExtension(entry.Name);
            foreach (XmlNode node in nodeList)
            {
                int id = int.Parse(node.Attributes["code"]?.Value ?? "0");
                ItemOptionRandom itemOption = new();

                foreach (XmlNode item in node.Attributes)
                {
                    switch (item.Name)
                    {
                        case "grade":
                            itemOption.Rarity = byte.Parse(node.Attributes["grade"]?.Value ?? "0");
                            break;
                        case "optionNumPick":
                            itemOption.Slots = node.Attributes[item.Name].Value.Split(",").Select(byte.Parse).ToArray();
                            break;
                        case "multiply_factor":
                            itemOption.MultiplyFactor = float.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "abp_rate_base":
                            itemOption.Stats.Add(new(StatId.PerfectGuard, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "asp_value_base":
                            itemOption.Stats.Add(new(StatId.AttackSpeed, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "atp_value_base":
                            itemOption.Stats.Add(new(StatId.Accuracy, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "bap_value_base":
                            itemOption.Stats.Add(new(StatId.BonusAtk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "cad_value_base":
                            itemOption.Stats.Add(new(StatId.CritDamage, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "cap_value_base":
                            itemOption.Stats.Add(new(StatId.CritRate, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "car_value_base":
                            itemOption.Stats.Add(new(StatId.CritEvasion, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "dex_value_base":
                            itemOption.Stats.Add(new(StatId.Dex, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "evp_value_base":
                            itemOption.Stats.Add(new(StatId.Evasion, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "finaladditionaldamage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.TotalDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "firedamage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.FireDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "firedamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.FireDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "heal_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.Heal, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "hp_rgp_value_base":
                            itemOption.Stats.Add(new(StatId.HpRegen, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "hp_value_base":
                            itemOption.Stats.Add(new(StatId.Hp, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "icedamage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.IceDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "icedamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.IceDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "int_value_base":
                            itemOption.Stats.Add(new(StatId.Int, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "killhprestore_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.HpOnKill, 0, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "knockbackreduce_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.KnockbackReduce, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "lddincrease_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.RangedDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "longdistancedamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.RangedDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "lightdamage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.HolyDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "lightdamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.HolyDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "luk_value_base":
                            itemOption.Stats.Add(new(StatId.Luk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "map_value_base":
                            itemOption.Stats.Add(new(StatId.MagicAtk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "mar_value_base":
                            itemOption.Stats.Add(new(StatId.MagicRes, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "marpen_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.MagicPiercing, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "msp_value_base":
                            itemOption.Stats.Add(new(StatId.MovementSpeed, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "ndd_value_base":
                            itemOption.Stats.Add(new(StatId.Defense, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "nddincrease_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.MeleeDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "neardistancedamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.MeleeDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "pap_value_base":
                            itemOption.Stats.Add(new(StatId.PhysicalAtk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "par_value_base":
                            itemOption.Stats.Add(new(StatId.PhysicalRes, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "parpen_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PhysicalPiercing, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "pen_rate_base":
                            itemOption.Stats.Add(new(StatId.Pierce, float.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "poisondamage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PoisonDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "poisondamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PoisonDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "sgi_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.BossDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "skillcooldown_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.CooldownReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "str_value_base":
                            itemOption.Stats.Add(new(StatId.Str, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "stunreduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.StunReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "thunderdamage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ElectricDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "thunderdamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ElectricDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "wapmax_value_base":
                            itemOption.Stats.Add(new(StatId.MaxWeaponAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "wapmin_value_base":
                            itemOption.Stats.Add(new(StatId.MinWeaponAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "bap_pet_value_base":
                            itemOption.Stats.Add(new(StatId.PetBonusAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "receivedhealincrease_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.AllyRecovery, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "reduce_darkstream_recive_damage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DarkDescentDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "smd_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.MesoBonus, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "sss_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.SwimSpeed, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "wapmin_rate_base":
                            itemOption.Stats.Add(new(StatId.MinWeaponAtk, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "wapmax_rate_base":
                            itemOption.Stats.Add(new(StatId.MaxWeaponAtk, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "pvpdamagereduce_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PvPDefense, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "pvpdamageincrease_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PvPDamage, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_pvp_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PvPExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_honor_token_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ValorTokens, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npckilldropitemincrate_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DropRate, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_ox_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.OXQuizExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_finalsurvival_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.SoleSurvivorExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_trapmaster_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.TrapMasterExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_crazyrunner_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.CrazyRunnerExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_escape_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.LudiEscapeExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_springbeach_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.SpringBeachExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_dancedance_exp_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DanceDanceExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_ox_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.OXMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_finalsurvival_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.SoleSurvivorMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_trapmaster_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.TrapMasterMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_crazyrunner_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.CrazyRunnerMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_escape_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.LudiEscapeMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_springbeach_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.SpringBeachMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_dancedance_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DanceDanceStopMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "seg_fishingreward_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.FishingExp, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "seg_playinstrumentreward_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PerformanceExp, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "npc_hit_reward_sp_ball_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.GenerateSpiritOrbs, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npc_hit_reward_ep_ball_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.GenerateStaminaOrbs, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "complete_fieldmission_msp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ExploredAreasMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_glide_vertical_velocity_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.AirMountAscentSpeed, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "fishing_double_mastery_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DoubleFishingMastery, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "playinstrument_double_mastery_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DoublePerformanceMastery, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "gathering_double_mastery_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DoubleForagingMastery, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "farming_double_mastery_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DoubleFarmingMastery, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "mining_double_mastery_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DoubleMiningMastery, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "breeding_double_mastery_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DoubleRanchingMastery, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "improve_darkstream_damage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DarkDescentDamageBonus, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_chaosraid_wap_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ChaosRaidWeaponAttack, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_chaosraid_asp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ChaosRaidAttackSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_chaosraid_atp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ChaosRaidAccuracy, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_chaosraid_hp_value_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.ChaosRaidHealth, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "darkdamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DarkDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "darkdamage_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.DarkDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "pvpdamageincrease_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PvPDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "pvpdamagereduce_rate_base":
                            itemOption.SpecialStats.Add(new(SpecialStatId.PvPDefense, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "additionaleffect_95000012_value_base":
                        case "additionaleffect_95000014_value_base":
                        case "hiddenbapadd_value_base":
                        case "hiddennddadd_value_base":
                        case "hiddenwapadd_value_base":
                        case "nddcalibrationfactor_rate_base":
                        case "wapcalibrationfactor_rate_base":
                        case "conditionreduce_rate_base":
                        case "sgi_target":
                        case "code":
                            break;
                    }
                }

                if (itemOptionsRandom.ContainsKey(id))
                {
                    itemOptionsRandom[id].Add(itemOption);
                }
                else
                {
                    itemOptionsRandom[id] = new()
                    {
                        itemOption
                    };
                }
            }

            foreach (KeyValuePair<int, List<ItemOptionRandom>> optionsData in itemOptionsRandom)
            {
                ItemOptionRandomMetadata metadata = new();
                metadata.Id = optionsData.Key;
                metadata.ItemOptions.AddRange(optionsData.Value);
                items.Add(metadata);
            }
        }
        return items;
    }

19 View Source File : ItemDropParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<ItemDropMetadata> Parse()
    {
        Dictionary<int, List<DropGroup>> itemGroups = new();
        List<ItemDropMetadata> drops = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("table/individualitemdrop") && !entry.Name.StartsWith("table/na/individualitemdrop"))
            {
                continue;
            }

            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList individualBoxItems = doreplacedent.SelectNodes($"/ms2/individualDropBox");
            foreach (XmlNode node in individualBoxItems)
            {
                string locale = node.Attributes["locale"]?.Value ?? "";

                if (locale != "NA" && locale != "")
                {
                    continue;
                }

                int boxId = int.Parse(node.Attributes["individualDropBoxID"].Value);
                int dropGroupId = int.Parse(node.Attributes["dropGroup"].Value);

                DropGroupContent contents = new();

                List<int> itemIds = new()
                {
                    int.Parse(node.Attributes["item"].Value)
                };

                if (node.Attributes["item2"] != null)
                {
                    itemIds.Add(int.Parse(node.Attributes["item2"].Value));
                }

                contents.SmartDropRate = int.Parse(node.Attributes["smartDropRate"]?.Value ?? "0");
                contents.EnchantLevel = byte.Parse(node.Attributes["enchantLevel"]?.Value ?? "0");

                if (node.Attributes["isApplySmartGenderDrop"] != null)
                {
                    contents.SmartGender = node.Attributes["isApplySmartGenderDrop"].Value.ToLower() == "true";
                }

                contents.MinAmount = float.Parse(node.Attributes["minCount"].Value);
                contents.MaxAmount = float.Parse(node.Attributes["maxCount"].Value);
                contents.Rarity = 1;

                _ = byte.TryParse(node.Attributes["PackageUIShowGrade"]?.Value ?? "1", out contents.Rarity);

                contents.ItemIds.AddRange(itemIds);
                DropGroup newGroup = new();

                if (itemGroups.ContainsKey(boxId))
                {
                    if (itemGroups[boxId].FirstOrDefault(x => x.Id == dropGroupId) != default)
                    {
                        DropGroup group = itemGroups[boxId].FirstOrDefault(x => x.Id == dropGroupId);
                        group.Contents.Add(contents);
                        continue;
                    }

                    newGroup.Id = dropGroupId;
                    newGroup.Contents.Add(contents);
                    itemGroups[boxId].Add(newGroup);
                    continue;
                }

                itemGroups[boxId] = new();
                newGroup = new();
                newGroup.Id = dropGroupId;
                newGroup.Contents.Add(contents);
                itemGroups[boxId].Add(newGroup);

            }

            foreach (KeyValuePair<int, List<DropGroup>> kvp in itemGroups)
            {
                ItemDropMetadata metadata = new();
                metadata.Id = kvp.Key;
                metadata.DropGroups = kvp.Value;
                drops.Add(metadata);
            }
        }
        return drops;
    }

19 View Source File : IRCompiler.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a

static float ParseR4(Token token) {
			return float.Parse(token.Image);
		}

19 View Source File : AnnotationAppearance.cs
License : MIT License
Project Creator : AngeloCresta

private void FontSize_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(FontName.SelectedItem != null)
				Chart1.Annotations[0].Font = new Font(FontName.SelectedItem.ToString(), float.Parse(FontSize.SelectedItem.ToString()));
		}

19 View Source File : FdbConverters.cs
License : MIT License
Project Creator : abdullin

private static void RegisterDefaultConverters()
		{
			//TODO: there is too much generic type combinations! need to refactor this ...

			RegisterUnsafe<bool, Slice>((value) => Slice.FromByte(value ? (byte)1 : default(byte)));
			RegisterUnsafe<bool, byte[]>((value) => Slice.FromByte(value ? (byte)1 : default(byte)).GetBytes());
			RegisterUnsafe<bool, string>((value) => value ? "true" : "false");
			RegisterUnsafe<bool, sbyte>((value) => value ? (sbyte)1 : default(sbyte));
			RegisterUnsafe<bool, byte>((value) => value ? (byte)1 : default(byte));
			RegisterUnsafe<bool, short>((value) => value ? (short)1 : default(short));
			RegisterUnsafe<bool, ushort>((value) => value ? (ushort)1 : default(ushort));
			RegisterUnsafe<bool, int>((value) => value ? 1 : default(int));
			RegisterUnsafe<bool, uint>((value) => value ? 1U : default(uint));
			RegisterUnsafe<bool, long>((value) => value ? 1L : default(long));
			RegisterUnsafe<bool, ulong>((value) => value ? 1UL : default(ulong));
			RegisterUnsafe<bool, double>((value) => value ? 0.0d : 1.0d);
			RegisterUnsafe<bool, float>((value) => value ? 0.0f : 1.0f);

			RegisterUnsafe<int, Slice>((value) => Slice.FromInt32(value));
			RegisterUnsafe<int, byte[]>((value) => Slice.FromInt32(value).GetBytes());
			RegisterUnsafe<int, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<int, bool>((value) => value != 0);
			RegisterUnsafe<int, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<int, byte>((value) => checked((byte)value));
			RegisterUnsafe<int, short>((value) => checked((short)value));
			RegisterUnsafe<int, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<int, uint>((value) => (uint)value);
			RegisterUnsafe<int, long>((value) => value);
			RegisterUnsafe<int, ulong>((value) => (ulong)value);
			RegisterUnsafe<int, double>((value) => value);
			RegisterUnsafe<int, float>((value) => checked((float)value));
			RegisterUnsafe<int, FdbTupleAlias>((value) => (FdbTupleAlias)value);

			RegisterUnsafe<uint, Slice>((value) => Slice.FromUInt64(value));
			RegisterUnsafe<uint, byte[]>((value) => Slice.FromUInt64(value).GetBytes());
			RegisterUnsafe<uint, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<uint, bool>((value) => value != 0);
			RegisterUnsafe<uint, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<uint, byte>((value) => checked((byte)value));
			RegisterUnsafe<uint, short>((value) => checked((short)value));
			RegisterUnsafe<uint, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<uint, int>((value) => (int)value);
			RegisterUnsafe<uint, long>((value) => value);
			RegisterUnsafe<uint, ulong>((value) => value);
			RegisterUnsafe<uint, double>((value) => value);
			RegisterUnsafe<uint, float>((value) => checked((float)value));

			RegisterUnsafe<long, Slice>((value) => Slice.FromInt64(value));
			RegisterUnsafe<long, byte[]>((value) => Slice.FromInt64(value).GetBytes());
			RegisterUnsafe<long, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<long, bool>((value) => value != 0);
			RegisterUnsafe<long, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<long, byte>((value) => checked((byte)value));
			RegisterUnsafe<long, short>((value) => checked((short)value));
			RegisterUnsafe<long, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<long, int>((value) => checked((int)value));
			RegisterUnsafe<long, uint>((value) => (uint)value);
			RegisterUnsafe<long, ulong>((value) => (ulong)value);
			RegisterUnsafe<long, double>((value) => checked((double)value));
			RegisterUnsafe<long, float>((value) => checked((float)value));
			RegisterUnsafe<long, TimeSpan>((value) => TimeSpan.FromTicks(value));
			RegisterUnsafe<long, Uuid64>((value) => new Uuid64(value));
			RegisterUnsafe<long, System.Net.IPAddress>((value) => new System.Net.IPAddress(value));

			RegisterUnsafe<ulong, Slice>((value) => Slice.FromUInt64(value));
			RegisterUnsafe<ulong, byte[]>((value) => Slice.FromUInt64(value).GetBytes());
			RegisterUnsafe<ulong, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<ulong, bool>((value) => value != 0);
			RegisterUnsafe<ulong, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<ulong, byte>((value) => checked((byte)value));
			RegisterUnsafe<ulong, short>((value) => checked((short)value));
			RegisterUnsafe<ulong, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<ulong, int>((value) => checked((int)value));
			RegisterUnsafe<ulong, uint>((value) => checked((uint)value));
			RegisterUnsafe<ulong, long>((value) => checked((long)value));
			RegisterUnsafe<ulong, double>((value) => checked((double)value));
			RegisterUnsafe<ulong, float>((value) => checked((float)value));
			RegisterUnsafe<ulong, Uuid64>((value) => new Uuid64(value));
			RegisterUnsafe<ulong, TimeSpan>((value) => TimeSpan.FromTicks(checked((long)value)));

			RegisterUnsafe<short, Slice>((value) => Slice.FromInt32(value));
			RegisterUnsafe<short, byte[]>((value) => Slice.FromInt32(value).GetBytes());
			RegisterUnsafe<short, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<short, bool>((value) => value != 0);
			RegisterUnsafe<short, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<short, byte>((value) => checked((byte)value));
			RegisterUnsafe<short, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<short, int>((value) => value);
			RegisterUnsafe<short, uint>((value) => checked((uint)value));
			RegisterUnsafe<short, long>((value) => value);
			RegisterUnsafe<short, ulong>((value) => checked((ulong)value));
			RegisterUnsafe<short, double>((value) => value);
			RegisterUnsafe<short, float>((value) => value);
			RegisterUnsafe<short, FdbTupleAlias>((value) => (FdbTupleAlias)value);

			RegisterUnsafe<ushort, Slice>((value) => Slice.FromUInt64(value));
			RegisterUnsafe<ushort, byte[]>((value) => Slice.FromUInt64(value).GetBytes());
			RegisterUnsafe<ushort, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<ushort, bool>((value) => value != 0);
			RegisterUnsafe<ushort, byte>((value) => checked((byte)value));
			RegisterUnsafe<ushort, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<ushort, short>((value) => checked((short)value));
			RegisterUnsafe<ushort, int>((value) => value);
			RegisterUnsafe<ushort, uint>((value) => value);
			RegisterUnsafe<ushort, long>((value) => value);
			RegisterUnsafe<ushort, ulong>((value) => value);
			RegisterUnsafe<ushort, double>((value) => value);
			RegisterUnsafe<ushort, float>((value) => value);

			RegisterUnsafe<byte, Slice>((value) => Slice.FromInt32(value));
			RegisterUnsafe<byte, byte[]>((value) => Slice.FromInt32(value).GetBytes());
			RegisterUnsafe<byte, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<byte, bool>((value) => value != 0);
			RegisterUnsafe<byte, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<byte, short>((value) => value);
			RegisterUnsafe<byte, ushort>((value) => value);
			RegisterUnsafe<byte, int>((value) => value);
			RegisterUnsafe<byte, uint>((value) => value);
			RegisterUnsafe<byte, long>((value) => value);
			RegisterUnsafe<byte, ulong>((value) => value);
			RegisterUnsafe<byte, double>((value) => value);
			RegisterUnsafe<byte, float>((value) => value);
			RegisterUnsafe<byte, FdbTupleAlias>((value) => (FdbTupleAlias)value);

			RegisterUnsafe<sbyte, Slice>((value) => Slice.FromInt64(value));
			RegisterUnsafe<sbyte, byte[]>((value) => Slice.FromInt64(value).GetBytes());
			RegisterUnsafe<sbyte, string>((value) => value.ToString(CultureInfo.InvariantCulture)); //TODO: string table!
			RegisterUnsafe<sbyte, bool>((value) => value != 0);
			RegisterUnsafe<sbyte, byte>((value) => checked((byte)value));
			RegisterUnsafe<sbyte, short>((value) => value);
			RegisterUnsafe<sbyte, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<sbyte, int>((value) => value);
			RegisterUnsafe<sbyte, uint>((value) => checked((uint)value));
			RegisterUnsafe<sbyte, long>((value) => value);
			RegisterUnsafe<sbyte, ulong>((value) => checked((ulong)value));
			RegisterUnsafe<sbyte, double>((value) => value);
			RegisterUnsafe<sbyte, float>((value) => value);

			RegisterUnsafe<float, Slice>((value) => Slice.FromSingle(value));
			RegisterUnsafe<float, byte[]>((value) => Slice.FromSingle(value).GetBytes());
			RegisterUnsafe<float, string>((value) => value.ToString("R", CultureInfo.InvariantCulture));
			RegisterUnsafe<float, bool>((value) => !(value == 0f || float.IsNaN(value)));
			RegisterUnsafe<float, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<float, byte>((value) => checked((byte)value));
			RegisterUnsafe<float, short>((value) => checked((short)value));
			RegisterUnsafe<float, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<float, int>((value) => checked((int)value));
			RegisterUnsafe<float, uint>((value) => (uint)value);
			RegisterUnsafe<float, long>((value) => checked((long)value));
			RegisterUnsafe<float, ulong>((value) => (ulong)value);
			RegisterUnsafe<float, double>((value) => value);

			RegisterUnsafe<double, Slice>((value) => Slice.FromDouble(value));
			RegisterUnsafe<double, byte[]>((value) => Slice.FromDouble(value).GetBytes());
			RegisterUnsafe<double, string>((value) => value.ToString("R", CultureInfo.InvariantCulture));
			RegisterUnsafe<double, bool>((value) => !(value == 0d || double.IsNaN(value)));
			RegisterUnsafe<double, sbyte>((value) => checked((sbyte)value));
			RegisterUnsafe<double, byte>((value) => checked((byte)value));
			RegisterUnsafe<double, short>((value) => checked((short)value));
			RegisterUnsafe<double, ushort>((value) => checked((ushort)value));
			RegisterUnsafe<double, int>((value) => checked((int)value));
			RegisterUnsafe<double, uint>((value) => (uint)value);
			RegisterUnsafe<double, long>((value) => checked((long)value));
			RegisterUnsafe<double, ulong>((value) => (ulong)value);
			RegisterUnsafe<double, float>((value) => checked((float)value));

			RegisterUnsafe<string, Slice>((value) => Slice.FromString(value));
			RegisterUnsafe<string, byte[]>((value) => Slice.FromString(value).GetBytes());
			RegisterUnsafe<string, bool>((value) => !string.IsNullOrEmpty(value));
			RegisterUnsafe<string, sbyte>((value) => string.IsNullOrEmpty(value) ? default(sbyte) : SByte.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, byte>((value) => string.IsNullOrEmpty(value) ? default(byte) : Byte.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, short>((value) => string.IsNullOrEmpty(value) ? default(short) : Int16.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, ushort>((value) => string.IsNullOrEmpty(value) ? default(ushort) : UInt16.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, int>((value) => string.IsNullOrEmpty(value) ? default(int) : Int32.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, uint>((value) => string.IsNullOrEmpty(value) ? default(uint) : UInt32.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, long>((value) => string.IsNullOrEmpty(value) ? default(long) : Int64.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, ulong>((value) => string.IsNullOrEmpty(value) ? default(ulong) : UInt64.Parse(value, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, float>((value) => string.IsNullOrEmpty(value) ? default(float) : Single.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, double>((value) => string.IsNullOrEmpty(value) ? default(double) : Double.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture));
			RegisterUnsafe<string, Guid>((value) => string.IsNullOrEmpty(value) ? default(Guid) : Guid.Parse(value));
			RegisterUnsafe<string, Uuid128>((value) => string.IsNullOrEmpty(value) ? default(Uuid128) : Uuid128.Parse(value));
			RegisterUnsafe<string, Uuid64>((value) => string.IsNullOrEmpty(value) ? default(Uuid64) : Uuid64.Parse(value));
			RegisterUnsafe<string, System.Net.IPAddress>((value) => string.IsNullOrEmpty(value) ? default(System.Net.IPAddress) : System.Net.IPAddress.Parse(value));

			RegisterUnsafe<byte[], Slice>((value) => Slice.Create(value));
			RegisterUnsafe<byte[], string>((value) => value == null ? default(string) : value.Length == 0 ? String.Empty : System.Convert.ToBase64String(value));
			RegisterUnsafe<byte[], bool>((value) => value != null && value.Length > 0);
			RegisterUnsafe<byte[], sbyte>((value) => value == null ? default(sbyte) : Slice.Create(value).ToSByte());
			RegisterUnsafe<byte[], byte>((value) => value == null ? default(byte) : Slice.Create(value).ToByte());
			RegisterUnsafe<byte[], short>((value) => value == null ? default(short) : Slice.Create(value).ToInt16());
			RegisterUnsafe<byte[], ushort>((value) => value == null ? default(ushort) : Slice.Create(value).ToUInt16());
			RegisterUnsafe<byte[], int>((value) => value == null ? 0 : Slice.Create(value).ToInt32());
			RegisterUnsafe<byte[], uint>((value) => value == null ? 0U : Slice.Create(value).ToUInt32());
			RegisterUnsafe<byte[], long>((value) => value == null ? 0L : Slice.Create(value).ToInt64());
			RegisterUnsafe<byte[], ulong>((value) => value == null ? 0UL : Slice.Create(value).ToUInt64());
			RegisterUnsafe<byte[], Guid>((value) => value == null || value.Length == 0 ? default(Guid) : new Uuid128(value).ToGuid());
			RegisterUnsafe<byte[], Uuid128>((value) => value == null || value.Length == 0 ? default(Uuid128) : new Uuid128(value));
			RegisterUnsafe<byte[], Uuid64>((value) => value == null || value.Length == 0 ? default(Uuid64) : new Uuid64(value));
			RegisterUnsafe<byte[], TimeSpan>((value) => value == null ? TimeSpan.Zero : TimeSpan.FromTicks(Slice.Create(value).ToInt64()));
			RegisterUnsafe<byte[], System.Net.IPAddress>((value) => value == null || value.Length == 0 ? default(System.Net.IPAddress) : new System.Net.IPAddress(value));

			RegisterUnsafe<Guid, Slice>((value) => Slice.FromGuid(value));
			RegisterUnsafe<Guid, byte[]>((value) => Slice.FromGuid(value).GetBytes());
			RegisterUnsafe<Guid, string>((value) => value.ToString("D", null));
			RegisterUnsafe<Guid, Uuid128>((value) => new Uuid128(value));
			RegisterUnsafe<Guid, bool>((value) => value != Guid.Empty);
			RegisterUnsafe<Guid, System.Net.IPAddress>((value) => new System.Net.IPAddress(new Uuid128(value).ToByteArray()));

			RegisterUnsafe<Uuid128, Slice>((value) => value.ToSlice());
			RegisterUnsafe<Uuid128, byte[]>((value) => value.ToByteArray());
			RegisterUnsafe<Uuid128, string>((value) => value.ToString("D", null));
			RegisterUnsafe<Uuid128, Guid>((value) => value.ToGuid());
			RegisterUnsafe<Uuid128, bool>((value) => value != Uuid128.Empty);
			RegisterUnsafe<Guid, System.Net.IPAddress>((value) => new System.Net.IPAddress(value.ToByteArray()));

			RegisterUnsafe<Uuid64, Slice>((value) => value.ToSlice());
			RegisterUnsafe<Uuid64, byte[]>((value) => value.ToByteArray());
			RegisterUnsafe<Uuid64, string>((value) => value.ToString("D", null));
			RegisterUnsafe<Uuid64, long>((value) => value.ToInt64());
			RegisterUnsafe<Uuid64, ulong>((value) => value.ToUInt64());
			RegisterUnsafe<Uuid64, bool>((value) => value.ToInt64() != 0L);

			RegisterUnsafe<TimeSpan, Slice>((value) => Slice.FromInt64(value.Ticks));
			RegisterUnsafe<TimeSpan, byte[]>((value) => Slice.FromInt64(value.Ticks).GetBytes());
			RegisterUnsafe<TimeSpan, long>((value) => value.Ticks);
			RegisterUnsafe<TimeSpan, ulong>((value) => checked((ulong)value.Ticks));
			RegisterUnsafe<TimeSpan, double>((value) => value.TotalSeconds);
			RegisterUnsafe<TimeSpan, bool>((value) => value == TimeSpan.Zero);

			RegisterUnsafe<System.Net.IPAddress, Slice>((value) => value != null ? Slice.Create(value.GetAddressBytes()) : Slice.Nil);
			RegisterUnsafe<System.Net.IPAddress, byte[]>((value) => value != null ? value.GetAddressBytes() : null);
			RegisterUnsafe<System.Net.IPAddress, string>((value) => value != null ? value.ToString() : null);

			RegisterUnsafe<FdbTupleAlias, byte>((value) => (byte)value);
			RegisterUnsafe<FdbTupleAlias, int>((value) => (int)value);
			RegisterUnsafe<FdbTupleAlias, Slice>((value) => Slice.FromByte((byte)value));

			//REVIEW: this should go in the Tuples layer !
			RegisterUnsafe<Slice, byte[]>((value) => value.GetBytes());
			RegisterUnsafe<Slice, string>((value) => value.ToUnicode());
			RegisterUnsafe<Slice, bool>((value) => value.ToBool());
			RegisterUnsafe<Slice, sbyte>((value) => value.ToSByte());
			RegisterUnsafe<Slice, byte>((value) => value.ToByte());
			RegisterUnsafe<Slice, short>((value) => value.ToInt16());
			RegisterUnsafe<Slice, ushort>((value) => value.ToUInt16());
			RegisterUnsafe<Slice, int>((value) => value.ToInt32());
			RegisterUnsafe<Slice, uint>((value) => value.ToUInt32());
			RegisterUnsafe<Slice, long>((value) => value.ToInt64());
			RegisterUnsafe<Slice, ulong>((value) => value.ToUInt64());
			RegisterUnsafe<Slice, Guid>((value) => value.ToGuid());
			RegisterUnsafe<Slice, Uuid128>((value) => value.ToUuid128());
			RegisterUnsafe<Slice, Uuid64>((value) => value.ToUuid64());
			RegisterUnsafe<Slice, TimeSpan>((value) => TimeSpan.FromTicks(value.ToInt64()));
			RegisterUnsafe<Slice, FdbTupleAlias>((value) => (FdbTupleAlias)value.ToByte());
			RegisterUnsafe<Slice, System.Net.IPAddress>((value) => !value.IsNullOrEmpty ? new System.Net.IPAddress(value.GetBytes()) : null);
		}

19 View Source File : ValueMember.cs
License : MIT License
Project Creator : AnotherEnd15

private static object ParseDefaultValue(Type type, object value)
        {
            {
                Type tmp = Helpers.GetUnderlyingType(type);
                if (tmp != null) type = tmp;
            }
            if (value is string s)
            {
                if (Helpers.IsEnum(type)) return Helpers.ParseEnum(type, s);

                switch (Helpers.GetTypeCode(type))
                {
                    case ProtoTypeCode.Boolean: return bool.Parse(s);
                    case ProtoTypeCode.Byte: return byte.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Char: // char.Parse missing on CF/phone7
                        if (s.Length == 1) return s[0];
                        throw new FormatException("Single character expected: \"" + s + "\"");
                    case ProtoTypeCode.DateTime: return DateTime.Parse(s, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Decimal: return decimal.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Double: return double.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Int16: return short.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Int32: return int.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Int64: return long.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.SByte: return sbyte.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Single: return float.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.String: return s;
                    case ProtoTypeCode.UInt16: return ushort.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.UInt32: return uint.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.UInt64: return ulong.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.TimeSpan: return TimeSpan.Parse(s);
                    case ProtoTypeCode.Uri: return s; // Uri is decorated as string
                    case ProtoTypeCode.Guid: return new Guid(s);
                }
            }

            if (Helpers.IsEnum(type)) return Enum.ToObject(type, value);
            return Convert.ChangeType(value, type, CultureInfo.InvariantCulture);

        }

19 View Source File : IntComponent.xaml.cs
License : MIT License
Project Creator : ADeltaX

public byte[] GetValueData()
        {
            switch (_dataType)
            {
                case DataTypeEnum.RegUwpByte:
                    return FromByte(byte.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpInt16:
                    return FromInt16(short.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpUint16:
                    return FromUInt16(ushort.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpInt32:
                    return FromInt32(int.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpUint32:
                    return FromUInt32(uint.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpInt64:
                    return FromInt64(long.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpUint64:
                    return FromUInt64(ulong.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpSingle:
                    return FromSingle(float.Parse(txBox.Text), _timestamp);
                case DataTypeEnum.RegUwpDouble:
                    return FromDouble(double.Parse(txBox.Text), _timestamp);
                default:
                    return null;
            }
        }

19 View Source File : GuildPropertyParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<GuildPropertyMetadata> Parse()
    {
        List<GuildPropertyMetadata> guildProperties = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("table/guildproperty"))
            {
                continue;
            }

            // Parse XML
            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList properties = doreplacedent.SelectNodes("/ms2/property");

            foreach (XmlNode property in properties)
            {
                GuildPropertyMetadata metadata = new();
                metadata.Level = int.Parse(property.Attributes["level"].Value);
                metadata.AcreplacedExp = int.Parse(property.Attributes["acreplacedExp"].Value);
                metadata.Capacity = int.Parse(property.Attributes["capacity"].Value);
                metadata.FundMax = int.Parse(property.Attributes["fundMax"].Value);
                metadata.DonationMax = int.Parse(property.Attributes["donationMax"].Value);
                metadata.AttendExp = int.Parse(property.Attributes["attendGuildExp"].Value);
                metadata.WinMiniGameExp = int.Parse(property.Attributes["winMiniGameGuildExp"].Value);
                metadata.LoseMiniGameExp = int.Parse(property.Attributes["loseMiniGameGuildExp"].Value);
                metadata.RaidGuildExp = int.Parse(property.Attributes["raidGuildExp"].Value);
                metadata.AttendFunds = int.Parse(property.Attributes["attendGuildFund"].Value);
                metadata.WinMiniGameFunds = int.Parse(property.Attributes["winMiniGameGuildFund"].Value);
                metadata.LoseMiniGameFunds = int.Parse(property.Attributes["loseMiniGameGuildFund"].Value);
                metadata.RaidGuildFunds = int.Parse(property.Attributes["raidGuildFund"].Value);
                metadata.AttendUserExpFactor = int.Parse(property.Attributes["attendUserExpFactor"].Value);
                metadata.DonateUserExpFactor = float.Parse(property.Attributes["donationUserExpFactor"].Value);
                metadata.AttendGuildCoin = int.Parse(property.Attributes["attendGuildCoin"].Value);
                metadata.DonateGuildCoin = int.Parse(property.Attributes["donateGuildCoin"].Value);
                metadata.WinMiniGameGuildCoin = int.Parse(property.Attributes["winMiniGameGuildCoin"].Value);
                metadata.LoseMiniGameGuildCoin = int.Parse(property.Attributes["loseMiniGameGuildCoin"].Value);

                guildProperties.Add(metadata);
            }
        }
        return guildProperties;
    }

19 View Source File : NpcParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<NpcMetadata> Parse()
    {
        // Parse EXP tables
        Dictionary<int, ExpMetadata> levelExp = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("table/expbasetable"))
            {
                continue;
            }

            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            foreach (XmlNode node in doreplacedent.DoreplacedentElement.ChildNodes)
            {
                if (node.Name == "table")
                {
                    if (int.Parse(node.Attributes["expTableID"].Value) != 1)
                    {
                        continue;
                    }
                    foreach (XmlNode tableNode in node.ChildNodes)
                    {
                        if (tableNode.Name == "base")
                        {
                            ExpMetadata expTable = new();

                            byte level = byte.Parse(tableNode.Attributes["level"].Value);
                            if (level != 0)
                            {
                                expTable.Level = level;
                                expTable.Experience = long.Parse(tableNode.Attributes["exp"].Value);
                                levelExp[level] = expTable;
                            }
                        }
                    }
                }
            }
        }

        Dictionary<int, string> npcIdToName = new()
        {
        };
        List<NpcMetadata> npcs = new();

        // Parse the NpcId -> Names first.
        foreach (PackFileEntry entry in Resources.XmlReader.Files.Where(entry => entry.Name.Equals("string/en/npcname.xml")))
        {
            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);

            foreach (XmlNode node in doreplacedent.SelectNodes("ms2/key"))
            {
                int id = int.Parse(node.Attributes["id"].Value);
                if (!npcIdToName.ContainsKey(id))
                {
                    npcIdToName.Add(id, node.Attributes["name"].Value);
                }
            }
        }

        // Handle /npc files second, to setup the NpcMetadata
        foreach (PackFileEntry entry in Resources.XmlReader.Files.Where(entry => entry.Name.StartsWith("npc/")))
        {
            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);

            XmlNode npcModelNode = doreplacedent.SelectSingleNode("ms2/environment/model") ?? doreplacedent.SelectSingleNode("ms2/model");
            XmlNode npcBasicNode = doreplacedent.SelectSingleNode("ms2/environment/basic") ?? doreplacedent.SelectSingleNode("ms2/basic");
            XmlNode npcStatsNode = doreplacedent.SelectSingleNode("ms2/environment/stat") ?? doreplacedent.SelectSingleNode("ms2/stat");
            XmlNode npcSpeedNode = doreplacedent.SelectSingleNode("ms2/environment/speed") ?? doreplacedent.SelectSingleNode("ms2/speed");
            XmlNode npcDistanceNode = doreplacedent.SelectSingleNode("ms2/environment/distance") ?? doreplacedent.SelectSingleNode("ms2/distance");
            XmlNode npcSkillNode = doreplacedent.SelectSingleNode("ms2/environment/skill") ?? doreplacedent.SelectSingleNode("ms2/skill");
            XmlNode npcEffectNode = doreplacedent.SelectSingleNode("ms2/environment/additionalEffect") ?? doreplacedent.SelectSingleNode("ms2/additionalEffect");
            XmlNode npcExpNode = doreplacedent.SelectSingleNode("ms2/environment/exp") ?? doreplacedent.SelectSingleNode("ms2/exp");
            XmlNode npcAiInfoNode = doreplacedent.SelectSingleNode("ms2/environment/aiInfo") ?? doreplacedent.SelectSingleNode("ms2/aiInfo");
            XmlNode npcNormalNode = doreplacedent.SelectSingleNode("ms2/environment/normal") ?? doreplacedent.SelectSingleNode("ms2/normal");
            XmlNode npcDeadNode = doreplacedent.SelectSingleNode("ms2/environment/dead") ?? doreplacedent.SelectSingleNode("ms2/dead");
            XmlNode npcDropItemNode = doreplacedent.SelectSingleNode("ms2/environment/dropiteminfo") ?? doreplacedent.SelectSingleNode("ms2/dropiteminfo");
            XmlAttributeCollection statsCollection = npcStatsNode.Attributes;

            // Metadata
            NpcMetadata metadata = new();
            metadata.Id = int.Parse(Path.GetFileNameWithoutExtension(entry.Name));
            metadata.Name = npcIdToName.ContainsKey(metadata.Id) ? npcIdToName[metadata.Id] : "";
            metadata.Model = npcModelNode.Attributes["kfm"].Value;

            // Parse basic attribs.
            metadata.TemplateId = int.TryParse(npcBasicNode.Attributes["illust"]?.Value, out _) ? int.Parse(npcBasicNode.Attributes["illust"].Value) : 0;
            metadata.Friendly = byte.Parse(npcBasicNode.Attributes["friendly"].Value);
            metadata.Level = byte.Parse(npcBasicNode.Attributes["level"].Value);

            metadata.NpcMetadataBasic.NpcAttackGroup = sbyte.Parse(npcBasicNode.Attributes["npcAttackGroup"]?.Value ?? "0");
            metadata.NpcMetadataBasic.NpcDefenseGroup = sbyte.Parse(npcBasicNode.Attributes["npcDefenseGroup"]?.Value ?? "0");
            metadata.NpcMetadataBasic.Difficulty = ushort.Parse(npcBasicNode.Attributes["difficulty"]?.Value ?? "0");
            metadata.NpcMetadataBasic.MaxSpawnCount = byte.Parse(npcBasicNode.Attributes["maxSpawnCount"]?.Value ?? "0");

            metadata.NpcMetadataBasic.GroupSpawnCount = byte.Parse(npcBasicNode.Attributes["groupSpawnCount"]?.Value ?? "0");
            metadata.NpcMetadataBasic.MainTags = npcBasicNode.Attributes["mainTags"]?.Value.Split(",").Select(p => p.Trim()).ToArray() ?? Array.Empty<string>();
            metadata.NpcMetadataBasic.SubTags = npcBasicNode.Attributes["subTags"]?.Value.Split(",").Select(p => p.Trim()).ToArray() ?? Array.Empty<string>();
            metadata.NpcMetadataBasic.Clreplaced = byte.Parse(npcBasicNode.Attributes["clreplaced"].Value);
            metadata.NpcMetadataBasic.Kind = ushort.Parse(npcBasicNode.Attributes["kind"].Value);
            metadata.NpcMetadataBasic.HpBar = byte.Parse(npcBasicNode.Attributes["hpBar"].Value);

            metadata.Stats = GetNpcStats(statsCollection);

            // Parse speed
            metadata.NpcMetadataSpeed.RotationSpeed = float.Parse(npcSpeedNode.Attributes["rotation"]?.Value ?? "0");
            metadata.NpcMetadataSpeed.WalkSpeed = float.Parse(npcSpeedNode.Attributes["walk"]?.Value ?? "0");
            metadata.NpcMetadataSpeed.RunSpeed = float.Parse(npcSpeedNode.Attributes["run"]?.Value ?? "0");

            // Parse distance
            metadata.NpcMetadataDistance.Avoid = int.Parse(npcDistanceNode.Attributes["avoid"]?.Value ?? "0");
            metadata.NpcMetadataDistance.Sight = int.Parse(npcDistanceNode.Attributes["sight"]?.Value ?? "0");
            metadata.NpcMetadataDistance.SightHeightUp = int.Parse(npcDistanceNode.Attributes["sightHeightUP"]?.Value ?? "0");
            metadata.NpcMetadataDistance.SightHeightDown = int.Parse(npcDistanceNode.Attributes["sightHeightDown"]?.Value ?? "0");

            // Parse skill
            metadata.NpcMetadataSkill.SkillIds = npcSkillNode.Attributes["ids"].Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse).ToArray();
            if (metadata.NpcMetadataSkill.SkillIds.Length > 0)
            {
                metadata.NpcMetadataSkill.SkillLevels = npcSkillNode.Attributes["levels"]?.Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(byte.Parse).ToArray();
                metadata.NpcMetadataSkill.SkillPriorities = npcSkillNode.Attributes["priorities"]?.Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(byte.Parse).ToArray();
                metadata.NpcMetadataSkill.SkillProbs = npcSkillNode.Attributes["probs"]?.Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(short.Parse).ToArray();
                metadata.NpcMetadataSkill.SkillCooldown = short.Parse(npcSkillNode.Attributes["coolDown"].Value);
            }

            // Parse Additional Effects (Effect / Buff)
            metadata.NpcMetadataEffect.EffectIds = npcEffectNode.Attributes["codes"].Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse).ToArray();
            if (metadata.NpcMetadataEffect.EffectIds.Length > 0)
            {
                metadata.NpcMetadataEffect.EffectLevels = npcEffectNode.Attributes["levels"]?.Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(byte.Parse).ToArray();
            }

            // Parse normal state
            List<(string, NpcAction, short)> normalActions = new();
            string[] normalActionIds = npcNormalNode.Attributes["action"]?.Value.Split(",") ?? Array.Empty<string>();
            if (normalActionIds.Length > 0)
            {
                short[] actionProbs = npcNormalNode.Attributes["prob"]?.Value.Split(",").Select(short.Parse).ToArray();
                for (int i = 0; i < normalActionIds.Length; i++)
                {
                    normalActions.Add((normalActionIds[i], GetNpcAction(normalActionIds[i]), actionProbs[i]));
                }
                metadata.StateActions[NpcState.Normal] = normalActions.ToArray();
            }
            metadata.MoveRange = short.Parse(npcNormalNode.Attributes["movearea"]?.Value ?? "0");

            // HACK: Parse combat/skills state (does not actually exist)
            List<(string, NpcAction, short)> combatActions = new();
            string[] combatActionsIds = new string[] { "Run_A" };
            if (combatActionsIds.Length > 0)
            {
                int equalProb = 10000 / combatActionsIds.Length;
                int remainder = 10000 % (equalProb * combatActionsIds.Length);
                combatActions.Add((combatActionsIds[0], GetNpcAction(combatActionsIds[0]), (short) (equalProb + remainder)));
                metadata.StateActions[NpcState.Combat] = combatActions.ToArray();
            }

            // Parse dead state
            List<(string, NpcAction, short)> deadActions = new();
            string[] deadActionIds = npcDeadNode.Attributes["defaultaction"]?.Value.Split(",") ?? Array.Empty<string>();
            if (deadActionIds.Length > 0)
            {
                int equalProb = 10000 / deadActionIds.Length;
                int remainder = 10000 % (equalProb * deadActionIds.Length);
                deadActions.Add((deadActionIds[0], GetNpcAction(deadActionIds[0]), (short) (equalProb + remainder)));
                for (int i = 1; i < deadActionIds.Length; i++)
                {
                    deadActions.Add((deadActionIds[i], GetNpcAction(deadActionIds[i]), (short) equalProb));
                }
                metadata.StateActions[NpcState.Dead] = deadActions.ToArray();
            }

            metadata.AiInfo = npcAiInfoNode.Attributes["path"].Value;
            int customExpValue = int.Parse(npcExpNode.Attributes["customExp"].Value);
            metadata.Experience = customExpValue >= 0 ? customExpValue : (int) levelExp[metadata.Level].Experience;
            metadata.NpcMetadataDead.Time = float.Parse(npcDeadNode.Attributes["time"].Value);
            metadata.NpcMetadataDead.Actions = npcDeadNode.Attributes["defaultaction"].Value.Split(",");
            metadata.GlobalDropBoxIds = npcDropItemNode.Attributes["globalDropBoxId"].Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse).ToArray();
            metadata.Kind = short.Parse(npcBasicNode.Attributes["kind"].Value);
            metadata.ShopId = int.Parse(npcBasicNode.Attributes["shopId"].Value);
            npcs.Add(metadata);
        }

        return npcs;
    }

19 View Source File : AdvancedEnchantment.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

protected override void _OnDealDamage(Monster monster, GameLocation location, Farmer who, ref int amount)
        {
            if (enchantment.parameters["trigger"] == "damage" || (enchantment.parameters["trigger"] == "crit" && amount > weapon.maxDamage))
            {
                //ModEntry.context.Monitor.Log($"Triggered enchantment {enchantment.type} on {enchantment.parameters["trigger"]} for {weapon.Name}");
                if (enchantment.type == "heal")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        int heal = Math.Max(1, (int)(amount * float.Parse(enchantment.parameters["amountMult"])));
                        who.health = Math.Min(who.maxHealth, Game1.player.health + heal);
                        location.debris.Add(new Debris(heal, new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()), Color.Lime, 1f, who));
                        if(enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
                else if (enchantment.type == "coins")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        float mult = float.Parse(enchantment.parameters["amountMult"]);
                        int coins = (int)Math.Round(mult * amount);
                        who.Money += coins;
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
            }
        }

19 View Source File : MailHelper.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

private static void SendBlackMarketSoldMail(BlackMarketListing listing, Item item, long price, bool removeListing)
    {
        float salesFeeRate = float.Parse(ConstantsMetadataStorage.GetConstant("BlackMarketSalesFeeRate"));
        long tax = (long) (salesFeeRate * (item.Amount * price));
        long revenue = item.Amount * price - tax;

        string senderName = "<ms2><v key=\"s_blackmarket_mail_to_sender\" /></ms2>";
        string replacedle = "<ms2><v key=\"s_blackmarket_mail_to_seller_replacedle\" /></ms2>";
        string body = "<ms2><v key=\"s_blackmarket_mail_to_seller_content\" /></ms2>";
        string addParameter1 = $"<ms2><v item=\"{item.Id}\" ></v></ms2>";
        string addParameter2 = $"<ms2><v item=\"{item.Id}\" ></v><v str=\"{item.Amount}\" ></v><v money=\"{price * item.Amount}\" ></v><v money=\"{price}\" ></v><v money=\"{tax}\" ></v><v str=\"{salesFeeRate * 100}%\" ></v><v money=\"{revenue}\" ></v></ms2>";

        if (removeListing)
        {
            revenue += listing.Deposit;
            body = "<ms2><v key=\"s_blackmarket_mail_to_seller_content_soldout\" /></ms2>";
            addParameter2 = $"<ms2><v item=\"{item.Id}\" ></v><v str=\"{item.Amount}\" ></v><v money=\"{price * item.Amount}\" ></v><v money=\"{price}\" ></v><v money=\"{tax}\" ></v><v str=\"{salesFeeRate * 100}%\" ></v><v money=\"{listing.Deposit}\" ></v><v money=\"{revenue}\" ></v></ms2>";
        }

        Mail mail = new(MailType.BlackMarketSale, listing.OwnerCharacterId, 0, senderName, replacedle, body, addParameter1, addParameter2, new(), revenue, 0);
        GameServer.MailManager.AddMail(mail);
        SendNotification(mail);
    }

19 View Source File : FrmReader.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void NextPage() // +
        {
            if (cmboPage.SelectedIndex < cmboPage.Items.Count - 1)
            { 
                cmboPage.SelectedIndex = cmboPage.SelectedIndex + 1;
                float currentPage = float.Parse(cmboPage.SelectedItem.ToString());
                float percent = (currentPage / (float)numPagesInCurrentChapter) * 100;
                progress.Value = (int)percent;
            }
        }

19 View Source File : SongDetailViewController.cs
License : MIT License
Project Creator : andruzzzhka

public void SetContent(MoreSongsFlowCoordinator sender, Song newSongInfo)
        {
            _currentSong = newSongInfo;

            songNameText.text = _currentSong.songName;

            downloadsText.text = _currentSong.downloads;
            _levelParams.bpm = float.Parse(_currentSong.plays);
            _levelParams.notesCount = int.Parse(_currentSong.beatsPerMinute);
            _levelParams.obstaclesCount = int.Parse(_currentSong.upvotes);
            _levelParams.bombsCount = int.Parse(_currentSong.downvotes);

            difficulty1Text.text = (_currentSong.difficultyLevels.Where(x => (x.difficulty == "Expert" || x.difficulty == "ExpertPlus")).Count() > 0) ? "Yes" : "No";
            difficulty2Text.text = (_currentSong.difficultyLevels.Where(x => x.difficulty == "Hard").Count() > 0) ? "Yes" : "No";
            difficulty3Text.text = (_currentSong.difficultyLevels.Where(x => (x.difficulty == "Easy" || x.difficulty == "Normal")).Count() > 0) ? "Yes" : "No";

            StartCoroutine(LoadScripts.LoadSpriteCoroutine(_currentSong.coverUrl, (cover) => { coverImage.sprite = cover;}));

            SetFavoriteState(PluginConfig.favoriteSongs.Any(x => x.Contains(_currentSong.hash)));
            SetDownloadState((SongDownloader.Instance.IsSongDownloaded(_currentSong) ? DownloadState.Downloaded : (sender.IsDownloadingSong(_currentSong) ? DownloadState.Downloading : DownloadState.NotDownloaded)));
        }

19 View Source File : UGUIMathNode.cs
License : MIT License
Project Creator : aksyr

private void OnChangeValA(string val) {
			mathNode.a = float.Parse(valA.text);
		}

19 View Source File : StripLineTitle.cs
License : MIT License
Project Creator : AngeloCresta

private void ControlChange(object sender, System.EventArgs e)
		{
			if(this.replacedlePosition.SelectedIndex >= 0)
			{
				string strAlign = this.replacedlePosition.SelectedItem.ToString();
				StringAlignment align = (StringAlignment) Enum.Parse(typeof(StringAlignment), strAlign, true);
				Chart1.ChartAreas["Default"].AxisX.StripLines[0].TextAlignment = align;
			}
			
			if(this.replacedleLinePosition.SelectedIndex >= 0)
			{
				string strAlign = this.replacedleLinePosition.SelectedItem.ToString();
				StringAlignment align = (StringAlignment) Enum.Parse(typeof(StringAlignment), strAlign, true);
				Chart1.ChartAreas["Default"].AxisX.StripLines[0].TextLineAlignment = align;
			}

			// Set selected axis
			Chart1.ChartAreas["Default"].AxisX.StripLines[0].Text = replacedle.Text;

			if( AntiAliasingCheck.Checked )
				Chart1.AntiAliasing = AntiAliasingStyles.All;
			else
				Chart1.AntiAliasing = AntiAliasingStyles.Graphics;


			// Set Font style.
			FontStyle fontStyle = FontStyle.Regular;
			if( ItalicCheck.Checked )
				fontStyle = (FontStyle)FontStyle.Italic;
			if( BoldCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Bold;
			if( UnderlineCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Underline;
			if( StrikeoutCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Strikeout;


			// Set replacedle font
			if(this.TheFont.SelectedIndex >= 0 && this.FontSize.SelectedIndex >= 0)
			{
				string font = this.TheFont.SelectedItem.ToString();
				float fontpoint = float.Parse(this.FontSize.SelectedItem.ToString());
				try
				{
					Chart1.ChartAreas["Default"].AxisX.StripLines[0].Font = new Font(font, fontpoint, fontStyle);
				}
				catch
				{
					Chart1.ChartAreas["Default"].AxisX.StripLines[0].Font = new Font("Arial", fontpoint, fontStyle);
				}
			}

			// Set replacedle color
			if(this.FontColorCombo.SelectedIndex >= 0)
			{
				Chart1.ChartAreas["Default"].AxisX.StripLines[0].ForeColor = Color.FromName(this.FontColorCombo.SelectedItem.ToString());
			}
		}

19 View Source File : FrmDoublePageReader.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void NextPage() // +
        {
            if (cmboPage.SelectedIndex < cmboPage.Items.Count - 2)
            { 
                cmboPage.SelectedIndex = cmboPage.SelectedIndex + 2;
                float currentPage = float.Parse(cmboPage.SelectedItem.ToString());
                float percent = (currentPage / (float)numPagesInCurrentChapter) * 100;
                progress.Value = (int)percent;
            } else if (cmboPage.SelectedIndex < cmboPage.Items.Count - 1)
            {
                cmboPage.SelectedIndex = cmboPage.SelectedIndex + 1;
                float currentPage = float.Parse(cmboPage.SelectedItem.ToString());
                float percent = (currentPage / (float)numPagesInCurrentChapter) * 100;
                progress.Value = (int)percent;
            }
        }

19 View Source File : ChartTitle.cs
License : MIT License
Project Creator : AngeloCresta

private void ControlChange(object sender, System.EventArgs e)
		{
			
			// Set selected axis
			Chart1.replacedles[0].Text = replacedle.Text;

			// Set Font style.
			FontStyle fontStyle = FontStyle.Regular;
			
			// Set replacedle font
			if(this.TheFont.SelectedIndex >= 0 && this.FontSize.SelectedIndex >= 0)
			{
				string font = this.TheFont.SelectedItem.ToString();
				float fontpoint = float.Parse(this.FontSize.SelectedItem.ToString());
				try
				{
					Chart1.replacedles[0].Font = new Font(font, fontpoint, fontStyle);
				}
				catch
				{
					Chart1.replacedles[0].Font = new Font("Arial", fontpoint, fontStyle);
				}
			}

			// Set replacedle alignment
			if( this.Alignment.SelectedIndex == 0 )
			{
				Chart1.replacedles[0].Alignment = ContentAlignment.MiddleLeft;
			}
			else if( this.Alignment.SelectedIndex == 1 )
			{
				Chart1.replacedles[0].Alignment = ContentAlignment.MiddleCenter;
			}
			else
			{
				Chart1.replacedles[0].Alignment = ContentAlignment.MiddleRight;
			}

			// Set replacedle color
			if(this.FontColorCombo.SelectedIndex >= 0)
			{
				Chart1.replacedles[0].ForeColor = Color.FromName(this.FontColorCombo.SelectedItem.ToString());
			}

			// Set Border replacedle color
			if(this.BorderColor.SelectedIndex > 0)
			{
				Chart1.replacedles[0].BorderColor = Color.FromName(this.BorderColor.SelectedItem.ToString());
			}
			else
			{
				Chart1.replacedles[0].BorderColor =  Color.Empty;
			}

			// Set Background replacedle color
			if(this.BackColorCom.SelectedIndex > 0)
			{
				Chart1.replacedles[0].BackColor = Color.FromName(this.BackColorCom.SelectedItem.ToString());
			}
			else
			{
				Chart1.replacedles[0].BackColor =  Color.Empty;
			}

			// Set Tooltip
			Chart1.replacedles[0].ToolTip = this.ToolTip.Text;

		}

19 View Source File : UGUIVector.cs
License : MIT License
Project Creator : aksyr

private void OnChangeValZ(string val) {
			vectorNode.z = float.Parse(valZ.text);
		}

19 View Source File : InteractObjectParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<InteractObjectMetadata> Parse()
    {
        List<InteractObjectMetadata> objects = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("table/interactobject"))
            {
                continue;
            }

            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList interactNodes = doreplacedent.GetElementsByTagName("interact");
            foreach (XmlNode interactNode in interactNodes)
            {
                string locale = interactNode.Attributes["locale"]?.Value ?? "";
                if (locale != "NA" && locale != "")
                {
                    continue;
                }

                InteractObjectMetadata metadata = new();

                metadata.Id = int.Parse(interactNode.Attributes["id"].Value);
                _ = Enum.TryParse(interactNode.Attributes["type"].Value, out metadata.Type);

                foreach (XmlNode childNode in interactNode)
                {
                    if (childNode.Name == "reward")
                    {
                        InteractObjectRewardMetadata reward = new();
                        reward.Exp = int.Parse(childNode.Attributes["exp"].Value);
                        reward.ExpType = childNode.Attributes["expType"].Value;
                        reward.ExpRate = float.Parse(childNode.Attributes["relativeExpRate"].Value);
                        reward.FirstExpType = childNode.Attributes["firstExpType"].Value;
                        reward.FirstExpRate = float.Parse(childNode.Attributes["firstRelativeExpRate"].Value);
                        metadata.Reward = reward;
                    }
                    else if (childNode.Name == "drop")
                    {
                        InteractObjectDropMetadata drop = new();

                        drop.ObjectLevel = childNode.Attributes["objectLevel"]?.Value ?? "";
                        _ = int.TryParse(childNode.Attributes["objectDropRank"]?.Value ?? "0", out drop.DropRank);

                        drop.GlobalDropBoxId = childNode.Attributes["globalDropBoxId"].Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse).ToList();

                        drop.IndividualDropBoxId = childNode.Attributes["individualDropBoxId"].Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse).ToList();

                        metadata.Drop = drop;
                    }
                    else if (childNode.Name == "gathering")
                    {
                        InteractObjectGatheringMetadata gathering = new();
                        gathering.RecipeId = int.Parse(childNode.Attributes["receipeID"].Value);
                        metadata.Gathering = gathering;
                    }
                    else if (childNode.Name == "webOpen")
                    {
                        InteractObjectWebMetadata web = new();
                        web.Url = childNode.Attributes["url"].Value;
                        metadata.Web = web;
                    }
                }

                objects.Add(metadata);
            }
        }
        return objects;
    }

19 View Source File : Updater.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public static void Start()
        {
            WFClient.logger.Log("Checking for updates");

            string json;
            using (var wc = new System.Net.WebClient())
            {
                json = wc.DownloadString("https://raw.githubusercontent.com/ninevult/MikuReader/master/MikuReader-WF/updater/wfupdate.json");
            }
            UpdateInfo info = JsonConvert.DeserializeObject<UpdateInfo>(json);

            if (float.Parse(info.Update_major) > float.Parse(WFClient.CLIENT_MAJOR)
                || float.Parse(info.Update_minor) > float.Parse(WFClient.CLIENT_MINOR))
            {
                new FrmUpdate(info).ShowDialog();
            }

            // AutoUpdater.Start("https://raw.githubusercontent.com/ninevult/MikuReader/master/MikuReader-WF/updater/wfupdate.xml");
            // AutoUpdater.RunUpdateAsAdmin = true;
            // AutoUpdater.OpenDownloadPage = true;
        }

19 View Source File : ItemParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<ItemMetadata> Parse()
    {
        // Item breaking ingredients
        Dictionary<int, List<ItemBreakReward>> rewards = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("table/itembreakingredient"))
            {
                continue;
            }

            XmlDoreplacedent innerDoreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList individualItems = innerDoreplacedent.SelectNodes($"/ms2/item");
            foreach (XmlNode nodes in individualItems)
            {
                string locale = nodes.Attributes["locale"]?.Value ?? "";
                if (locale != "NA" && locale != "")
                {
                    continue;
                }
                int itemID = int.Parse(nodes.Attributes["ItemID"].Value);
                rewards[itemID] = new();

                int ingredienreplacedemID1 = int.Parse(nodes.Attributes["IngredienreplacedemID1"]?.Value ?? "0");
                int ingredientCount1 = int.Parse(nodes.Attributes["IngredientCount1"]?.Value ?? "0");
                rewards[itemID].Add(new(ingredienreplacedemID1, ingredientCount1));

                _ = int.TryParse(nodes.Attributes["IngredienreplacedemID2"]?.Value ?? "0", out int ingredienreplacedemID2);
                _ = int.TryParse(nodes.Attributes["IngredientCount2"]?.Value ?? "0", out int ingredientCount2);
                rewards[itemID].Add(new(ingredienreplacedemID2, ingredientCount2));

                _ = int.TryParse(nodes.Attributes["IngredienreplacedemID3"]?.Value ?? "0", out int ingredienreplacedemID3);
                _ = int.TryParse(nodes.Attributes["IngredientCount3"]?.Value ?? "0", out int ingredientCount3);
                rewards[itemID].Add(new(ingredienreplacedemID3, ingredientCount3));
            }
        }

        //Item Name
        Dictionary<int, string> names = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("string/en/itemname.xml"))
            {
                continue;
            }

            XmlDoreplacedent innerDoreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList nodes = innerDoreplacedent.SelectNodes($"/ms2/key");
            foreach (XmlNode node in nodes)
            {
                int itemId = int.Parse(node.Attributes["id"].Value);
                if (node.Attributes["name"] == null)
                {
                    continue;
                }
                string itemName = node.Attributes["name"].Value;
                names[itemId] = itemName;
            }
        }

        // Item rarity
        Dictionary<int, int> rarities = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("table/na/itemwebfinder"))
            {
                continue;
            }
            XmlDoreplacedent innerDoreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList nodes = innerDoreplacedent.SelectNodes($"/ms2/key");
            foreach (XmlNode node in nodes)
            {
                int itemId = int.Parse(node.Attributes["id"].Value);
                int rarity = int.Parse(node.Attributes["grade"].Value);
                rarities[itemId] = rarity;
            }
        }

        // Items
        List<ItemMetadata> items = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("item/"))
            {
                continue;
            }

            ItemMetadata metadata = new();
            string filename = Path.GetFileNameWithoutExtension(entry.Name);
            int itemId = int.Parse(filename);

            if (items.Exists(item => item.Id == itemId))
            {
                continue;
            }

            metadata.Id = itemId;
            Debug.replacedert(metadata.Id > 0, $"Invalid Id {metadata.Id} from {itemId}");

            // Parse XML
            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNode item = doreplacedent.SelectSingleNode("ms2/environment");

            // Tag
            XmlNode basic = item.SelectSingleNode("basic");
            metadata.Tag = basic.Attributes["stringTag"].Value;

            // Gear/Cosmetic slot
            XmlNode slots = item.SelectSingleNode("slots");
            XmlNode slot = slots.FirstChild;
            bool slotResult = Enum.TryParse(slot.Attributes["name"].Value, out metadata.Slot);
            if (!slotResult && !string.IsNullOrEmpty(slot.Attributes["name"].Value))
            {
                Console.WriteLine($"Failed to parse item slot for {itemId}: {slot.Attributes["name"].Value}");
            }

            int totalSlots = slots.SelectNodes("slot").Count;
            if (totalSlots > 1)
            {
                if (metadata.Slot == ItemSlot.CL || metadata.Slot == ItemSlot.PA)
                {
                    metadata.IsDress = true;
                }
                else if (metadata.Slot == ItemSlot.RH || metadata.Slot == ItemSlot.LH)
                {
                    metadata.IsTwoHand = true;
                }
            }

            // Hair data
            if (slot.Attributes["name"].Value == "HR")
            {
                int replacedetNodeCount = slot.SelectNodes("replacedet").Count;
                XmlNode replacedet = slot.FirstChild;

                XmlNode scaleNode = slot.SelectSingleNode("scale");

                if (replacedetNodeCount == 3) // This hair has a front and back positionable hair
                {
                    XmlNode backHair = replacedet.NextSibling; // back hair info
                    XmlNode frontHair = backHair.NextSibling; // front hair info

                    int backHairNodes = backHair.SelectNodes("custom").Count;

                    CoordF[] bPosCord = new CoordF[backHairNodes];
                    CoordF[] bPosRotation = new CoordF[backHairNodes];
                    CoordF[] fPosCord = new CoordF[backHairNodes];
                    CoordF[] fPosRotation = new CoordF[backHairNodes];

                    for (int i = 0; i < backHairNodes; i++)
                    {
                        foreach (XmlNode backPresets in backHair)
                        {
                            if (backPresets.Name == "custom")
                            {
                                bPosCord[i] = CoordF.Parse(backPresets.Attributes["position"].Value);
                                bPosRotation[i] = CoordF.Parse(backPresets.Attributes["rotation"].Value);
                            }
                        }
                        foreach (XmlNode frontPresets in frontHair)
                        {
                            if (frontPresets.Name == "custom")
                            {
                                fPosCord[i] = CoordF.Parse(frontPresets.Attributes["position"].Value);
                                fPosRotation[i] = CoordF.Parse(frontPresets.Attributes["position"].Value);
                            }
                        }
                        HairPresets hairPresets = new()
                        {
                        };

                        hairPresets.BackPositionCoord = bPosCord[i];
                        hairPresets.BackPositionRotation = bPosRotation[i];
                        hairPresets.FrontPositionCoord = fPosCord[i];
                        hairPresets.FrontPositionRotation = fPosRotation[i];
                        hairPresets.MinScale = float.Parse(scaleNode?.Attributes["min"]?.Value ?? "0");
                        hairPresets.MaxScale = float.Parse(scaleNode?.Attributes["max"]?.Value ?? "0");

                        metadata.HairPresets.Add(hairPresets);
                    }
                }
                else if (replacedetNodeCount == 2) // This hair only has back positionable hair
                {
                    XmlNode backHair = replacedet.NextSibling; // back hair info

                    int backHairNodes = backHair.SelectNodes("custom").Count;

                    CoordF[] bPosCord = new CoordF[backHairNodes];
                    CoordF[] bPosRotation = new CoordF[backHairNodes];

                    for (int i = 0; i < backHairNodes; i++)
                    {
                        foreach (XmlNode backPresets in backHair)
                        {
                            if (backPresets.Name == "custom")
                            {
                                bPosCord[i] = CoordF.Parse(backPresets.Attributes["position"].Value);
                                bPosRotation[i] = CoordF.Parse(backPresets.Attributes["rotation"].Value);
                            }
                        }

                        HairPresets hairPresets = new()
                        {
                        };

                        hairPresets.BackPositionCoord = bPosCord[i];
                        hairPresets.BackPositionRotation = bPosRotation[i];
                        hairPresets.FrontPositionCoord = CoordF.Parse("0, 0, 0");
                        hairPresets.FrontPositionRotation = CoordF.Parse("0, 0, 0");
                        hairPresets.MinScale = float.Parse(scaleNode?.Attributes["min"]?.Value ?? "0");
                        hairPresets.MaxScale = float.Parse(scaleNode?.Attributes["max"]?.Value ?? "0");
                        metadata.HairPresets.Add(hairPresets);
                    }
                }
                else // hair does not have back or front positionable hair
                {
                    HairPresets hairPresets = new()
                    {
                    };
                    hairPresets.BackPositionCoord = CoordF.Parse("0, 0, 0");
                    hairPresets.BackPositionRotation = CoordF.Parse("0, 0, 0");
                    hairPresets.FrontPositionCoord = CoordF.Parse("0, 0, 0");
                    hairPresets.FrontPositionRotation = CoordF.Parse("0, 0, 0");
                    hairPresets.MinScale = float.Parse(scaleNode?.Attributes["min"]?.Value ?? "0");
                    hairPresets.MaxScale = float.Parse(scaleNode?.Attributes["max"]?.Value ?? "0");
                    metadata.HairPresets.Add(hairPresets);
                }
            }


            // Color data
            XmlNode customize = item.SelectSingleNode("customize");
            metadata.ColorIndex = int.Parse(customize.Attributes["defaultColorIndex"].Value);
            metadata.ColorPalette = int.Parse(customize.Attributes["colorPalette"].Value);

            // Badge slot
            XmlNode gem = item.SelectSingleNode("gem");
            bool gemResult = Enum.TryParse(gem.Attributes["system"].Value, out metadata.Gem);
            if (!gemResult && !string.IsNullOrEmpty(gem.Attributes["system"].Value))
            {
                Console.WriteLine($"Failed to parse badge slot for {itemId}: {gem.Attributes["system"].Value}");
            }

            // Inventory tab and max stack size
            XmlNode property = item.SelectSingleNode("property");
            try
            {
                byte type = byte.Parse(property.Attributes["type"].Value);
                byte subType = byte.Parse(property.Attributes["subtype"].Value);
                bool skin = byte.Parse(property.Attributes["skin"].Value) != 0;
                metadata.Tab = GetTab(type, subType, skin);
                metadata.IsTemplate = byte.Parse(property.Attributes["skinType"]?.Value ?? "0") == 99;
                metadata.TradeableCount = byte.Parse(property.Attributes["tradableCount"].Value);
                metadata.RepackageCount = byte.Parse(property.Attributes["rePackingLimitCount"].Value);
                metadata.RepackageItemConsumeCount = byte.Parse(property.Attributes["rePackingItemConsumeCount"].Value);
                metadata.BlackMarketCategory = property.Attributes["blackMarketCategory"].Value;

                // sales price
                XmlNode sell = property.SelectSingleNode("sell");
                metadata.SellPrice = sell.Attributes["price"]?.Value.Split(',').Select(int.Parse).ToList() ?? null;
                metadata.SellPriceCustom = sell.Attributes["priceCustom"]?.Value.Split(',').Select(int.Parse).ToList() ?? null;
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to parse tab slot for {itemId}: {e.Message}");
            }
            metadata.StackLimit = int.Parse(property.Attributes["slotMax"].Value);

            // Rarity
            XmlNode option = item.SelectSingleNode("option");
            metadata.OptionStatic = int.Parse(option.Attributes["static"].Value);
            metadata.OptionRandom = int.Parse(option.Attributes["random"].Value);
            metadata.OptionConstant = int.Parse(option.Attributes["constant"].Value);
            metadata.OptionLevelFactor = int.Parse(option.Attributes["optionLevelFactor"].Value);

            XmlNode function = item.SelectSingleNode("function");
            string contentType = function.Attributes["name"].Value;
            metadata.FunctionData.Name = contentType;

            // Item boxes
            if (contentType == "OpenItemBox")
            {
                // selection boxes are SelecreplacedemBox and 1,boxid
                // normal boxes are OpenItemBox and 0,1,0,boxid
                // fragments are OpenItemBox and 0,1,0,boxid,required_amount
                if (function.Attributes["parameter"].Value.Contains('l'))
                {
                    continue; // TODO: Implement these CN items. Skipping for now
                }

                List<string> parameters = new(function.Attributes["parameter"].Value.Split(","));
                OpenItemBox box = new();
                box.RequiredItemId = int.Parse(parameters[0]);
                box.ReceiveOneItem = parameters[1] == "1";
                box.BoxId = int.Parse(parameters[3]);
                box.AmountRequired = 1;
                if (parameters.Count == 5)
                {
                    box.AmountRequired = int.Parse(parameters[4]);
                }
                metadata.FunctionData.OpenItemBox = box;
            }
            else if (contentType == "SelecreplacedemBox")
            {
                if (function.Attributes["parameter"].Value.Contains('l'))
                {
                    continue; // TODO: Implement these CN items. Skipping for now
                }

                List<string> parameters = new(function.Attributes["parameter"].Value.Split(","));
                parameters.RemoveAll(param => param.Length == 0);
                SelecreplacedemBox box = new();
                box.GroupId = int.Parse(parameters[0]);
                box.BoxId = int.Parse(parameters[1]);
                metadata.FunctionData.SelecreplacedemBox = box;
            }
            else if (contentType == "ChatEmoticonAdd")
            {
                ChatEmoticonAdd sticker = new();
                string rawParameter = function.Attributes["parameter"].Value;
                string decodedParameter = HttpUtility.HtmlDecode(rawParameter);
                XmlDoreplacedent xmlParameter = new();
                xmlParameter.LoadXml(decodedParameter);
                XmlNode functionParameters = xmlParameter.SelectSingleNode("v");
                sticker.Id = byte.Parse(functionParameters.Attributes["id"].Value);

                sticker.Duration = int.Parse(functionParameters.Attributes["durationSec"]?.Value ?? "0");
                metadata.FunctionData.ChatEmoticonAdd = sticker;
            }
            else if (contentType == "OpenMreplacedive")
            {
                OpenMreplacediveEvent mreplacediveEvent = new();
                string rawParameter = function.Attributes["parameter"].Value;
                string cleanParameter = rawParameter.Remove(1, 1); // remove the unwanted space
                string decodedParameter = HttpUtility.HtmlDecode(cleanParameter);

                XmlDoreplacedent xmlParameter = new();
                xmlParameter.LoadXml(decodedParameter);
                XmlNode functionParameters = xmlParameter.SelectSingleNode("v");
                mreplacediveEvent.FieldId = int.Parse(functionParameters.Attributes["fieldID"].Value);
                mreplacediveEvent.Duration = int.Parse(functionParameters.Attributes["portalDurationTick"].Value);
                mreplacediveEvent.Capacity = byte.Parse(functionParameters.Attributes["maxCount"].Value);
                metadata.FunctionData.OpenMreplacediveEvent = mreplacediveEvent;
            }
            else if (contentType == "LevelPotion")
            {
                LevelPotion levelPotion = new();
                string rawParameter = function.Attributes["parameter"].Value;
                string decodedParameter = HttpUtility.HtmlDecode(rawParameter);
                XmlDoreplacedent xmlParameter = new();
                xmlParameter.LoadXml(decodedParameter);
                XmlNode functionParameters = xmlParameter.SelectSingleNode("v");
                levelPotion.TargetLevel = byte.Parse(functionParameters.Attributes["targetLevel"].Value);
                metadata.FunctionData.LevelPotion = levelPotion;
            }
            else if (contentType == "VIPCoupon")
            {
                VIPCoupon coupon = new();
                string rawParameter = function.Attributes["parameter"].Value;
                string decodedParameter = HttpUtility.HtmlDecode(rawParameter);
                XmlDoreplacedent xmlParameter = new();
                xmlParameter.LoadXml(decodedParameter);
                XmlNode functionParameters = xmlParameter.SelectSingleNode("v");
                coupon.Duration = int.Parse(functionParameters.Attributes["period"].Value);
                metadata.FunctionData.VIPCoupon = coupon;
            }
            else if (contentType == "HongBao")
            {
                HongBaoData hongBao = new();
                string rawParameter = function.Attributes["parameter"].Value;
                string decodedParameter = HttpUtility.HtmlDecode(rawParameter);
                XmlDoreplacedent xmlParameter = new();
                xmlParameter.LoadXml(decodedParameter);
                XmlNode functionParameters = xmlParameter.SelectSingleNode("v");
                hongBao.Id = int.Parse(functionParameters.Attributes["itemId"].Value);
                hongBao.Count = short.Parse(functionParameters.Attributes["totalCount"].Value);
                hongBao.TotalUsers = byte.Parse(functionParameters.Attributes["totalUser"].Value);
                hongBao.Duration = int.Parse(functionParameters.Attributes["durationSec"].Value);
                metadata.FunctionData.HongBao = hongBao;
            }
            else if (contentType == "SuperWorldChat")
            {
                string[] parameters = function.Attributes["parameter"].Value.Split(",");
                metadata.FunctionData.Id = int.Parse(parameters[0]); // only storing the first parameter. Not sure if the server uses the other 2. 
            }
            else if (contentType == "OpenGachaBox")
            {
                string[] parameters = function.Attributes["parameter"].Value.Split(",");
                metadata.FunctionData.Id = int.Parse(parameters[0]); // only storing the first parameter. Unknown what the second parameter is used for.
            }
            else if (contentType == "OpenCoupleEffectBox")
            {
                OpenCoupleEffectBox box = new();
                string[] parameters = function.Attributes["parameter"].Value.Split(",");
                box.Id = int.Parse(parameters[0]);
                box.Rarity = byte.Parse(parameters[1]);
                metadata.FunctionData.OpenCoupleEffectBox = box;
            }
            else if (contentType == "InstallBillBoard")
            {
                InstallBillboard balloon = new();
                string rawParameter = function.Attributes["parameter"].Value;
                string decodedParameter = HttpUtility.HtmlDecode(rawParameter);
                XmlDoreplacedent xmlParameter = new();
                xmlParameter.LoadXml(decodedParameter);
                XmlNode functionParameters = xmlParameter.SelectSingleNode("v");
                balloon.InteractId = int.Parse(functionParameters.Attributes["interactID"].Value);
                balloon.Duration = int.Parse(functionParameters.Attributes["durationSec"].Value);
                balloon.Model = functionParameters.Attributes["model"].Value;
                balloon.replacedet = functionParameters.Attributes["replacedet"]?.Value ?? "";
                balloon.NormalState = functionParameters.Attributes["normal"].Value;
                balloon.Reactable = functionParameters.Attributes["reactable"].Value;
                balloon.Scale = float.Parse(functionParameters.Attributes["scale"]?.Value ?? "0");
                metadata.FunctionData.InstallBillboard = balloon;
            }
            else if (contentType == "replacedleScroll" || contentType == "ItemExchangeScroll" || contentType == "OpenInstrument" || contentType == "StoryBook" || contentType == "FishingRod" || contentType == "ItemChangeBeauty"
                     || contentType == "ItemRePackingScroll")
            {
                metadata.FunctionData.Id = int.Parse(function.Attributes["parameter"].Value);
            }

            // Music score charges
            XmlNode musicScore = item.SelectSingleNode("MusicScore");
            metadata.PlayCount = int.Parse(musicScore.Attributes["playCount"].Value);
            metadata.FileName = musicScore.Attributes["fileName"].Value;
            metadata.IsCustomScore = bool.Parse(musicScore.Attributes["isCustomNote"].Value);

            // Shop ID from currency items
            if (item["Shop"] != null)
            {
                XmlNode shop = item.SelectSingleNode("Shop");
                metadata.ShopID = int.Parse(shop.Attributes["systemShopID"].Value);
            }

            XmlNode skill = item.SelectSingleNode("skill");
            metadata.SkillID = int.Parse(skill.Attributes["skillID"].Value);

            XmlNode limit = item.SelectSingleNode("limit");
            metadata.EnableBreak = byte.Parse(limit.Attributes["enableBreak"].Value) == 1;
            metadata.Level = int.Parse(limit.Attributes["levelLimit"].Value);
            metadata.TransferType = (TransferType) byte.Parse(limit.Attributes["transferType"].Value);
            metadata.Sellable = byte.Parse(limit.Attributes["shopSell"].Value) == 1;
            metadata.RecommendJobs = limit.Attributes["recommendJobs"]?.Value.Split(",").Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse).ToList();
            metadata.Gender = (Gender) byte.Parse(limit.Attributes["genderLimit"].Value);

            XmlNode installNode = item.SelectSingleNode("install");
            metadata.IsCubeSolid = byte.Parse(installNode.Attributes["cubeProp"].Value) == 1;
            metadata.ObjectId = int.Parse(installNode.Attributes["objCode"].Value);

            XmlNode housingNode = item.SelectSingleNode("housing");
            string value = housingNode.Attributes["categoryTag"]?.Value;
            if (value is not null)
            {
                List<string> categories = new(value.Split(","));
                _ = short.TryParse(categories[0], out short category);

                metadata.HousingCategory = (ItemHousingCategory) category;
            }

            // Item breaking ingredients
            if (rewards.ContainsKey(itemId))
            {
                metadata.BreakRewards = rewards[itemId];
            }

            // Item rarities
            if (rarities.ContainsKey(itemId))
            {
                metadata.Rarity = rarities[itemId];
            }

            // Item Names
            if (names.ContainsKey(itemId))
            {
                metadata.Name = names[itemId];
            }

            items.Add(metadata);
        }
        return items;
    }

19 View Source File : PathDataHolderEditor.cs
License : MIT License
Project Creator : Adsito

public override void OnInspectorGUI()
    {
        PathDataHolder script = (PathDataHolder)target;
        script.pathData.name = EditorGUILayout.TextField("Name", script.pathData.name + "");
        script.pathData.spline = EditorGUILayout.Toggle("Spline", script.pathData.spline);
        script.pathData.start = EditorGUILayout.Toggle("Start", script.pathData.start);
        script.pathData.end = EditorGUILayout.Toggle("End", script.pathData.end);
        script.pathData.width = EditorGUILayout.FloatField("Width", script.pathData.width);

        script.pathData.innerPadding = EditorGUILayout.FloatField("Inner Padding", script.pathData.innerPadding);
        script.pathData.outerPadding = EditorGUILayout.FloatField("Outer Padding", script.pathData.outerPadding);

        script.pathData.innerFade = EditorGUILayout.FloatField("Inner Fade", script.pathData.innerFade);
        script.pathData.outerFade = EditorGUILayout.FloatField("Outer Fade", script.pathData.outerFade);
        
        script.pathData.randomScale = EditorGUILayout.FloatField("Random Scale", script.pathData.randomScale);
        script.pathData.meshOffset = EditorGUILayout.FloatField("Mesh Offset", script.pathData.meshOffset);
        script.pathData.terrainOffset = EditorGUILayout.FloatField("Terrain Offset", script.pathData.terrainOffset);

        script.pathData.splat = EditorGUILayout.IntField("Splat", script.pathData.splat);
        script.pathData.topology = EditorGUILayout.IntField("Topology", script.pathData.topology);

        GUILayout.Label("Path Tools", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add path node to start"))
            script.AddNodeToStart();
        if (GUILayout.Button("Add path node to end"))
            script.AddNodeToEnd();
        GUILayout.EndHorizontal();
        GUILayout.Label("Node Resolution Factor");
        script.resolutionFactor = float.Parse(GUILayout.TextField(script.resolutionFactor + ""));
        script.resolutionFactor = GUILayout.HorizontalSlider(script.resolutionFactor, 0, 1);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Increase Nodes Resolution"))
            script.IncreaseNodesRes();
        if (GUILayout.Button("Decrease Nodes Resolution"))
            script.DecreaseNodesRes();
        GUILayout.EndHorizontal();
    }

19 View Source File : AnimationParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<AnimationMetadata> Parse()
    {
        List<AnimationMetadata> animations = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("anikeytext"))
            {
                continue;
            }

            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            foreach (XmlNode animationNode in doreplacedent.DoreplacedentElement.ChildNodes)
            {
                AnimationMetadata metadata = new();

                if (animationNode.Name == "kfm")
                {
                    metadata.ActorId = animationNode.Attributes["name"].Value;
                }
                foreach (XmlNode sequenceNode in animationNode)
                {
                    if (sequenceNode.Name != "seq")
                    {
                        continue;
                    }

                    SequenceMetadata sequence = new();
                    sequence.SequenceId = short.Parse(sequenceNode.Attributes["id"].Value);
                    sequence.SequenceName = sequenceNode.Attributes["name"].Value;
                    foreach (XmlNode keyNode in sequenceNode)
                    {
                        KeyMetadata key = new();
                        key.KeyName = keyNode.Attributes["name"].Value;
                        key.KeyTime = float.Parse(keyNode.Attributes["time"].Value);
                        sequence.Keys.Add(key);
                    }
                    metadata.Sequence.Add(sequence);
                }
                animations.Add(metadata);
            }
        }
        return animations;
    }

19 View Source File : ItemOptionStaticParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<ItemOptionStaticMetadata> Parse()
    {
        List<ItemOptionStaticMetadata> items = new();
        Dictionary<int, List<ItemOptionsStatic>> itemOptionsStatic = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("itemoption/option/static"))
            {
                continue;
            }

            XmlDoreplacedent innerDoreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList nodeList = innerDoreplacedent.SelectNodes("/ms2/option");
            string filename = Path.GetFileNameWithoutExtension(entry.Name);
            foreach (XmlNode node in nodeList)
            {
                _ = int.TryParse(node.Attributes["code"]?.Value ?? "0", out int id);
                ItemOptionsStatic optionsStatic = new();

                foreach (XmlNode item in node.Attributes)
                {
                    switch (item.Name)
                    {
                        case "grade":
                            _ = byte.TryParse(node.Attributes["grade"]?.Value ?? "0", out optionsStatic.Rarity);
                            break;
                        case "optionNumPick":
                            optionsStatic.Slots = node.Attributes[item.Name].Value.Split(",").Select(byte.Parse).ToArray();
                            break;
                        case "abp_rate_base":
                            optionsStatic.Stats.Add(new(StatId.PerfectGuard, float.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "asp_value_base":
                            optionsStatic.Stats.Add(new(StatId.AttackSpeed, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "atp_value_base":
                            optionsStatic.Stats.Add(new(StatId.Accuracy, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "bap_value_base":
                            optionsStatic.Stats.Add(new(StatId.BonusAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "cad_value_base":
                            optionsStatic.Stats.Add(new(StatId.CritDamage, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "cap_value_base":
                            optionsStatic.Stats.Add(new(StatId.CritRate, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "car_value_base":
                            optionsStatic.Stats.Add(new(StatId.CritEvasion, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "dex_value_base":
                            optionsStatic.Stats.Add(new(StatId.Dex, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "evp_value_base":
                            optionsStatic.Stats.Add(new(StatId.Evasion, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "finaladditionaldamage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.TotalDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "firedamage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.FireDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "firedamagereduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.FireDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "heal_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.Heal, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "hp_rgp_value_base":
                            optionsStatic.Stats.Add(new(StatId.HpRegen, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "hp_value_base":
                            optionsStatic.Stats.Add(new(StatId.Hp, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "icedamage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.IceDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "icedamagereduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.IceDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "int_value_base":
                            optionsStatic.Stats.Add(new(StatId.Int, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "killhprestore_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.HpOnKill, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "knockbackreduce_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.KnockbackReduce, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "lddincrease_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.RangedDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "longdistancedamagereduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.RangedDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "lightdamage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.HolyDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "lightdamagereduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.HolyDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "luk_value_base":
                            optionsStatic.Stats.Add(new(StatId.Luk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "map_value_base":
                            optionsStatic.Stats.Add(new(StatId.MagicAtk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "mar_value_base":
                            optionsStatic.Stats.Add(new(StatId.MagicRes, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "marpen_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.MagicPiercing, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "msp_value_base":
                            optionsStatic.Stats.Add(new(StatId.MovementSpeed, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "ndd_value_base":
                            optionsStatic.Stats.Add(new(StatId.Defense, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "nddincrease_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.MeleeDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "neardistancedamagereduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.MeleeDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "pap_value_base":
                            optionsStatic.Stats.Add(new(StatId.PhysicalAtk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "par_value_base":
                            optionsStatic.Stats.Add(new(StatId.PhysicalRes, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "parpen_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.PhysicalPiercing, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "pen_rate_base":
                            optionsStatic.Stats.Add(new(StatId.Pierce, float.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "poisondamage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.PoisonDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "poisondamagereduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.PoisonDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "sgi_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.BossDamage, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "skillcooldown_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.CooldownReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "str_value_base":
                            optionsStatic.Stats.Add(new(StatId.Str, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "stunreduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.StunReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "thunderdamage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ElectricDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "thunderdamagereduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ElectricDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "wapmax_value_base":
                            optionsStatic.Stats.Add(new(StatId.MaxWeaponAtk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "wapmin_value_base":
                            optionsStatic.Stats.Add(new(StatId.MinWeaponAtk, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "bap_pet_value_base":
                            optionsStatic.Stats.Add(new(StatId.PetBonusAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "receivedhealincrease_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.AllyRecovery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "reduce_darkstream_recive_damage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DarkDescentDamageReduce, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "smd_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.MesoBonus, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "sss_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.SwimSpeed, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "wapmin_rate_base":
                            optionsStatic.Stats.Add(new(StatId.MinWeaponAtk, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "wapmax_rate_base":
                            optionsStatic.Stats.Add(new(StatId.MaxWeaponAtk, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "pvpdamagereduce_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.PvPDefense, 0, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "pvpdamageincrease_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.PvPDamage, 0, int.Parse(node.Attributes[item.Name].Value.Split(",").First())));
                            break;
                        case "improve_pvp_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.PvPExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_honor_token_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ValorTokens, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npckilldropitemincrate_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DropRate, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_ox_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.OXQuizExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_finalsurvival_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.SoleSurvivorExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_trapmaster_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.TrapMasterExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_crazyrunner_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.CrazyRunnerExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_escape_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.LudiEscapeExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_springbeach_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.SpringBeachExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_dancedance_exp_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DanceDanceExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_ox_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.OXMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_finalsurvival_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.SoleSurvivorMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_trapmaster_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.TrapMasterMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_crazyrunner_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.CrazyRunnerMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_escape_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.LudiEscapeMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_springbeach_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.SpringBeachMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_dancedance_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DanceDanceStopMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "seg_fishingreward_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.FishingExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "seg_playinstrumentreward_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.PerformanceExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npc_hit_reward_sp_ball_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.GenerateSpiritOrbs, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npc_hit_reward_ep_ball_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.GenerateStaminaOrbs, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "complete_fieldmission_msp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ExploredAreasMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_glide_vertical_velocity_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.AirMountAscentSpeed, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "fishing_double_mastery_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DoubleFishingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "playinstrument_double_mastery_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DoublePerformanceMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "gathering_double_mastery_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DoubleForagingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "farming_double_mastery_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DoubleFarmingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "mining_double_mastery_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DoubleMiningMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "breeding_double_mastery_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DoubleRanchingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_darkstream_damage_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DarkDescentDamageBonus, float.Parse(node.Attributes[item.Name].Value.Split(",").First()), 0));
                            break;
                        case "improve_chaosraid_wap_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ChaosRaidWeaponAttack, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_chaosraid_asp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ChaosRaidAttackSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_chaosraid_atp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ChaosRaidAccuracy, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_chaosraid_hp_value_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.ChaosRaidHealth, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "hiddennddadd_value_base":
                            optionsStatic.HiddenDefenseAdd = int.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "hiddenwapadd_value_base":
                            optionsStatic.HiddenWeaponAtkAdd = int.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "nddcalibrationfactor_rate_base":
                            optionsStatic.DefenseCalibrationFactor = float.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "wapcalibrationfactor_rate_base":
                            optionsStatic.WeaponAtkCalibrationFactor = float.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "conditionreduce_rate_base":
                            optionsStatic.SpecialStats.Add(new(SpecialStatId.DebuffDurationReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "additionaleffect_95000012_value_base":
                        case "additionaleffect_95000014_value_base":
                        case "sgi_target":
                        case "code":
                            break;
                    }
                }

                if (itemOptionsStatic.ContainsKey(id))
                {
                    itemOptionsStatic[id].Add(optionsStatic);
                }
                else
                {
                    itemOptionsStatic[id] = new()
                    {
                        optionsStatic
                    };
                }
            }

            foreach (KeyValuePair<int, List<ItemOptionsStatic>> optionsData in itemOptionsStatic)
            {
                ItemOptionStaticMetadata metadata = new();
                metadata.Id = optionsData.Key;
                metadata.ItemOptions.AddRange(optionsData.Value);
                items.Add(metadata);
            }
        }
        return items;
    }

19 View Source File : AMFPatches.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

public static bool _OnDealDamage_Prefix(BaseEnchantment __instance, string ____displayName, Monster monster, GameLocation location, Farmer who, ref int amount)
        {
            if (!(__instance is BaseWeaponEnchantment) || ____displayName == null  || ____displayName == "" || !ModEntry.advancedEnchantments.ContainsKey(____displayName) || (ModEntry.EnchantmentTriggers.ContainsKey(who.uniqueMultiplayerID + ____displayName) && ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] == Game1.ticks))
                return true;
            AdvancedEnchantmentData enchantment = ModEntry.advancedEnchantments[____displayName];

            if (enchantment?.parameters?.ContainsKey("trigger") != true)
                return true;

            if (enchantment.parameters["trigger"] == "damage" || (enchantment.parameters["trigger"] == "crit" && amount > (who.CurrentTool as MeleeWeapon).maxDamage) && !Environment.StackTrace.Contains("OnCalculateDamage"))
            {
                context.Monitor.Log($"Triggered enchantment {enchantment.name} on {enchantment.parameters["trigger"]} {amount} {(who.CurrentTool as MeleeWeapon).enchantments.Count}");
                ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] = Game1.ticks;
                if (enchantment.type == "heal")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        int heal = Math.Max(1, (int)(amount * float.Parse(enchantment.parameters["amountMult"])));
                        who.health = Math.Min(who.maxHealth, Game1.player.health + heal);
                        location.debris.Add(new Debris(heal, new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()), Color.Lime, 1f, who));
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
                else if (enchantment.type == "coins")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        float mult = float.Parse(enchantment.parameters["amountMult"]);
                        int coins = (int)Math.Round(mult * amount);
                        who.Money += coins;
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                } 
            }
            return false;
        }

19 View Source File : ItemOptionConstantParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<ItemOptionConstantMetadata> Parse()
    {
        List<ItemOptionConstantMetadata> items = new();
        Dictionary<int, List<ItemOptionsConstant>> itemOptionsConstant = new();

        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("itemoption/constant"))
            {
                continue;
            }

            XmlDoreplacedent innerDoreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList nodeList = innerDoreplacedent.SelectNodes("/ms2/option");
            string filename = Path.GetFileNameWithoutExtension(entry.Name);
            foreach (XmlNode node in nodeList)
            {
                int id = int.Parse(node.Attributes["code"]?.Value ?? "0");
                ItemOptionsConstant constant = new();

                foreach (XmlNode item in node.Attributes)
                {
                    switch (item.Name)
                    {
                        case "code":
                            break;
                        case "grade":
                            constant.Rarity = byte.Parse(node.Attributes["grade"]?.Value ?? "0");
                            break;
                        case "abp_rate_base":
                            constant.Stats.Add(new(StatId.PerfectGuard, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "asp_value_base":
                            constant.Stats.Add(new(StatId.AttackSpeed, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "atp_value_base":
                            constant.Stats.Add(new(StatId.Accuracy, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "bap_value_base":
                            constant.Stats.Add(new(StatId.BonusAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "cad_value_base":
                            constant.Stats.Add(new(StatId.CritDamage, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "cap_value_base":
                            constant.Stats.Add(new(StatId.CritRate, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "car_value_base":
                            constant.Stats.Add(new(StatId.CritEvasion, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "dex_value_base":
                            constant.Stats.Add(new(StatId.Dex, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "evp_value_base":
                            constant.Stats.Add(new(StatId.Evasion, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "finaladditionaldamage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.TotalDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "firedamage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.FireDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "firedamagereduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.FireDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "heal_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.Heal, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "hp_rgp_value_base":
                            constant.Stats.Add(new(StatId.HpRegen, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "hp_value_base":
                            constant.Stats.Add(new(StatId.Hp, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "icedamage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.IceDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "icedamagereduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.IceDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "int_value_base":
                            constant.Stats.Add(new(StatId.Int, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "killhprestore_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.HpOnKill, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "knockbackreduce_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.KnockbackReduce, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "lddincrease_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.RangedDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "longdistancedamagereduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.RangedDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "lightdamage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.HolyDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "lightdamagereduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.HolyDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "luk_value_base":
                            constant.Stats.Add(new(StatId.Luk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "map_value_base":
                            constant.Stats.Add(new(StatId.MagicAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "mar_value_base":
                            constant.Stats.Add(new(StatId.MagicRes, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "marpen_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.MagicPiercing, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "msp_value_base":
                            constant.Stats.Add(new(StatId.MovementSpeed, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "ndd_value_base":
                            constant.Stats.Add(new(StatId.Defense, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "nddincrease_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.MeleeDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "neardistancedamagereduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.MeleeDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "pap_value_base":
                            constant.Stats.Add(new(StatId.PhysicalAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "par_value_base":
                            constant.Stats.Add(new(StatId.PhysicalRes, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "parpen_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.PhysicalPiercing, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "pen_rate_base":
                            constant.Stats.Add(new(StatId.Pierce, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "poisondamage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.PoisonDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "poisondamagereduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.PoisonDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "sgi_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.BossDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "skillcooldown_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.CooldownReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "str_value_base":
                            constant.Stats.Add(new(StatId.Str, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "stunreduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.StunReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "thunderdamage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ElectricDamage, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "thunderdamagereduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ElectricDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "wapmax_value_base":
                            constant.Stats.Add(new(StatId.MaxWeaponAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "wapmin_value_base":
                            constant.Stats.Add(new(StatId.MinWeaponAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "bap_pet_value_base":
                            constant.Stats.Add(new(StatId.PetBonusAtk, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "receivedhealincrease_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.AllyRecovery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "reduce_darkstream_recive_damage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DarkDescentDamageReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "smd_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.MesoBonus, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "sss_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.SwimSpeed, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "wapmin_rate_base":
                            constant.Stats.Add(new(StatId.MinWeaponAtk, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "wapmax_rate_base":
                            constant.Stats.Add(new(StatId.MaxWeaponAtk, float.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "pvpdamagereduce_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.PvPDefense, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "pvpdamageincrease_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.PvPDamage, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_pvp_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.PvPExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_honor_token_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ValorTokens, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npckilldropitemincrate_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DropRate, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_ox_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.OXQuizExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_finalsurvival_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.SoleSurvivorExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_trapmaster_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.TrapMasterExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_crazyrunner_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.CrazyRunnerExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_escape_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.LudiEscapeExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_springbeach_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.SpringBeachExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_dancedance_exp_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DanceDanceExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_mreplacedive_ox_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.OXMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_finalsurvival_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.SoleSurvivorMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_trapmaster_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.TrapMasterMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_crazyrunner_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.CrazyRunnerMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_escape_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.LudiEscapeMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_springbeach_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.SpringBeachMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_mreplacedive_dancedance_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DanceDanceStopMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "seg_fishingreward_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.FishingExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "seg_playinstrumentreward_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.PerformanceExp, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npc_hit_reward_sp_ball_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.GenerateSpiritOrbs, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "npc_hit_reward_ep_ball_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.GenerateStaminaOrbs, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "complete_fieldmission_msp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ExploredAreasMovementSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_glide_vertical_velocity_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.AirMountAscentSpeed, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "fishing_double_mastery_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DoubleFishingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "playinstrument_double_mastery_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DoublePerformanceMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "gathering_double_mastery_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DoubleForagingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "farming_double_mastery_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DoubleFarmingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "mining_double_mastery_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DoubleMiningMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "breeding_double_mastery_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DoubleRanchingMastery, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_darkstream_damage_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DarkDescentDamageBonus, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_chaosraid_wap_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ChaosRaidWeaponAttack, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "improve_chaosraid_asp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ChaosRaidAttackSpeed, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_chaosraid_atp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ChaosRaidAccuracy, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "improve_chaosraid_hp_value_base":
                            constant.SpecialStats.Add(new(SpecialStatId.ChaosRaidHealth, 0, int.Parse(node.Attributes[item.Name].Value)));
                            break;
                        case "conditionreduce_rate_base":
                            constant.SpecialStats.Add(new(SpecialStatId.DebuffDurationReduce, float.Parse(node.Attributes[item.Name].Value), 0));
                            break;
                        case "hiddenwapadd_value_base":
                            constant.HiddenWeaponAtkAdd = int.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "wapcalibrationfactor_rate_base":
                            constant.WeaponAtkCalibrationFactor = float.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "hiddennddadd_value_base":
                            constant.HiddenDefenseAdd = int.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "nddcalibrationfactor_rate_base":
                            constant.DefenseCalibrationFactor = float.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "hiddenbapadd_value_base":
                            constant.HiddenBonusAtkAdd = int.Parse(node.Attributes[item.Name].Value);
                            break;
                        case "additionaleffect_95000012_value_base":
                        case "additionaleffect_95000014_value_base":
                        case "optionNumPick": // this isn't used in constant item options
                            break;
                    }
                }

                if (itemOptionsConstant.ContainsKey(id))
                {
                    itemOptionsConstant[id].Add(constant);
                }
                else
                {
                    itemOptionsConstant[id] = new()
                    {
                        constant
                    };
                }
            }

            foreach (KeyValuePair<int, List<ItemOptionsConstant>> optionsData in itemOptionsConstant)
            {
                ItemOptionConstantMetadata metadata = new();
                metadata.Id = optionsData.Key;
                metadata.ItemOptions.AddRange(optionsData.Value);
                items.Add(metadata);
            }
        }
        return items;
    }

19 View Source File : FrmDoublePageReader.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void PreviousPage() // -
        {
            if (cmboPage.SelectedIndex > 1)
            {
                cmboPage.SelectedIndex = cmboPage.SelectedIndex - 2;
                float currentPage = float.Parse(cmboPage.SelectedItem.ToString());
                float percent = (currentPage / (float)numPagesInCurrentChapter) * 100;
                progress.Value = (int)percent;
            } else if (cmboPage.SelectedIndex > 0)
            {
                cmboPage.SelectedIndex = cmboPage.SelectedIndex - 1;
                float currentPage = float.Parse(cmboPage.SelectedItem.ToString());
                float percent = (currentPage / (float)numPagesInCurrentChapter) * 100;
                progress.Value = (int)percent;
            }
        }

19 View Source File : ItemOptionRangeParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

private static List<ParserSpecialStat> ParseSpecialValues(SpecialStatId attribute, XmlNode node, bool isPercent)
    {
        List<ParserSpecialStat> values = new();
        for (int i = 2; i <= 17; i++)
        {
            float value = float.Parse(node.Attributes[$"idx{i}"].Value);
            values.Add(new(attribute, isPercent ? value : 0, !isPercent ? value : 0));
        }

19 View Source File : AdvancedEnchantment.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

protected override void _OnMonsterSlay(Monster m, GameLocation location, Farmer who)
        {
            if (enchantment.parameters["trigger"] == "slay")
            {
                //ModEntry.context.Monitor.Log($"Triggered enchantment {enchantment.type} on slay for {weapon.Name}");
                if (enchantment.type == "heal")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        int heal = Math.Max(1, (int)(m.Health * float.Parse(enchantment.parameters["amountMult"])));
                        who.health = Math.Min(who.maxHealth, Game1.player.health + heal);
                        location.debris.Add(new Debris(heal, new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()), Color.Lime, 1f, who));
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                    return;
                }
                else if (enchantment.type == "loot")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        if (enchantment.parameters.ContainsKey("extraDropChecks"))
                        {
                            int extraChecks = Math.Max(1, int.Parse(enchantment.parameters["extraDropChecks"]));
                            for (int i = 0; i < extraChecks; i++)
                            {
                                location.monsterDrop(m, m.GetBoundingBox().Center.X, m.GetBoundingBox().Center.Y, who);
                            }
                        }
                        else if (enchantment.parameters.ContainsKey("extraDropItems"))
                        {
                            string[] items = enchantment.parameters["extraDropItems"].Split(',');
                            foreach (string item in items)
                            {
                                string[] ic = item.Split('_');
                                if (ic.Length == 1)
                                    Game1.createItemDebris(new Object(int.Parse(item), 1, false, -1, 0), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                else if(ic.Length == 2)
                                {
                                    float chance = int.Parse(ic[1]) / 100f;
                                    if (Game1.random.NextDouble() < chance)
                                        Game1.createItemDebris(new Object(int.Parse(ic[0]), 1, false, -1, 0), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                }
                                else if(ic.Length == 4)
                                {
                                    float chance = int.Parse(ic[3]) / 100f;
                                    if (Game1.random.NextDouble() < chance)
                                        Game1.createItemDebris(new Object(int.Parse(ic[0]), Game1.random.Next(int.Parse(ic[1]), int.Parse(ic[2]))), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                }
                            }
                        }
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
                else if (enchantment.type == "coins")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        float mult = float.Parse(enchantment.parameters["amountMult"]);
                        int amount = (int)Math.Round(mult * m.maxHealth);
                        who.Money += amount;
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
            }
        }

19 View Source File : SkillParser.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

protected override List<SkillMetadata> Parse()
    {
        List<SkillMetadata> skillList = new();
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            // Parsing Skills
            if (entry.Name.StartsWith("skill"))
            {
                XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
                XmlNode ui = doreplacedent.SelectSingleNode("/ms2/basic/ui");
                XmlNode kinds = doreplacedent.SelectSingleNode("/ms2/basic/kinds");
                XmlNode stateAttr = doreplacedent.SelectSingleNode("/ms2/basic/stateAttr");
                XmlNodeList levels = doreplacedent.SelectNodes("/ms2/level");

                int skillId = int.Parse(Path.GetFileNameWithoutExtension(entry.Name));
                string skillState = kinds.Attributes["state"]?.Value ?? "";
                byte skillAttackType = byte.Parse(ui.Attributes["attackType"]?.Value ?? "0");
                byte skillType = byte.Parse(kinds.Attributes["type"].Value);
                byte skillSubType = byte.Parse(kinds.Attributes["subType"]?.Value ?? "0");
                byte skillElement = byte.Parse(kinds.Attributes["element"].Value);
                byte skillSuperArmor = byte.Parse(stateAttr.Attributes["superArmor"].Value);
                bool skillRecovery = int.Parse(kinds.Attributes["spRecoverySkill"]?.Value ?? "0") == 1;

                List<SkillLevel> skillLevels = new();
                foreach (XmlNode level in levels)
                {
                    // Getting all skills level
                    string feature = level.Attributes["feature"]?.Value ?? "";
                    int levelValue = int.Parse(level.Attributes["value"].Value ?? "0");
                    // We prevent duplicates levels from older balances.
                    if (skillLevels.Exists(level => level.Level == levelValue))
                    {
                        continue;
                    }
                    int spirit = int.Parse(level.SelectSingleNode("consume/stat").Attributes["sp"]?.Value ?? "0");
                    int stamina = int.Parse(level.SelectSingleNode("consume/stat").Attributes["ep"]?.Value ?? "0");
                    float damageRate = float.Parse(level.SelectSingleNode("motion/attack/damageProperty")?.Attributes["rate"].Value ?? "0");
                    string sequenceName = level.SelectSingleNode("motion/motionProperty")?.Attributes["sequenceName"].Value ?? "";
                    string motionEffect = level.SelectSingleNode("motion/motionProperty")?.Attributes["motionEffect"].Value ?? "";

                    SkillUpgrade skillUpgrade = new();
                    if (level.SelectSingleNode("motion/upgrade")?.Attributes != null)
                    {
                        int upgradeLevel = int.Parse(level.SelectSingleNode("motion/upgrade").Attributes["level"].Value ?? "0");
                        int[] upgradeSkills = level.SelectSingleNode("motion/upgrade").Attributes["skillIDs"].Value.Split(",").Select(int.Parse).ToArray();
                        short[] upgradeSkillsLevel = level.SelectSingleNode("motion/upgrade").Attributes["skillLevels"].Value.Split(",").Select(short.Parse).ToArray();

                        skillUpgrade = new(upgradeLevel, upgradeSkills, upgradeSkillsLevel);
                    }

                    // Getting all Attack attr in each level.
                    List<SkillAttack> skillAttacks = new();
                    List<SkillCondition> skillConditions = new();

                    XmlNodeList conditionSkills = level.SelectNodes("motion/attack/conditionSkill") ?? level.SelectNodes("conditionSkill");
                    foreach (XmlNode conditionSkill in conditionSkills)
                    {
                        int conditionSkillId = int.Parse(conditionSkill.Attributes["skillID"]?.Value ?? "0");
                        short conditionSkillLevel = short.Parse(conditionSkill.Attributes["level"]?.Value ?? "0");
                        bool splash = conditionSkill.Attributes["splash"]?.Value == "1";
                        byte target = byte.Parse(conditionSkill.Attributes["skillTarget"].Value ?? "0");
                        byte owner = byte.Parse(conditionSkill.Attributes["skillOwner"]?.Value ?? "0");
                        SkillCondition skillCondition = new(conditionSkillId, conditionSkillLevel, splash, target, owner);

                        skillConditions.Add(skillCondition);
                    }

                    XmlNodeList attackListAttr = level.SelectNodes("motion/attack");
                    foreach (XmlNode attackAttr in attackListAttr)
                    {
                        // Many skills has a condition to proc another skill.
                        // We capture that as a list, since each Attack attr has one at least.
                        byte attackPoint = byte.Parse(Regex.Match(attackAttr.Attributes["point"]?.Value, @"\d").Value);
                        short targetCount = short.Parse(attackAttr.Attributes["targetCount"].Value);
                        long magicPathId = long.Parse(attackAttr.Attributes["magicPathID"]?.Value ?? "0");
                        long cubeMagicPathId = long.Parse(attackAttr.Attributes["cubeMagicPathID"]?.Value ?? "0");
                        SkillAttack skillAttack = new(attackPoint, targetCount, magicPathId, cubeMagicPathId);

                        skillAttacks.Add(skillAttack);
                    }

                    SkillMotion skillMotion = new(sequenceName, motionEffect);
                    SkillLevel skillLevel = new(levelValue, spirit, stamina, damageRate, feature, skillMotion, skillAttacks, skillConditions, skillUpgrade);
                    skillLevels.Add(skillLevel);
                }
                skillList.Add(new(skillId, skillLevels, skillState, skillAttackType, skillType, skillSubType, skillElement, skillSuperArmor, skillRecovery));
                continue;
            }

            // Parsing SubSkills
            if (entry.Name.StartsWith("table/job"))
            {
                XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
                XmlNodeList jobs = doreplacedent.SelectNodes("/ms2/job");
                foreach (XmlNode job in jobs)
                {
                    // Grabs all the skills and them the jobCode.
                    XmlNodeList skills = job.SelectNodes("skills/skill");
                    int jobCode = int.Parse(job.Attributes["code"].Value);
                    foreach (XmlNode skill in skills)
                    {
                        int id = int.Parse(skill.Attributes["main"].Value);
                        short maxLevel = short.Parse(skill.Attributes["maxLevel"]?.Value ?? "1");
                        skillList.Find(x => x.SkillId == id).Job = jobCode;
                        skillList.Find(x => x.SkillId == id).MaxLevel = maxLevel;

                        // If it has subSkill, add as well.
                        if (skill.Attributes["sub"] == null)
                        {
                            continue;
                        }

                        int[] sub = skill.Attributes["sub"].Value.Split(",").Select(int.Parse).ToArray();
                        skillList.Find(x => x.SkillId == id).SubSkills = sub;
                        for (int n = 0; n < sub.Length; n++)
                        {
                            if (skillList.Select(x => x.SkillId).Contains(sub[n]))
                            {
                                skillList.Find(x => x.SkillId == sub[n]).Job = jobCode;
                            }
                        }
                    }
                    XmlNodeList learnSkills = job.SelectNodes("learn/skill");
                    foreach (XmlNode learnSkill in learnSkills)
                    {
                        int id = int.Parse(learnSkill.Attributes["id"].Value);
                        skillList.Find(x => x.SkillId == id).CurrentLevel = 1;
                    }
                }
            }
        }

        // Parsing Additional Data
        foreach (PackFileEntry entry in Resources.XmlReader.Files)
        {
            if (!entry.Name.StartsWith("additionaleffect"))
            {
                continue;
            }

            XmlDoreplacedent doreplacedent = Resources.XmlReader.GetXmlDoreplacedent(entry);
            XmlNodeList levels = doreplacedent.SelectNodes("/ms2/level");
            int skillId = int.Parse(Path.GetFileNameWithoutExtension(entry.Name));

            List<SkillLevel> skillLevels = new();
            if (skillList.Select(x => x.SkillId).Contains(skillId))
            {
                foreach (XmlNode level in levels)
                {
                    int currentLevel = int.Parse(level.SelectSingleNode("BasicProperty").Attributes["level"]?.Value ?? "0");
                    skillLevels = skillList.Find(x => x.SkillId == skillId).SkillLevels;

                    if (skillLevels.Select(x => x.Level).Contains(currentLevel))
                    {
                        skillLevels.Find(x => x.Level == currentLevel).SkillAdditionalData = ParseSkillData(level);
                    }
                }
                continue;
            }

            // Adding missing skills from additionaleffect.
            // Since they are many skills that are called by another skill and not from player directly.
            foreach (XmlNode level in levels)
            {
                int currentLevel = int.Parse(level.SelectSingleNode("BasicProperty").Attributes["level"]?.Value ?? "0");
                skillLevels.Add(new(currentLevel, ParseSkillData(level)));
            }
            skillList.Add(new(skillId, skillLevels));

        }
        return skillList;
    }

19 View Source File : Half.cs
License : MIT License
Project Creator : 91Act

public static Half Parse(string value, NumberStyles style, IFormatProvider provider)
        {
            return (Half)float.Parse(value, style, provider);
        }

19 View Source File : RoadSigns.cs
License : GNU General Public License v3.0
Project Creator : Albo1125

public static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            if (sender == roadManagementMenu)
            {

                if (selectedItem == barriersList)
                {
                    SignTypeToPlace = SignTypes.Barrier;
                    sender.Visible = false;
                    PlaceSignItem.Text = "Place " + barriersList.Collection[barriersList.Index].Value.ToString();
                    PlaceSignMenu.RefreshIndex();
                    PlaceSignMenu.Visible = true;
                    PositionToPlaceAt = Game.LocalPlayer.Character.Position;
                    RotationToPlaceAt = Game.LocalPlayer.Character.Rotation;
                }

                else if (selectedItem == conesList)
                {
                    SignTypeToPlace = SignTypes.Cone;
                    sender.Visible = false;
                    PlaceSignItem.Text = "Place " + conesList.Collection[conesList.Index].Value.ToString();
                    PlaceSignMenu.RefreshIndex();
                    PlaceSignMenu.Visible = true;
                    PositionToPlaceAt = Game.LocalPlayer.Character.Position;
                    RotationToPlaceAt = Game.LocalPlayer.Character.Rotation;

                }

                else if (selectedItem == removeLastDroppedSignItem)
                {
                    removeLastSign();
                }
                else if (selectedItem == RemoveNearestSignItem)
                {
                    RemoveNearestSign();
                }
                else if (selectedItem == removeAllSignsItem)
                {
                    removeAllSigns();
                }
            }
            else if (sender == PlaceSignMenu)
            {
                if (selectedItem == PlaceSignItem)
                {
                    
                    string direction = SpawnDirectionLisreplacedem.Collection[SpawnDirectionLisreplacedem.Index].Value.ToString();
                    float multiplier = float.Parse(SpawnMultiplierLisreplacedem.Collection[SpawnMultiplierLisreplacedem.Index].Value.ToString());
                    Vector3 spawn = DetermineSignSpawn(direction, multiplier);
                    float Heading = float.Parse(HeadingItem.Collection[HeadingItem.Index].Value.ToString());
                    if (SignTypeToPlace == SignTypes.Barrier)
                    {
                        string selectedsign = barriersToChooseFrom[barriersList.Index];
                        if (barriersList.Collection[barriersList.Index].Value.ToString() == "Stripes Left")
                        {

                            dropSign(selectedsign, true, spawn, Heading);
                        }
                        else
                        {
                            dropSign(selectedsign, false, spawn, Heading);
                        }
                        Game.LogTrivial("Barrier Placed");
                    }
                    else if (SignTypeToPlace == SignTypes.Cone)
                    {
                        string selectedsign = conesToChooseFrom[conesList.Index];
                        dropSign(selectedsign, false, spawn, Heading);
                        Game.LogTrivial("Cone Placed");
                    }
                }
                
            }
        }

19 View Source File : MissionParameterParser.cs
License : MIT License
Project Creator : ahydrax

public static (object value, ErrorType error, bool ok) ParseParameter(Type parameterType, string parameterValue)
        {
            switch (parameterType)
            {
                case var t when t == typeof(string):
                    return (parameterValue, ErrorType.No, true);

                case var t when t == typeof(bool):
                    return TryParse(JsonConvert.DeserializeObject<bool>, parameterValue);

                case var t when t == typeof(byte):
                    return TryParse(x => byte.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture), parameterValue);

                case var t when t == typeof(sbyte):
                    return TryParse(x => sbyte.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture),
                        parameterValue);

                case var t when t == typeof(char):
                    return TryParse(x => x[0], parameterValue);

                case var t when t == typeof(decimal):
                    return TryParse(x => decimal.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture),
                        parameterValue);

                case var t when t == typeof(double):
                    return TryParse(x => double.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture),
                        parameterValue);

                case var t when t == typeof(float):
                    return TryParse(x => float.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture),
                        parameterValue);

                case var t when t == typeof(int):
                    return TryParse(x => int.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture), parameterValue);

                case var t when t == typeof(uint):
                    return TryParse(x => uint.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture), parameterValue);

                case var t when t == typeof(long):
                    return TryParse(x => long.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture), parameterValue);

                case var t when t == typeof(ulong):
                    return TryParse(x => ulong.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture),
                        parameterValue);

                case var t when t == typeof(short):
                    return TryParse(x => short.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture),
                        parameterValue);

                case var t when t == typeof(ushort):
                    return TryParse(x => ushort.Parse(x, NumberStyles.Any, CultureInfo.InvariantCulture),
                        parameterValue);

                case var t when t == typeof(DateTime):
                    return TryParse(
                        x => DateTimeOffset.ParseExact(x, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None)
                            .UtcDateTime,
                        parameterValue);

                case var t when t == typeof(DateTimeOffset):
                    return TryParse(
                        x => DateTimeOffset.ParseExact(x, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None),
                        parameterValue);

                case var t when t == typeof(Guid):
                    return TryParse(Guid.Parse, parameterValue);
                
                case var t when t.IsEnum:
                    return TryParse(x => Enum.Parse(parameterType, x), parameterValue);

                case var pctx when pctx == typeof(PerformContext):
                case var jct when jct == typeof(IJobCancellationToken):
                case var ct when ct == typeof(CancellationToken):
                    return (null, ErrorType.No, true);

                case var t when t.CanBeInstantiated():
                    return TryParse(x => JsonConvert.DeserializeObject(parameterValue, t), parameterValue);

                default:
                    return (null, ErrorType.Unsupported, false);
            }
        }

19 View Source File : AnnotationAppearance.cs
License : MIT License
Project Creator : AngeloCresta

private void FontName_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(FontSize.SelectedItem != null)
				Chart1.Annotations[0].Font = new Font(FontName.SelectedItem.ToString(), float.Parse(FontSize.SelectedItem.ToString()));
		}

19 View Source File : Inspector.cs
License : GNU General Public License v3.0
Project Creator : a2659802

internal UnityAction<float> UpdateTextDelegate(int idx)
        {
            var PropPanel = PropPanels[idx];
            var slider = PropPanel.transform.Find("Slider").GetComponent<Slider>();
            var text = PropPanel.transform.Find("Value").GetComponent<InputField>();
            AddListener(idx, ((v) => {
                text.text = v.ToString();
            }));
            text.onValueChanged.AddListener((va) =>
            {
                if (float.Parse(va) >= slider.minValue && float.Parse(va) <= slider.maxValue)
                {
                    slider.value = float.Parse(va);
                }
                else
                {
                    text.text = slider.minValue.ToString();
                }
            });
            return null;
        }

19 View Source File : AxisTitle.cs
License : MIT License
Project Creator : AngeloCresta

private void ControlChange(object sender, System.EventArgs e)
		{
			int axis = 0;
			
			foreach( Axis item in Chart1.ChartAreas["Default"].Axes)
			{
				item.replacedle = String.Empty;
			}

			if(this.AxisPosition.SelectedIndex >= 0)
			{
				string strAxis = this.AxisPosition.SelectedItem.ToString();
				if(strAxis == "Axis X")
					axis = 0;
				if(strAxis == "Axis Y")
					axis = 1;
				if(strAxis == "Axis X2")
					axis = 2;
				if(strAxis == "Axis Y2")
					axis = 3;
			}
			// Set selected axis
			Chart1.ChartAreas["Default"].Axes[axis].replacedle = replacedle.Text;

			// Set Font style.
			FontStyle fontStyle = FontStyle.Regular;
			if( ItalicCheck.Checked )
				fontStyle = (FontStyle)FontStyle.Italic;
			if( BoldCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Bold;
			if( UnderlineCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Underline;
			if( StrikeoutCheck.Checked )
				fontStyle |= (FontStyle)FontStyle.Strikeout;

			// Set replacedle font
			if(this.TheFont.SelectedIndex >= 0 && this.FontSize.SelectedIndex >= 0)
			{
				string font = this.TheFont.SelectedItem.ToString();
				float fontpoint = float.Parse(this.FontSize.SelectedItem.ToString());
				try
				{
					Chart1.ChartAreas["Default"].Axes[axis].replacedleFont = new Font(font, fontpoint, fontStyle);
				}
				catch
				{
					Chart1.ChartAreas["Default"].Axes[axis].replacedleFont = new Font("Arial", fontpoint, fontStyle);
				}
			}

			// Set replacedle color
			if(this.FontColorCombo.SelectedIndex >= 0)
			{
				Chart1.ChartAreas["Default"].Axes[axis].replacedleForeColor = Color.FromName(this.FontColorCombo.SelectedItem.ToString());
			}
		}

19 View Source File : UGUIMathNode.cs
License : MIT License
Project Creator : aksyr

private void OnChangeValB(string val) {
			mathNode.b = float.Parse(valB.text);
		}

19 View Source File : PaintingDataTable.cs
License : MIT License
Project Creator : AngeloCresta

private void FontSize_SelectionChangeCommitted(object sender, System.EventArgs e)
		{
			chart1.ChartAreas["Default"].AxisX.replacedleFont = new Font("Arial", float.Parse(FontSize.SelectedItem.ToString()));
		}

19 View Source File : LyricsFetcher.cs
License : MIT License
Project Creator : 71

private static void PopulateFromSrt(TextReader reader, List<Subreplacedle> subreplacedles)
        {
            // Parse using a simple state machine:
            //   0: Parsing number
            //   1: Parsing start / end time
            //   2: Parsing text
            byte state = 0;

            float startTime = 0f,
                  endTime = 0f;

            StringBuilder text = new StringBuilder();
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                switch (state)
                {
                    case 0:
                        if (string.IsNullOrEmpty(line))
                            // No number found; continue in same state.
                            continue;

                        if (!int.TryParse(line, out int _))
                            goto Invalid;

                        // Number found; continue to next state.
                        state = 1;
                        break;

                    case 1:
                        Match m = Regex.Match(line, @"(\d+):(\d+):(\d+,\d+) *--> *(\d+):(\d+):(\d+,\d+)");

                        if (!m.Success)
                            goto Invalid;

                        startTime = int.Parse(m.Groups[1].Value) * 3600
                                  + int.Parse(m.Groups[2].Value) * 60
                                  + float.Parse(m.Groups[3].Value.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture);

                        endTime = int.Parse(m.Groups[4].Value) * 3600
                                + int.Parse(m.Groups[5].Value) * 60
                                + float.Parse(m.Groups[6].Value.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture);

                        // Subreplacedle start / end found; continue to next state.
                        state = 2;
                        break;

                    case 2:
                        if (string.IsNullOrEmpty(line))
                        {
                            // End of text; continue to next state.
                            subreplacedles.Add(new Subreplacedle(text.ToString(), startTime, endTime));

                            text.Length = 0;
                            state = 0;
                        }
                        else
                        {
                            // Continuation of text; continue in same state.
                            text.AppendLine(line);
                        }

                        break;

                    default:
                        // Shouldn't happen.
                        throw new Exception();
                }
            }

            Invalid:

            Debug.Log("[Beat Singer] Invalid subtiles file found, cancelling load...");
            subreplacedles.Clear();
        }

19 View Source File : PrintingSettings.cs
License : MIT License
Project Creator : AngeloCresta

private void SetPrintingSettings()
		{
			// Set page orientation
			if(comboBoxOrientation.Text == "Landscape")
			{
				chart1.Printing.PrintDoreplacedent.DefaultPageSettings.Landscape = true;
			}
			else
			{
				chart1.Printing.PrintDoreplacedent.DefaultPageSettings.Landscape = false;
			}

			// Set page margins
			int	margin = (int)(float.Parse(comboBoxMargin.Text) * 100f);
			chart1.Printing.PrintDoreplacedent.DefaultPageSettings.Margins =
                new System.Drawing.Printing.Margins(margin, margin, margin, margin);

			// Set printer resolution
			foreach(PrinterResolution pr in chart1.Printing.PrintDoreplacedent.PrinterSettings.PrinterResolutions)
			{
				if(pr.Kind.ToString() == comboBoxResolution.Text)
				{
					chart1.Printing.PrintDoreplacedent.DefaultPageSettings.PrinterResolution = pr;
				}
			}
		}

19 View Source File : UGUIVector.cs
License : MIT License
Project Creator : aksyr

private void OnChangeValY(string val) {
			vectorNode.y = float.Parse(valY.text);
		}

19 View Source File : FdbTuplePackers.cs
License : MIT License
Project Creator : abdullin

public static float DeserializeSingle(Slice slice)
		{
			if (slice.IsNullOrEmpty) return 0;

			byte type = slice[0];
			switch (type)
			{
				case FdbTupleTypes.Nil:
					{
						return 0;
					}
				case FdbTupleTypes.Utf8:
					{
						return Single.Parse(FdbTupleParser.ParseUnicode(slice), CultureInfo.InvariantCulture);
					}
				case FdbTupleTypes.Single:
					{
						return FdbTupleParser.ParseSingle(slice);
					}
				case FdbTupleTypes.Double:
					{
						return (float)FdbTupleParser.ParseDouble(slice);
					}
			}

			if (type <= FdbTupleTypes.IntPos8 && type >= FdbTupleTypes.IntNeg8)
			{
				return checked((float)DeserializeInt64(slice));
			}

			throw new FormatException(String.Format("Cannot convert tuple segment of type 0x{0:X} into a Single", type));
		}

19 View Source File : ValueMember.cs
License : MIT License
Project Creator : 404Lcc

private static object ParseDefaultValue(Type type, object value)
        {
			if(true)
            {
                Type tmp = Helpers.GetUnderlyingType(type);
                if (tmp != null) type = tmp;
            }
            switch (Helpers.GetTypeCode(type))
            {
                case ProtoTypeCode.Boolean:
                case ProtoTypeCode.Byte:
                case ProtoTypeCode.Char: // char.Parse missing on CF/phone7
                case ProtoTypeCode.DateTime:
                case ProtoTypeCode.Decimal:
                case ProtoTypeCode.Double:
                case ProtoTypeCode.Int16:
                case ProtoTypeCode.Int32:
                case ProtoTypeCode.Int64:
                case ProtoTypeCode.SByte:
                case ProtoTypeCode.Single:
                case ProtoTypeCode.String:
                case ProtoTypeCode.UInt16:
                case ProtoTypeCode.UInt32:
                case ProtoTypeCode.UInt64:
                case ProtoTypeCode.TimeSpan:
                case ProtoTypeCode.Uri:
                case ProtoTypeCode.Guid:
                    {
                        value = value + "";
                    }
                    break;
            }
            if (value is string)
            {
                string s = (string)value;
                if (Helpers.IsEnum(type)) return Helpers.ParseEnum(type, s);

                switch (Helpers.GetTypeCode(type))
                {
                    case ProtoTypeCode.Boolean: return bool.Parse(s);
                    case ProtoTypeCode.Byte: return byte.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Char: // char.Parse missing on CF/phone7
                        if (s.Length == 1) return s[0];
                        throw new FormatException("Single character expected: \"" + s + "\"");
                    case ProtoTypeCode.DateTime: return DateTime.Parse(s, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Decimal: return decimal.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Double: return double.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Int16: return short.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Int32: return int.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Int64: return long.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.SByte: return sbyte.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.Single: return float.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.String: return s;
                    case ProtoTypeCode.UInt16: return ushort.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.UInt32: return uint.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.UInt64: return ulong.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture);
                    case ProtoTypeCode.TimeSpan: return TimeSpan.Parse(s);
                    case ProtoTypeCode.Uri: return s; // Uri is decorated as string
                    case ProtoTypeCode.Guid: return new Guid(s);
                }
            }
#if FEAT_IKVM
            if (Helpers.IsEnum(type)) return value; // return the underlying type instead
            System.Type convertType = null;
            switch(Helpers.GetTypeCode(type))
            {
                case ProtoTypeCode.SByte: convertType = typeof(sbyte); break;
                case ProtoTypeCode.Int16: convertType = typeof(short); break;
                case ProtoTypeCode.Int32: convertType = typeof(int); break;
                case ProtoTypeCode.Int64: convertType = typeof(long); break;
                case ProtoTypeCode.Byte: convertType = typeof(byte); break;
                case ProtoTypeCode.UInt16: convertType = typeof(ushort); break;
                case ProtoTypeCode.UInt32: convertType = typeof(uint); break;
                case ProtoTypeCode.UInt64: convertType = typeof(ulong); break;
                case ProtoTypeCode.Single: convertType = typeof(float); break;
                case ProtoTypeCode.Double: convertType = typeof(double); break;
                case ProtoTypeCode.Decimal: convertType = typeof(decimal); break;
            }
            if(convertType != null) return Convert.ChangeType(value, convertType, CultureInfo.InvariantCulture);
            throw new ArgumentException("Unable to process default value: " + value + ", " + type.FullName);
#else
            if (Helpers.IsEnum(type)) return Enum.ToObject(type, value);
            return Convert.ChangeType(value, type, CultureInfo.InvariantCulture);
#endif
        }

19 View Source File : Half.cs
License : MIT License
Project Creator : 91Act

public static Half Parse(string value, NumberStyles style)
        {
            return (Half)float.Parse(value, style, CultureInfo.InvariantCulture);
        }

19 View Source File : FrmReader.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void PreviousPage() // -
        {
            if (cmboPage.SelectedIndex > 0)
            {
                cmboPage.SelectedIndex = cmboPage.SelectedIndex - 1;
                float currentPage = float.Parse(cmboPage.SelectedItem.ToString());
                float percent = (currentPage / (float)numPagesInCurrentChapter) * 100;
                progress.Value = (int)percent;
            }
        }

19 View Source File : AMFPatches.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

public static bool _OnMonsterSlay_Prefix(BaseEnchantment __instance, string ____displayName, Monster m, GameLocation location, Farmer who)
        {
            if (!(__instance is BaseWeaponEnchantment) || ____displayName == null || !ModEntry.advancedEnchantments.ContainsKey(____displayName) || (ModEntry.EnchantmentTriggers.ContainsKey(who.uniqueMultiplayerID + ____displayName) && ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] == Game1.ticks))
                return true;
            AdvancedEnchantmentData enchantment = ModEntry.advancedEnchantments[____displayName];
            if (enchantment.parameters["trigger"] == "slay")
            {
                context.Monitor.Log($"Triggered enchantment {enchantment.name} on slay");
                ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] = Game1.ticks;
                if (enchantment.type == "heal")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        int heal = Math.Max(1, (int)(m.Health * float.Parse(enchantment.parameters["amountMult"])));
                        who.health = Math.Min(who.maxHealth, Game1.player.health + heal);
                        location.debris.Add(new Debris(heal, new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()), Color.Lime, 1f, who));
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
                else if (enchantment.type == "loot")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        if (enchantment.parameters.ContainsKey("extraDropChecks"))
                        {
                            int extraChecks = Math.Max(1, int.Parse(enchantment.parameters["extraDropChecks"]));
                            for (int i = 0; i < extraChecks; i++)
                            {
                                location.monsterDrop(m, m.GetBoundingBox().Center.X, m.GetBoundingBox().Center.Y, who);
                            }
                        }
                        else if (enchantment.parameters.ContainsKey("extraDropItems"))
                        {
                            string[] items = enchantment.parameters["extraDropItems"].Split(',');
                            foreach (string item in items)
                            {
                                string[] ic = item.Split('_');
                                if (ic.Length == 1)
                                    Game1.createItemDebris(new Object(int.Parse(item), 1, false, -1, 0), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                else if (ic.Length == 2)
                                {
                                    float chance = int.Parse(ic[1]) / 100f;
                                    if (Game1.random.NextDouble() < chance)
                                        Game1.createItemDebris(new Object(int.Parse(ic[0]), 1, false, -1, 0), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                }
                                else if (ic.Length == 4)
                                {
                                    float chance = int.Parse(ic[3]) / 100f;
                                    if (Game1.random.NextDouble() < chance)
                                        Game1.createItemDebris(new Object(int.Parse(ic[0]), Game1.random.Next(int.Parse(ic[1]), int.Parse(ic[2]))), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                }
                            }
                        }
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
                else if (enchantment.type == "coins")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        float mult = float.Parse(enchantment.parameters["amountMult"]);
                        int amount = (int)Math.Round(mult * m.maxHealth);
                        who.Money += amount;
                        if (enchantment.parameters.ContainsKey("sound"))
                            Game1.playSound(enchantment.parameters["sound"]);
                    }
                }
            }
            return false;
        }

19 View Source File : MesoMarketPacket.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

public static PacketWriter LoadMarket()
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.MESO_MARKET);
        pWriter.Write(MesoMarketPacketMode.LoadMarket);
        pWriter.WriteFloat(float.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketTax")));
        pWriter.WriteFloat(float.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketPriceRange")));
        pWriter.WriteLong(long.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketAveragePrice"))); // TODO: Calculate average price
        pWriter.WriteInt(int.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketTotaListingsLimit")));
        pWriter.WriteInt(int.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketDailyListingsLimit")));
        pWriter.WriteInt(int.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketMonthlyPurchaseLimit")));
        pWriter.WriteInt(int.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketListingDayDuration")));
        pWriter.WriteInt(int.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketListingsDisplayCount")));
        pWriter.WriteInt(100); // unk
        pWriter.WriteInt(1000); // unk
        return pWriter;
    }

See More Examples