Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
ModifierCacheCheatSheet.cs
Go to the documentation of this file.
1 using System.Linq;
2 using CheatSheet;
3 using Loot.Api.Core;
4 
5 namespace Loot.Caching
6 {
7  public sealed partial class ModifierCachePlayer
8  {
9  // This needs to be separate because of CheatSheetInterface static reference
10  // to not freak out JIT
11  private void UpdateCheatSheetCache()
12  {
13  // get cheat sheet slots
14  var curEquips = CheatSheetInterface.GetEnabledExtraAccessories(player).Take(_oldCheatSheetEquips.Length).ToArray();
15 
16  // go over enabled slots
17  for (int i = 0; i < curEquips.Length; i++)
18  {
19  var oldEquip = _oldCheatSheetEquips[i];
20  var newEquip = curEquips[i];
21 
22  // update delegations
23  if (oldEquip != null && newEquip == oldEquip)
24  {
25  continue;
26  }
27 
28  Ready = false;
29 
30  // detach old first
31  if (oldEquip != null && !oldEquip.IsAir)
32  {
33  foreach (Modifier m in LootModItem.GetActivePool(oldEquip))
34  {
35  AddDetachItem(oldEquip, m);
36  }
37  }
38 
39  // attach new
40  if (newEquip != null && !newEquip.IsAir)
41  {
42  foreach (Modifier m in LootModItem.GetActivePool(newEquip))
43  {
44  AddAttachItem(newEquip, m);
45  }
46  }
47 
48  _oldCheatSheetEquips[i] = newEquip;
49  }
50 
51  // current enabled is smaller than total
52  if (curEquips.Length >= _oldCheatSheetEquips.Count(x => x != null))
53  {
54  return;
55  }
56 
57  var outOfDateEquips = _oldCheatSheetEquips.Skip(curEquips.Length);
58  // for all disabled slots but still had a registered item, detach it
59  foreach (var item in outOfDateEquips.Where(x => x != null && !x.IsAir))
60  {
61  Ready = false;
62  foreach (Modifier m in LootModItem.GetActivePool(item))
63  {
64  AddDetachItem(item, m);
65  }
66  }
67  }
68  }
69 }
Defines a modifier, which is an unloaded GlobalItem Making it a GlobalItem gives easy access to all h...
Definition: Modifier.cs:21
Defines an item that may be modified by modifiers from mods
Definition: LootModItem.cs:21
static List< Modifier > GetActivePool(Item item)
Caches the item held and items equipped by players. When equips and held items change, their respective modifiers&#39; effects are automatically called to detach and attach their delegations.