Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
ModifierEffectContent.cs
Go to the documentation of this file.
1 using System;
2 using System.Linq;
3 using System.Reflection;
4 using Loot.Api.Attributes;
5 using Loot.Api.Content;
6 using Loot.Api.Core;
7 
8 namespace Loot.Content
9 {
13  public sealed class ModifierEffectContent : LoadableContentBase<ModifierEffect>
14  {
15  internal override void Load()
16  {
17  AddContent(NullModifierEffect.INSTANCE, Loot.Instance);
18  }
19 
20  internal override bool CheckContentPiece(ModifierEffect contentPiece)
21  {
22  //verbose GetCustomAttributes call
23  //because we call the constructor, it will throw our
24  //validation exceptions on load instead on entering world
25  var attributes = contentPiece
26  .GetType()
27  .GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
28  .Select(x => x.GetCustomAttributes(false).OfType<DelegationPrioritizationAttribute>());
29 
30  foreach (var attribute in attributes.SelectMany(x => x))
31  {
32  Activator.CreateInstance(attribute.GetType(), attribute.DelegationPrioritization, attribute.DelegationLevel);
33  }
34 
35  // If we reached this point, all was fine.
36  return true;
37  }
38  }
39 }
This class holds all loaded ModifierEffect content
static NullModifierEffect INSTANCE
A ModifierEffect signifies the effect of a modifier on a player It should house the implementation...
This class is used for Content holders in the Content namespace As a modder you should not use this c...
Defines a "Null" effect which represents no effect safely Cannot be rolled normally ...
This attribute is used to set a custom prioritization for a delegation It allows you to customize at ...