forked from FEZModding/FEZUG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFEZUG.cs
98 lines (80 loc) · 2.34 KB
/
FEZUG.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using Common;
using FezEngine.Components;
using FezEngine.Tools;
using FezGame;
using FezGame.Components;
using FezGame.Services;
using FEZUG.Features;
using FEZUG.Features.Console;
using FEZUG.Helpers;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace FEZUG
{
public class Fezug : DrawableGameComponent
{
public static string Version = "v0.1.1";
public List<IFezugFeature> Features { get; private set; }
public static Fezug Instance;
public Fezug(Game game) : base(game)
{
ServiceHelper.InjectServices(this);
Instance = this;
Enabled = true;
Visible = true;
DrawOrder = 99999;
Initialize();
}
public override void Initialize()
{
base.Initialize();
DrawingTools.Init();
Features = new List<IFezugFeature>();
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.IsClass && typeof(IFezugFeature).IsAssignableFrom(t)))
{
IFezugFeature feature = (IFezugFeature)Activator.CreateInstance(type);
ServiceHelper.InjectServices(feature);
Features.Add(feature);
}
foreach (var feature in Features)
{
feature.Initialize();
}
}
public static IFezugFeature GetFeature<T>()
{
return GetFeature(typeof(T));
}
public static IFezugFeature GetFeature(Type type)
{
foreach (var feature in Instance.Features)
{
if (feature.GetType() == type) return feature;
}
return null;
}
public override void Update(GameTime gameTime)
{
InputHelper.Update(gameTime);
foreach (var feature in Features)
{
feature.Update(gameTime);
}
}
public override void Draw(GameTime gameTime)
{
DrawingTools.BeginBatch();
foreach(var feature in Features)
{
feature.Draw(gameTime);
}
DrawingTools.EndBatch();
}
}
}