88 lines
2.3 KiB
C#
88 lines
2.3 KiB
C#
using System;
|
|
using FlaxEngine;
|
|
using Console = Game.Console;
|
|
#if FLAX_EDITOR
|
|
using FlaxEditor;
|
|
#endif
|
|
|
|
namespace Game
|
|
{
|
|
public class ConsolePlugin : GGamePlugin
|
|
{
|
|
public static PluginDescription DescriptionInternal = new PluginDescription
|
|
{
|
|
Author = "Ari Vuollet",
|
|
Name = "Console",
|
|
Description = "Quake-like console",
|
|
Version = Version.Parse("0.1.0"),
|
|
IsAlpha = true,
|
|
Category = "Game"
|
|
};
|
|
|
|
public override void Init()
|
|
{
|
|
//FlaxEngine.Debug.Log("ConsolePlugin initialized");
|
|
Console.Init();
|
|
|
|
AssetManager.Init(); // TODO: move these elsewhere
|
|
|
|
//Level.SceneLoaded += LoadConfig;
|
|
}
|
|
|
|
public override void Deinit()
|
|
{
|
|
//Level.SceneLoaded -= LoadConfig;
|
|
}
|
|
|
|
private void LoadConfig(Scene scene, Guid guid)
|
|
{
|
|
Console.Print("Loading config file");
|
|
AssetManager.Globals.ResetValues();
|
|
|
|
foreach (var line in AssetManager.Config.GetLines())
|
|
Console.Execute(line, false, true);
|
|
}
|
|
}
|
|
|
|
#if FLAX_EDITOR
|
|
public class ConsoleEditorPlugin : GEditorPlugin
|
|
{
|
|
public override Type GamePluginType => typeof(ConsolePlugin);
|
|
|
|
public ConsoleEditorPlugin()
|
|
{
|
|
_description = ConsolePlugin.DescriptionInternal;
|
|
}
|
|
|
|
public override void Init()
|
|
{
|
|
//FlaxEngine.Debug.Log("ConsolePlugin initialized");
|
|
Console.Init();
|
|
|
|
AssetManager.Init();
|
|
|
|
Level.SceneLoaded += LoadConfig;
|
|
|
|
/*AssetManager.Init(); // TODO: move these elsewhere
|
|
AssetManager.Globals.ResetValues();
|
|
|
|
foreach (var line in AssetManager.Config.GetLines())
|
|
Console.Execute(line, false, true);*/
|
|
}
|
|
|
|
public override void Deinit()
|
|
{
|
|
Level.SceneLoaded -= LoadConfig;
|
|
}
|
|
|
|
private void LoadConfig(Scene scene, Guid guid)
|
|
{
|
|
Console.Print("Loading config file");
|
|
AssetManager.Globals.ResetValues();
|
|
|
|
foreach (var line in AssetManager.Config.GetLines())
|
|
Console.Execute(line, false, true);
|
|
}
|
|
}
|
|
#endif
|
|
} |