Example #1
0
        public static void StatusEffects_PressedSpecialAbility(StatusEffects __instance)
        {
            CustomAbility custom = __instance.agent.GetAbility();

            if (custom is null)
            {
                return;
            }
            if (custom.Item.invItemName != __instance.agent.specialAbility)
            {
                return;
            }

            if (RogueFramework.IsDebugEnabled(DebugFlags.Abilities))
            {
                RogueFramework.LogDebug($"Pressing ability ability {custom} ({__instance.agent.specialAbility}, {__instance.agent.agentName}).");
            }

            try { custom.OnPressed(); }
            catch (Exception e) { RogueFramework.LogError(e, "CustomAbility.OnPressed", custom, __instance.agent); }
            if (custom.Count > 0)
            {
                __instance.agent.inventory.buffDisplay.specialAbilitySlot.MakeNotUsable();
            }
        }
Example #2
0
        /// <summary>
        ///   <para>Creates a new <see cref="CustomAbility"/> with the specified <paramref name="id"/>, <paramref name="sprite"/>, <paramref name="name"/> and <paramref name="description"/>.</para>
        /// </summary>
        public static CustomAbility CreateCustomAbility(string id, Sprite sprite, bool unlockedFromStart, CustomNameInfo name, CustomNameInfo description, Action <InvItem> setupDetails)
        {
            CustomAbility customAbility = GetCustomAbility(id);

            if (customAbility != null)
            {
                string message = string.Concat("A CustomAbility with Id \"", id, "\" already exists!");
                Logger.LogError(message);
                throw new ArgumentException(message, nameof(id));
            }
            CustomAbilities.Add(customAbility = new CustomAbility(id,
                                                                  CreateCustomName(id, "Item", name),
                                                                  CreateCustomName(id, "Description", description)
                                                                  ));
            customAbility.Unlocked     = unlockedFromStart;
            customAbility.Sprite       = sprite;
            customAbility.SetupDetails = setupDetails;
            sprite.name = id;

            PluginInstance.Setup(customAbility);

            Logger.LogDebug(string.Concat("A CustomAbility with Id \"", id, "\" was created."));

            return(customAbility);
        }
Example #3
0
        public static void StatusEffects_GiveSpecialAbility(StatusEffects __instance)
        {
            if (GameController.gameController.levelType == "HomeBase" &&
                !__instance.agent.isDummy && __instance.agent.agentName != VanillaAgents.MechEmpty)
            {
                return;
            }
            CustomAbility custom = __instance.agent.GetAbility();

            if (custom is null)
            {
                return;
            }

            if (RogueFramework.IsDebugEnabled(DebugFlags.Abilities))
            {
                RogueFramework.LogDebug($"Giving ability {custom} ({__instance.agent.specialAbility}, {__instance.agent.agentName}).");
            }

            try { custom.OnAdded(); }
            catch (Exception e) { RogueFramework.LogError(e, "CustomAbility.OnAdded", custom, __instance.agent); }

            if (custom is IAbilityTargetable)
            {
                __instance.SpecialAbilityInterfaceCheck();
            }
            if (custom is IAbilityRechargeable)
            {
                __instance.RechargeSpecialAbility(custom.ItemInfo.Name);
            }
        }
Example #4
0
        protected static void StatusEffects_ReleasedSpecialAbility(StatusEffects __instance)
        {
            if (__instance.agent.ghost || __instance.agent.teleporting)
            {
                return;
            }

            CustomAbility ability = RogueLibs.GetAbility(__instance.agent.specialAbility);

            ability?.OnReleased?.Invoke(__instance.agent?.inventory?.equippedSpecialAbility, __instance.agent);
        }
Example #5
0
        public static void StatusEffects_HeldSpecialAbility(StatusEffects __instance)
        {
            CustomAbility custom = __instance.agent.GetAbility();

            if (!(custom is IAbilityChargeable chargeable))
            {
                return;
            }
            if (custom.Item.invItemName != __instance.agent.specialAbility)
            {
                return;
            }

            ref float held     = ref GameController.gameController.playerControl.pressedSpecialAbilityTime[__instance.agent.isPlayer - 1];
Example #6
0
        protected static IEnumerator StatusEffects_RechargeSpecialAbility2(IEnumerator iEnumerator, StatusEffects __instance)
        {
            while (iEnumerator.MoveNext())
            {
                CustomAbility ability = RogueLibs.GetAbility(__instance.agent?.specialAbility);
                if (ability == null)
                {
                    yield return(iEnumerator.Current);
                }
                else
                {
                    yield return(ability.RechargeInterval?.Invoke(__instance.agent?.inventory?.equippedSpecialAbility, __instance.agent));

                    ability.Recharge?.Invoke(__instance.agent?.inventory?.equippedSpecialAbility, __instance.agent);
                }
            }
        }
Example #7
0
 protected static IEnumerator StatusEffects_SpecialAbilityInterfaceCheck2(IEnumerator iEnumerator, StatusEffects __instance)
 {
     while (iEnumerator.MoveNext())
     {
         CustomAbility ability = RogueLibs.GetAbility(__instance.agent?.specialAbility);
         if (ability?.IndicatorCheck != null)
         {
             PlayfieldObject res = ability.IndicatorCheck.Invoke(__instance.agent?.inventory?.equippedSpecialAbility, __instance.agent);
             if (res == null)
             {
                 __instance.agent.specialAbilityIndicator.Revert();
             }
             else
             {
                 __instance.agent.specialAbilityIndicator.ShowIndicator(res, __instance.agent?.specialAbility);
             }
         }
         yield return(iEnumerator.Current);
     }
 }
Example #8
0
        protected static void StatusEffects_GiveSpecialAbility(StatusEffects __instance, string abilityName)
        {
            if (GameController.gameController.levelType == "HomeBase" && !__instance.agent.isDummy)
            {
                return;
            }
            if (__instance.agent.name == "DummyAgent" || __instance.agent.name.Contains("BackupAgent"))
            {
                return;
            }

            CustomAbility ability = RogueLibs.GetAbility(__instance.agent.inventory.equippedSpecialAbility.invItemName);

            if (ability?.IndicatorCheck != null)
            {
                __instance.SpecialAbilityInterfaceCheck();
            }
            if (ability?.Recharge != null)
            {
                __instance.RechargeSpecialAbility(abilityName);
            }
        }
Example #9
0
        protected static void SpecialAbilityIndicator_ShowIndicator(SpecialAbilityIndicator __instance, string specialAbilityType)
        {
            CustomAbility ability = RogueLibs.GetAbility(specialAbilityType);

            __instance.image.sprite = ability.Sprite;
        }