Ejemplo n.º 1
0
        private static void TrySelectingTransformation(TransformationDefinition def, UIMouseEvent evt, UIElement listeningElement)
        {
            MyPlayer player = Main.LocalPlayer.GetModPlayer <MyPlayer>();

            if (player.PlayerTransformations.ContainsKey(def) && def.MeetsSelectionRequirements(player))
            {
                SoundHelper.PlayVanillaSound(SoundID.MenuTick);

                if (SelectedTransformation != def)
                {
                    SelectedTransformation = def;
                    Main.NewText($"Selected {def.Text}, Mastery: {Math.Round(100f * def.GetPlayerMastery(player), 2)}%");
                }
                else
                {
                    Main.NewText($"{def.Text} Mastery: {Math.Round(100f * def.GetPlayerMastery(player), 2)}%");
                }
            }
            else if (def.SelectionRequirementsFailed.Invoke(player, def))
            {
                SoundHelper.PlayVanillaSound(SoundID.MenuClose);

                if (def.FailureText == null)
                {
                    return;
                }
                Main.NewText(def.FailureText);
            }
        }