Skip to content

Commit 6cb3683

Browse files
Added redirect extension methods for slot modifications
1 parent 0db1cdf commit 6cb3683

2 files changed

Lines changed: 187 additions & 1 deletion

File tree

InscryptionAPI/Rulebook/RuleBookRedirectExtensions.cs

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using InscryptionAPI.Boons;
33
using InscryptionAPI.Card;
44
using InscryptionAPI.Items;
5+
using InscryptionAPI.Slots;
56
using UnityEngine;
67
using static InscryptionAPI.RuleBook.RuleBookManager;
78

@@ -35,6 +36,11 @@ public static AbilityManager.FullAbility SetUniqueRedirect(this AbilityManager.F
3536
fullAbility.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Unique, redirectColour, uniqueRedirect);
3637
return fullAbility;
3738
}
39+
public static AbilityManager.FullAbility SetSlotRedirect(this AbilityManager.FullAbility fullAbility, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
40+
{
41+
fullAbility.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Items, redirectColour, SlotModificationManager.SLOT_PAGEID + slotMod.ToString());
42+
return fullAbility;
43+
}
3844

3945
public static AbilityInfo SetAbilityRedirect(this AbilityInfo info, string clickableText, Ability abilityRedirect, Color redirectColour)
4046
{
@@ -96,6 +102,18 @@ public static AbilityInfo SetUniqueRedirect(this AbilityInfo info, string clicka
96102
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the AbilityInfo hasn't been added to the API yet.");
97103
return info;
98104
}
105+
public static AbilityInfo SetSlotRedirect(this AbilityInfo info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
106+
{
107+
AbilityManager.FullAbility full = AbilityManager.BaseGameAbilities.Concat(AbilityManager.NewAbilities).First(x => x.Info.ability == info.ability);
108+
if (full != null)
109+
{
110+
full.SetSlotRedirect(clickableText, slotMod, redirectColour);
111+
return info;
112+
}
113+
114+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the AbilityInfo hasn't been added to the API yet.");
115+
return info;
116+
}
99117
#endregion
100118

101119
#region StatIconInfo
@@ -124,6 +142,11 @@ public static StatIconManager.FullStatIcon SetUniqueRedirect(this StatIconManage
124142
fullIcon.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Unique, redirectColour, uniqueRedirect);
125143
return fullIcon;
126144
}
145+
public static StatIconManager.FullStatIcon SetSlotRedirect(this StatIconManager.FullStatIcon fullIcon, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
146+
{
147+
fullIcon.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Items, redirectColour, SlotModificationManager.SLOT_PAGEID + slotMod.ToString());
148+
return fullIcon;
149+
}
127150

128151
public static StatIconInfo SetAbilityRedirect(this StatIconInfo info, string clickableText, Ability abilityRedirect, Color redirectColour)
129152
{
@@ -185,6 +208,18 @@ public static StatIconInfo SetUniqueRedirect(this StatIconInfo info, string clic
185208
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the StatIconInfo hasn't been added to the API yet.");
186209
return info;
187210
}
211+
public static StatIconInfo SetSlotRedirect(this StatIconInfo info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
212+
{
213+
StatIconManager.FullStatIcon full = StatIconManager.AllStatIcons.Find(x => x.Id == info.iconType);
214+
if (full != null)
215+
{
216+
full.SetSlotRedirect(clickableText, slotMod, redirectColour);
217+
return info;
218+
}
219+
220+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the StatIconInfo hasn't been added to the API yet.");
221+
return info;
222+
}
188223
#endregion
189224

190225
#region BoonData
@@ -213,6 +248,11 @@ public static BoonManager.FullBoon SetUniqueRedirect(this BoonManager.FullBoon f
213248
fullBoon.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Unique, redirectColour, uniqueRedirect);
214249
return fullBoon;
215250
}
251+
public static BoonManager.FullBoon SetSlotRedirect(this BoonManager.FullBoon fullBoon, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
252+
{
253+
fullBoon.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Items, redirectColour, SlotModificationManager.SLOT_PAGEID + slotMod.ToString());
254+
return fullBoon;
255+
}
216256

217257
public static BoonData SetAbilityRedirect(this BoonData info, string clickableText, Ability abilityRedirect, Color redirectColour)
218258
{
@@ -274,6 +314,18 @@ public static BoonData SetUniqueRedirect(this BoonData info, string clickableTex
274314
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the BoonData hasn't been added to the API yet.");
275315
return info;
276316
}
317+
public static BoonData SetSlotRedirect(this BoonData info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
318+
{
319+
BoonManager.FullBoon full = BoonManager.AllFullBoons.Find(x => x.boon.type == info.type);
320+
if (full != null)
321+
{
322+
full.SetSlotRedirect(clickableText, slotMod, redirectColour);
323+
return info;
324+
}
325+
326+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the BoonData hasn't been added to the API yet.");
327+
return info;
328+
}
277329
#endregion
278330

279331
#region ConsumableItemData
@@ -302,6 +354,11 @@ public static ConsumableItemManager.FullConsumableItemData SetUniqueRedirect(thi
302354
fullItem.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Unique, redirectColour, uniqueRedirect);
303355
return fullItem;
304356
}
357+
public static ConsumableItemManager.FullConsumableItemData SetSlotRedirect(this ConsumableItemManager.FullConsumableItemData fullItem, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
358+
{
359+
fullItem.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Items, redirectColour, SlotModificationManager.SLOT_PAGEID + slotMod.ToString());
360+
return fullItem;
361+
}
305362

306363
public static ConsumableItemData SetAbilityRedirect(this ConsumableItemData info, string clickableText, Ability abilityRedirect, Color redirectColour)
307364
{
@@ -363,6 +420,124 @@ public static ConsumableItemData SetUniqueRedirect(this ConsumableItemData info,
363420
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the ConsumableItemData hasn't been added to the API yet.");
364421
return info;
365422
}
423+
public static ConsumableItemData SetSlotRedirect(this ConsumableItemData info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
424+
{
425+
ConsumableItemManager.FullConsumableItemData full = ConsumableItemManager.allFullItemDatas.Find(x => x.itemData == info);
426+
if (full != null)
427+
{
428+
full.SetSlotRedirect(clickableText, slotMod, redirectColour);
429+
return info;
430+
}
431+
432+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the ConsumableItemData hasn't been added to the API yet.");
433+
return info;
434+
}
435+
#endregion
436+
437+
#region SlotMod
438+
public static SlotModificationManager.Info SetAbilityRedirect(this SlotModificationManager.Info slotInfo, string clickableText, Ability abilityRedirect, Color redirectColour)
439+
{
440+
slotInfo.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Abilities, redirectColour, abilityRedirect.ToString());
441+
return slotInfo;
442+
}
443+
public static SlotModificationManager.Info SetStatIconRedirect(this SlotModificationManager.Info slotInfo, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour)
444+
{
445+
slotInfo.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.StatIcons, redirectColour, statIconRedirect.ToString());
446+
return slotInfo;
447+
}
448+
public static SlotModificationManager.Info SetBoonRedirect(this SlotModificationManager.Info slotInfo, string clickableText, BoonData.Type boonRedirect, Color redirectColour)
449+
{
450+
slotInfo.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Boons, redirectColour, boonRedirect.ToString());
451+
return slotInfo;
452+
}
453+
public static SlotModificationManager.Info SetItemRedirect(this SlotModificationManager.Info slotInfo, string clickableText, string itemNameRedirect, Color redirectColour)
454+
{
455+
slotInfo.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Items, redirectColour, itemNameRedirect);
456+
return slotInfo;
457+
}
458+
public static SlotModificationManager.Info SetUniqueRedirect(this SlotModificationManager.Info slotInfo, string clickableText, string uniqueRedirect, Color redirectColour)
459+
{
460+
slotInfo.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Unique, redirectColour, uniqueRedirect);
461+
return slotInfo;
462+
}
463+
public static SlotModificationManager.Info SetSlotRedirect(this SlotModificationManager.Info slotInfo, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
464+
{
465+
slotInfo.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Items, redirectColour, SlotModificationManager.SLOT_PAGEID + slotMod.ToString());
466+
return slotInfo;
467+
}
468+
469+
public static SlotModificationManager.ModificationType SetAbilityRedirect(this SlotModificationManager.ModificationType info, string clickableText, Ability abilityRedirect, Color redirectColour)
470+
{
471+
SlotModificationManager.Info full = SlotModificationManager.AllSlotModifications.InfoByID(info);
472+
if (full != null)
473+
{
474+
full.SetAbilityRedirect(clickableText, abilityRedirect, redirectColour);
475+
return info;
476+
}
477+
478+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the SlotModificationManager.ModificationType hasn't been added to the API yet.");
479+
return info;
480+
}
481+
public static SlotModificationManager.ModificationType SetStatIconRedirect(this SlotModificationManager.ModificationType info, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour)
482+
{
483+
SlotModificationManager.Info full = SlotModificationManager.AllSlotModifications.InfoByID(info);
484+
if (full != null)
485+
{
486+
full.SetStatIconRedirect(clickableText, statIconRedirect, redirectColour);
487+
return info;
488+
}
489+
490+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the SlotModificationManager.ModificationType hasn't been added to the API yet.");
491+
return info;
492+
}
493+
public static SlotModificationManager.ModificationType SetBoonRedirect(this SlotModificationManager.ModificationType info, string clickableText, BoonData.Type boonRedirect, Color redirectColour)
494+
{
495+
SlotModificationManager.Info full = SlotModificationManager.AllSlotModifications.InfoByID(info);
496+
if (full != null)
497+
{
498+
full.SetBoonRedirect(clickableText, boonRedirect, redirectColour);
499+
return info;
500+
}
501+
502+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the ConsumableItemData hasn't been added to the API yet.");
503+
return info;
504+
}
505+
public static SlotModificationManager.ModificationType SetItemRedirect(this SlotModificationManager.ModificationType info, string clickableText, string itemNameRedirect, Color redirectColour)
506+
{
507+
SlotModificationManager.Info full = SlotModificationManager.AllSlotModifications.InfoByID(info);
508+
if (full != null)
509+
{
510+
full.SetItemRedirect(clickableText, itemNameRedirect, redirectColour);
511+
return info;
512+
}
513+
514+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the SlotModificationManager.ModificationType hasn't been added to the API yet.");
515+
return info;
516+
}
517+
public static SlotModificationManager.ModificationType SetUniqueRedirect(this SlotModificationManager.ModificationType info, string clickableText, string uniqueRedirect, Color redirectColour)
518+
{
519+
SlotModificationManager.Info full = SlotModificationManager.AllSlotModifications.InfoByID(info);
520+
if (full != null)
521+
{
522+
full.SetUniqueRedirect(clickableText, uniqueRedirect, redirectColour);
523+
return info;
524+
}
525+
526+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the SlotModificationManager.ModificationType hasn't been added to the API yet.");
527+
return info;
528+
}
529+
public static SlotModificationManager.ModificationType SetSlotRedirect(this SlotModificationManager.ModificationType info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
530+
{
531+
SlotModificationManager.Info full = SlotModificationManager.AllSlotModifications.InfoByID(info);
532+
if (full != null)
533+
{
534+
full.SetSlotRedirect(clickableText, slotMod, redirectColour);
535+
return info;
536+
}
537+
538+
InscryptionAPIPlugin.Logger.LogError($"Can't set rulebook redirect for {clickableText} because the SlotModificationManager.ModificationType hasn't been added to the API yet.");
539+
return info;
540+
}
366541
#endregion
367542

368543
#region RuleBookPageInfo
@@ -421,5 +596,16 @@ public static RuleBookPageInfo SetUniqueRedirect(this RuleBookPageInfo pageInfo,
421596
ext.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Unique, redirectColour, uniqueRedirect);
422597
return pageInfo;
423598
}
599+
public static RuleBookPageInfo SetSlotRedirect(this RuleBookPageInfo pageInfo, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour)
600+
{
601+
RuleBookPageInfoExt ext = CustomRedirectPages.Find(x => x.parentPageInfo == pageInfo);
602+
if (ext == null)
603+
{
604+
ext = new(pageInfo, new());
605+
CustomRedirectPages.Add(ext);
606+
}
607+
ext.RulebookDescriptionRedirects[clickableText] = new(PageRangeType.Items, redirectColour, SlotModificationManager.SLOT_PAGEID + slotMod.ToString());
608+
return pageInfo;
609+
}
424610
#endregion
425611
}

docs/wiki/redirect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ info.SetAbilityRedirect("Stinky", Ability.DebuffEnemy, GameColors.Instance.orang
2222

2323
Now when you open the page for Made of Stone, the word 'Stinky' will be orange and redirect you to Stinky's page, and the words 'Touch of Death' will be red and redirect you to Touch of Death's page.
2424

25-
Redirects can be also be set for stat icons, items, and boons:
25+
Redirects can be also be set for stat icons, items, boons, and slot modifications:
2626

2727
```c#
2828
AbilityInfo info = AbilitiesUtil.GetInfo(Ability.MadeOfStone);

0 commit comments

Comments
 (0)