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(); } }
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); } }
public static bool CharacterCreation_PushedButton(CharacterCreation __instance, ButtonHelper myButton) { bool debug = RogueFramework.IsDebugEnabled(DebugFlags.UnlockMenus); if (__instance.selectedSpace == "Load") { if (debug) { RogueFramework.LogDebug("Redirecting the button push to the original method."); } return(true); } if (debug) { RogueFramework.LogDebug($"Pressing \"{myButton.myText.text}\" ({myButton.scrollingButtonNum}, {myButton.scrollingButtonType}) button."); } string type = myButton.scrollingButtonUnlock.unlockType; List <ButtonData> buttonsData = type == UnlockTypes.Item ? __instance.buttonsDataItems : type == UnlockTypes.Trait ? __instance.buttonsDataTraits : type == UnlockTypes.Ability ? __instance.buttonsDataAbilities : type == UnlockTypes.BigQuest ? __instance.buttonsDataBigQuests : null; ButtonData buttonData = buttonsData[myButton.scrollingButtonNum]; DisplayedUnlock du = (DisplayedUnlock)buttonData.__RogueLibsCustom; try { du.OnPushedButton(); } catch (Exception e) { RogueFramework.LogError(e, "DisplayedUnlock.OnPushedButton", du, du.Menu); } __instance.curSelectedButton = myButton; __instance.curSelectedButtonNum = myButton.scrollingButtonNum; return(false); }
public static bool ScrollingMenu_PushedButton(ScrollingMenu __instance, ButtonHelper myButton) { bool debug = RogueFramework.IsDebugEnabled(DebugFlags.UnlockMenus); if (__instance.menuType.EndsWith("Configs")) { if (debug) { RogueFramework.LogDebug("Redirecting the button push to the original method."); } return(true); } if (debug) { RogueFramework.LogDebug($"Pressing \"{myButton.myText.text}\" ({myButton.scrollingButtonNum}, {myButton.scrollingButtonType}) button."); } ButtonData buttonData = __instance.buttonsData[myButton.scrollingButtonNum]; DisplayedUnlock du = (DisplayedUnlock)buttonData.__RogueLibsCustom; try { du.OnPushedButton(); } catch (Exception e) { RogueFramework.LogError(e, "DisplayedUnlock.OnPushedButton", du, du.Menu); } return(false); }
#pragma warning disable CS0618 // Type or member is obsolete public static void InitializeUnlockWrappers() { GameController gc = GameController.gameController; SessionDataBig sdb = gc.sessionDataBig; foreach (Unlock unlock in sdb.unlocks.ToList()) { // wrapping original unlocks if (string.IsNullOrEmpty(gc.unlocks.GetSpecialUnlockInfo(unlock.unlockName, unlock))) { unlock.cost = -2; if (RogueFramework.IsDebugEnabled(DebugFlags.Unlocks)) { RogueFramework.LogDebug($"\"{unlock.unlockName}\" ({unlock.unlockType}) has special unlock conditions."); } } UnlockWrapper wrapper; if (unlock.unlockType == UnlockTypes.Mutator) { unlock.unavailable = false; wrapper = new MutatorUnlock(unlock); } else if (unlock.unlockType == UnlockTypes.Item) { if (unlock.onlyInCharacterCreation && !unlock.unavailable) { unlock.unavailable = true; } if (!unlock.unavailable && !unlock.onlyInCharacterCreation && !unlock.freeItem) { unlock.onlyInCharacterCreation = unlock.freeItem = true; } wrapper = new ItemUnlock(unlock); } else if (unlock.unlockType == UnlockTypes.Trait) { if (unlock.onlyInCharacterCreation && !unlock.unavailable) { unlock.unavailable = true; } wrapper = new TraitUnlock(unlock); } else if (unlock.unlockType == UnlockTypes.Ability) { if (unlock.onlyInCharacterCreation && !unlock.unavailable) { unlock.unavailable = true; } wrapper = new AbilityUnlock(unlock); } else if (unlock.unlockType == UnlockTypes.Floor) { wrapper = new FloorUnlock(unlock); } else if (unlock.unlockType == UnlockTypes.BigQuest) { wrapper = new BigQuestUnlock(unlock); } else if (unlock.unlockType == UnlockTypes.Extra) { wrapper = new ExtraUnlock(unlock); } else if (unlock.unlockType == UnlockTypes.Agent) { wrapper = new AgentUnlock(unlock) { IsSSA = unlock.unlockName == VanillaAgents.SuperCop || unlock.unlockName == VanillaAgents.UpperCruster || unlock.unlockName == VanillaAgents.Supergoon }; } else if (unlock.unlockType == "Achievement") { wrapper = new AchievementUnlock(unlock); } else if (unlock.unlockType == "HomeBase") { wrapper = new HomeBaseUnlock(unlock); } else if (unlock.unlockType == "Loadout") { wrapper = new LoadoutUnlock(unlock); } else { RogueFramework.LogError($"Unknown unlock type \"{unlock.unlockName}\" ({unlock.unlockType})"); sdb.unlocks.Remove(unlock); continue; } if (wrapper is IUnlockInCC inCC && !inCC.IsAvailableInCC) { inCC.IsAvailableInCC = wrapper.IsAvailable; } RogueFramework.Unlocks.Add(wrapper); AddUnlockFull(wrapper, true); } FixPrerequisites(); foreach (UnlockWrapper wrapper in RogueFramework.CustomUnlocks) { if (RogueFramework.IsDebugEnabled(DebugFlags.Unlocks)) { RogueFramework.LogDebug($"Initializing custom unlock \"{wrapper.Name}\" ({wrapper.Type})."); } RogueFramework.Unlocks.Add(wrapper); AddUnlockFull(wrapper); } }
public static void Updater_Update() { foreach (Agent agent in GameController.gameController.agentList.ToList()) { foreach (IDoUpdate obj in agent.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj); } } InvItem specialAbility = agent.inventory.equippedSpecialAbility; if (specialAbility != null) { foreach (IDoUpdate obj in specialAbility.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj, agent); } } } foreach (InvItem item in agent.inventory.InvItemList.ToList()) { if (item != specialAbility) { foreach (IDoUpdate obj in item.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj, agent); } } } } foreach (StatusEffect effect in agent.statusEffects.StatusEffectList.ToList()) { foreach (IDoUpdate obj in effect.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj, agent); } } } foreach (Trait trait in agent.statusEffects.TraitList.ToList()) { foreach (IDoUpdate obj in trait.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj, agent); } } } } foreach (ObjectReal objectReal in GameController.gameController.objectRealListUpdate.ToList()) { foreach (IDoUpdate obj in objectReal.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj); } } if (objectReal.objectInvDatabase != null) { foreach (InvItem item in objectReal.objectInvDatabase.InvItemList) { foreach (IDoUpdate obj in item.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj, objectReal); } } } } } foreach (Item item in GameController.gameController.itemList.ToList()) { foreach (IDoUpdate obj in item.invItem.GetHooks <IDoUpdate>()) { try { obj.Update(); } catch (Exception e) { RogueFramework.LogError(e, "IDoUpdate.Update", obj, item); } } } }