Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Pages
/home/travis/build/Jofairden/EvenMoreModifiers/Loot.cs
Go to the documentation of this file.
1 using Loot.UI.Common.Core;
2 using Microsoft.Xna.Framework;
3 using System.Collections.Generic;
4 using System.Runtime.CompilerServices;
5 using log4net;
6 using Loot.Api.Loaders;
7 using Loot.Api.ModContent;
8 using Loot.UI;
9 using Terraria;
10 using Terraria.ModLoader;
11 using Terraria.UI;
12 
13 /*
14  * original version by Hiccup
15  * reworked and maintained by Jofairden
16  * for tModLoader
17  *
18  * (c) Jofairden 2018
19  */
20 
21 [assembly: InternalsVisibleTo("LootTests")] // Allow doing unit tests
22 
23 namespace Loot
24 {
25  public sealed class Loot : Mod
26  {
27  internal new static ILog Logger => ((Mod)Instance)?.Logger;
28  internal static Loot Instance;
29 
30  internal UserInterface GuiInterface;
31  internal GuiTabWindow GuiState;
32 
33  internal static ModContentManager ModContentManager;
34  public static bool IsLoaded;
35 
36  public override void Load()
37  {
38  Instance = this;
39  LoadingFunneler.Load();
40  }
41 
42  public override void PostAddRecipes()
43  {
44  LoadingFunneler.PostLoad();
45  }
46 
47  public override void Unload()
48  {
49  LoadingFunneler.Unload();
50  Instance = null;
51  }
52 
53  public override void PreSaveAndQuit()
54  {
55  if (GuiState.Visible)
56  {
57  GuiState.ToggleUI(GuiInterface);
58  }
59  }
60 
61  private GameTime _lastUpdateUiGameTime;
62 
63  public override void UpdateUI(GameTime gameTime)
64  {
65  _lastUpdateUiGameTime = gameTime;
66  if (GuiInterface?.CurrentState != null)
67  {
68  GuiInterface.Update(gameTime);
69  }
70  }
71 
72  public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
73  {
74  int mouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));
75  if (mouseTextIndex != -1)
76  {
77  layers.Insert(mouseTextIndex, new LegacyGameInterfaceLayer(
78  "Loot: GuiInterface",
79  delegate
80  {
81  if (GuiInterface?.CurrentState is VisibilityUI visibilityUi
82  && visibilityUi.Visible && _lastUpdateUiGameTime != null)
83  {
84  GuiInterface.Draw(Main.spriteBatch, _lastUpdateUiGameTime);
85  }
86  return true;
87  },
88  InterfaceScaleType.UI));
89  }
90  }
91  }
92 }
GameTime _lastUpdateUiGameTime
Definition: Loot.cs:61
This class is responsible for managing instances of TextureModContent for registered mods...
override void Load()
Definition: Loot.cs:36
override void ModifyInterfaceLayers(List< GameInterfaceLayer > layers)
Definition: Loot.cs:72
override void PreSaveAndQuit()
Definition: Loot.cs:53
static bool IsLoaded
Definition: Loot.cs:34
override void UpdateUI(GameTime gameTime)
Definition: Loot.cs:63
override void PostAddRecipes()
Definition: Loot.cs:42
override void Unload()
Definition: Loot.cs:47