Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
PoorCube.cs
Go to the documentation of this file.
1 using Loot.Api.Cubes;
2 using Loot.Api.Ext;
3 using Loot.Api.Strategy;
4 using Loot.Pools;
5 using Loot.Rarities;
6 using Microsoft.Xna.Framework;
7 using Terraria;
8 using Terraria.ModLoader;
9 
10 namespace Loot.Cubes
11 {
12  public class PoorCube : RerollingCube
13  {
14  public override int EssenceCraftCost => 10;
15  protected override string CubeName => "Poor Cube";
16  protected override Color? OverrideNameColor => Color.White;
17 
18  protected override TooltipLine ExtraTooltip => new TooltipLine(mod, "PoorCube::Description::Add_Box",
19  "Maximum lines: 2" +
20  "\nMaximum potential: Rare" +
21  "\nAlways rolls from random modifiers")
22  {
23  overrideColor = OverrideNameColor
24  };
25 
26  protected override void SafeDefaults()
27  {
28  item.value = Item.buyPrice(copper: 1);
29  }
30 
31  protected override void SafeStaticDefaults()
32  {
33  }
34 
35  public override RollingStrategy GetRollingStrategy(Item item, RollingStrategyProperties properties)
36  {
37  var currentRarity = LootModItem.GetInfo(item).Rarity;
38  bool isLegendary = currentRarity?.GetType() == typeof(LegendaryRarity);
39  bool isEpic = currentRarity?.GetType() == typeof(EpicRarity);
40  bool forcedDowngrade = currentRarity != null && isLegendary || isEpic;
41  if (forcedDowngrade)
42  {
43  properties.CanUpgradeRarity = ctx => false;
44  properties.ForceModifierRarity = mod.GetModifierRarity<RareRarity>();
45  }
46 
47  properties.MaxRollableLines = 2;
48  properties.ForceModifierPool = mod.GetModifierPool<AllModifiersPool>();
49  if (!forcedDowngrade)
50  {
51  properties.CanUpgradeRarity = ctx => ctx.Rarity.GetType() == typeof(CommonRarity);
52  }
54  }
55  }
56 }
Defines a set of rolling utilities
Definition: RollingUtils.cs:9
int MaxRollableLines
The maximum amount of modifiers that can roll
The legendary rarity, before transcendent but after epic
The epic rarity, before legendary but after rare
Definition: EpicRarity.cs:10
Defines properties that will be used when an item is being rolled in a IRollingStrategy<T> These can ...
A modifier pool that always consists of all modifiers Cannot be rolled normally
ModifierPool ForceModifierPool
Force a specific pool to roll Note that OverrideRollModifierPool will override this property ...
Defines an item that may be modified by modifiers from mods
Definition: LootModItem.cs:21
override void SafeStaticDefaults()
Definition: PoorCube.cs:31
static DefaultRollingStrategy Default
Definition: RollingUtils.cs:23
static LootModItem GetInfo(Item item)
Describes the common rarity, which every item starts with
Definition: CommonRarity.cs:10
ModifierRarity Rarity
Definition: LootModItem.cs:31
The rare rarity, before epic but after common
Definition: RareRarity.cs:10
override void SafeDefaults()
Definition: PoorCube.cs:26
override RollingStrategy GetRollingStrategy(Item item, RollingStrategyProperties properties)
Definition: PoorCube.cs:35
Defines a rerolling cube that opens the rerolling UI on right click The method M:GetRollingStrategy c...