Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
PercentDefenseBonus.cs
Go to the documentation of this file.
1 using System;
2 using Loot.Api.Attributes;
3 using Loot.Api.Core;
4 using Loot.Api.Delegators;
5 using Loot.Modifiers.Base;
6 using Terraria;
7 
8 namespace Loot.Modifiers.EquipModifiers.Defensive
9 {
11  {
12  public float PercentDefBoost;
13 
14  public override void ResetEffects()
15  {
16  PercentDefBoost = 0f;
17  }
18 
19  [AutoDelegation("OnPostUpdateEquips")]
21  private void DefBoost()
22  {
23  player.statDefense = (int) Math.Ceiling(player.statDefense * (1 + PercentDefBoost));
24  }
25  }
26 
27  [UsesEffect(typeof(PercentDefBoostEffect))]
29  {
31  {
32  return base.GetTooltip()
33  .WithPositive($"+{Properties.RoundedPower}% defense");
34  }
35 
37  {
38  return base.GetModifierProperties(item)
39  .WithMaxMagnitude(10f);
40  }
41 
42  public override void UpdateEquip(Item item, Player player)
43  {
44  ModifierDelegatorPlayer.GetPlayer(player).GetEffect<PercentDefBoostEffect>().PercentDefBoost += Properties.RoundedPower / 100f;
45  }
46  }
47 }
The ModifierPropertiesBuilder implements the builder pattern for ModifierProperties It provides a str...
This attribute may be used to skip usage of AttachDelegations and DetachDelegations Which is a cumber...
A ModifierEffect signifies the effect of a modifier on a player It should house the implementation...
Defines a modifier that can roll on an equip item (armor or accessory) These modifiers will have 60% ...
DelegationPrioritization
Specify when you want your delegation to happen in the chain
static ModifierDelegatorPlayer GetPlayer(Player player)
Defines the properties of a modifier
override void ResetEffects()
Automatically called when the ModPlayer does its ResetEffects Also automatically called when the dele...
Defines a tooltip line of a modifier A modifier can have multiple lines
override ModifierProperties.ModifierPropertiesBuilder GetModifierProperties(Item item)
Holds player-entity data and handles it
override ModifierTooltipLine.ModifierTooltipBuilder GetTooltip()