示例#1
0
    public static void SetSkinById(string id)
    {
        ISelectableSkin Skin = GetSkinById(id);

        if (EnemyHPBar.instance.CurrentSkin.GetId() == Skin.GetId())
        {
            return;
        }
        EnemyHPBar.instance.CurrentSkin = Skin;
    }
        /// <summary>
        ///     Add a skin to the skin list provided by an external mod.
        /// </summary>
        /// <param name="NewSkin">an <c>ISelectableSkin</c> that represents the skin</param>
        /// <returns>true if the skin is added</returns>
        public static bool AddSkin(ISelectableSkin NewSkin)
        {
            var Exists = SkinManager.ProvidedSkins.Exists(skin => skin.GetId() == NewSkin.GetId());

            if (!Exists)
            {
                SkinManager.ProvidedSkins.Add(NewSkin);
                BetterMenu.UpdateSkinList();
            }
            return(!Exists);
        }
示例#3
0
    internal static void ApplySkin()
    {
        ISelectableSkin skinToApply = EnemyHPBar.SkinList[selectedSkin];

        BetterMenu.SetSkinById(skinToApply.GetId());
        EnemyHPBar.bossol = EnemyHPBar.instance.HPBarCreateSprite(ResourceLoader.GetBossOutlineImage());
        EnemyHPBar.bossbg = EnemyHPBar.instance.HPBarCreateSprite(ResourceLoader.GetBossBackgroundImage());
        EnemyHPBar.bossfg = EnemyHPBar.instance.HPBarCreateSprite(ResourceLoader.GetBossForegroundImage());
        EnemyHPBar.ol     = EnemyHPBar.instance.HPBarCreateSprite(ResourceLoader.GetOutlineImage());
        EnemyHPBar.fg     = EnemyHPBar.instance.HPBarCreateSprite(ResourceLoader.GetForegroundImage());
        EnemyHPBar.mg     = EnemyHPBar.instance.HPBarCreateSprite(ResourceLoader.GetMiddlegroundImage());
        EnemyHPBar.bg     = EnemyHPBar.instance.HPBarCreateSprite(ResourceLoader.GetBackgroundImage());
    }
        /// <summary>
        ///     Change the current skin, to the one whose id is provided.
        /// </summary>
        /// <param name="id">a <c>string</c> that uniquely identifies the skin</param>
        public static void SetSkinById(string id)
        {
            var Skin = GetSkinById(id);

            CustomKnight.Instance.Log("Trying to apply skin :" + Skin.GetId());
            if (CurrentSkin != null && CurrentSkin.GetId() == Skin.GetId())
            {
                return;
            }
            CurrentSkin = Skin;
            BetterMenu.SelectedSkin(SkinManager.CurrentSkin.GetId());
            // use this when saving so you save to the right settings
            if (GameManager.instance.IsNonGameplayScene())
            {
                CustomKnight.GlobalSettings.DefaultSkin = CurrentSkin.GetId();
            }
            else
            {
                CustomKnight.GlobalSettings.DefaultSkin = CurrentSkin.GetId();
                CustomKnight.SaveSettings.DefaultSkin   = CurrentSkin.GetId();
            };
            RefreshSkin(false);
            OnSetSkin?.Invoke(CustomKnight.Instance, new EventArgs());
        }