Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Reflection;
-
- using IllusionPlugin;
- //using GamecraftModdingAPI;
-
- namespace NScript
- {
- public class NScriptPlugin : IEnhancedPlugin
- {
- public override string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
-
- public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
-
- private string toggleButtonText = "Turn On";
-
- private HarmonyLib.Harmony instance;
-
- private Install.Installer _installer = null;
-
- // called when Gamecraft shuts down
- public override void OnApplicationQuit()
- {
- // Shutdown this mod
- instance?.UnpatchAll(Assembly.GetExecutingAssembly().GetName().FullName);
- GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown");
-
- // Shutdown the Gamecraft modding API last
- GamecraftModdingAPI.Main.Shutdown();
- }
-
- // called when Gamecraft starts up
- public override void OnApplicationStart()
- {
- // Initialize the Gamecraft modding API first
- GamecraftModdingAPI.Main.Init();
- // check out the modding API docs here: https://mod.exmods.org/
- instance = new HarmonyLib.Harmony(Assembly.GetExecutingAssembly().GetName().FullName);
- instance.PatchAll(Assembly.GetExecutingAssembly());
-
- // load external libraries
- _installer = Install.InstallTools.BuildDefaultInstaller();
- _installer.InstallEverything();
- // TODO wait for this later, since these resources are usually only used when in a game
- // (i.e. there's no need to prevent the main menu from loading just to download this stuff)
- _installer.WaitForCompletion();
- if (Filmscript.GeneralBindings.DllExists())
- {
- GamecraftModdingAPI.Utility.Logging.MetaLog($"filmscript.dll {Filmscript.GeneralBindings.Version()}");
- }
- else
- {
- GamecraftModdingAPI.Utility.Logging.MetaLog($"Failed to find filmscript DLL");
- }
-
- // Initialize this mod
- GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new CameraEngine());
-
- GamecraftModdingAPI.Utility.Logging.MetaLog($"{Name} has started up");
- }
-
- public override void OnGUI()
- {
- // toggle custom camera mode
- if (UnityEngine.GUILayout.Button(toggleButtonText))
- {
- // toggle button text indicates what the button will do *next* time it's pressed
- if (CameraPatch.AllowDefaultBehaviour)
- {
- toggleButtonText = "Turn Off"; // custom camera mode is turning on
- }
- else
- {
- toggleButtonText = "Turn On"; // custom camera mode is turning off
- }
-
- CameraPatch.AllowDefaultBehaviour = !CameraPatch.AllowDefaultBehaviour;
- CameraEngine.useDefaultBehaviour = !CameraEngine.useDefaultBehaviour;
- }
-
- if (_installer != null && _installer.CurrentlyInstalling != null)
- {
- UnityEngine.GUILayout.Box($"Downloading {_installer.CurrentlyInstalling}...");
- }
- }
- }
- }
|