Program.cs for Terraria Light Mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using Terraria; | |
using ReLogic.Peripherals.RGB; | |
using Terraria.Initializers; | |
namespace TerrariaLeds | |
{ | |
class Program | |
{ | |
private static MyRgbDevice device = new MyRgbDevice(); | |
private static void RegisterOurDevice() | |
{ | |
var engine = (ChromaEngine)typeof(ChromaInitializer).GetField("_engine", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); | |
engine.AddDeviceGroup("LedStrip", new VirtualRgbDeviceGroup(device)); | |
engine.EnableDeviceGroup("LedStrip"); | |
} | |
public static void Main(string[] args) | |
{ | |
AppDomain.CurrentDomain.AssemblyLoad += (sender, sargs) => | |
{ | |
if (sargs.LoadedAssembly.GetName().Name == "Newtonsoft.Json") | |
Terraria.Main.OnEngineLoad += RegisterOurDevice; | |
}; | |
// Invoke Terraria's Main for Windows-based systems. | |
typeof(WindowsLaunch).GetMethod("Main", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { args }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment