Exemplo n.º 1
0
 public ModFileOutput(IOwmlConfig config, IModLogger logger, IModManifest manifest) : base(config, logger, manifest)
 {
     if (_writer == null)
     {
         _writer = File.Open(config.OutputFilePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
     }
 }
Exemplo n.º 2
0
 internal ModInputCombination(IModManifest manifest, IModConsole console, string name, string combination)
 {
     _manifest = manifest;
     _console  = console;
     Name      = name;
     _hashes   = StringToHashes(combination);
 }
Exemplo n.º 3
0
 public void OnOWMLLog(IModManifest man, string message)
 {
     if (!message.Contains("Unity log message:"))
     {
         instance.PostMessage(message, man.Name, ChatHandler.MsgType.LOG);
     }
 }
Exemplo n.º 4
0
        private IModData GetModData(IModManifest manifest)
        {
            var storage       = new ModStorage(manifest);
            var config        = storage.Load <ModConfig>("config.json");
            var defaultConfig = storage.Load <ModConfig>("default-config.json");

            if (config == null && defaultConfig == null)
            {
                config        = new ModConfig();
                defaultConfig = new ModConfig();
            }
            else if (defaultConfig != null && config == null)
            {
                config = defaultConfig;
            }
            else if (defaultConfig != null)
            {
                foreach (var setting in defaultConfig.Settings)
                {
                    if (!config.Settings.ContainsKey(setting.Key))
                    {
                        config.Settings.Add(setting.Key, setting.Value);
                    }
                }
            }
            storage.Save(config, "config.json");
            return(new ModData(manifest, config, defaultConfig));
        }
Exemplo n.º 5
0
 /// <summary>Construct an instance.</summary>
 /// <param name="list">The list of loaded mods.</param>
 /// <param name="proxyFactory">The proxy factory instance.</param>
 /// <param name="manifest">The manifest of the mod this instance is attached to.</param>
 public ModInteraction(IList <IModBehaviour> list, InterfaceProxyFactory proxyFactory, IModManifest manifest)
 {
     _modList      = list;
     _modManifest  = manifest;
     _proxyFactory = proxyFactory;
     RegenerateDictionaries();
 }
Exemplo n.º 6
0
 public ModSocketOutput(IOwmlConfig config, IModLogger logger, IModManifest manifest) : base(config, logger, manifest)
 {
     if (_socket == null)
     {
         CreateSocket();
     }
 }
Exemplo n.º 7
0
        private bool IsMadeForSameOwmlMajorVersion(IModManifest manifest)
        {
            var owmlVersionSplit = _owmlManifest.Version.Split('.');
            var modVersionSplit  = manifest.OWMLVersion.Split('.');

            return(owmlVersionSplit.Length == modVersionSplit.Length &&
                   owmlVersionSplit[0] == modVersionSplit[0] &&
                   owmlVersionSplit[1] == modVersionSplit[1]);
        }
Exemplo n.º 8
0
        protected ModConsole(IOwmlConfig config, IModLogger logger, IModManifest manifest)
        {
            Logger     = logger;
            Manifest   = manifest;
            OwmlConfig = config;

            if (manifest.Name == "OWML")
            {
                Instance = this;
            }
        }
Exemplo n.º 9
0
 public App(IOwmlConfig owmlConfig, IModManifest owmlManifest, IModConsole writer, IModFinder modFinder,
            OutputListener listener, PathFinder pathFinder, OWPatcher owPatcher, VRPatcher vrPatcher)
 {
     _owmlConfig   = owmlConfig;
     _owmlManifest = owmlManifest;
     _writer       = writer;
     _modFinder    = modFinder;
     _listener     = listener;
     _pathFinder   = pathFinder;
     _owPatcher    = owPatcher;
     _vrPatcher    = vrPatcher;
 }
Exemplo n.º 10
0
 public ModLogger(IOwmlConfig config, IModManifest manifest)
 {
     if (manifest.Name == "OWML")
     {
         Instance = this;
     }
     if (_config == null)
     {
         _config = config;
     }
     _manifest = manifest;
 }
Exemplo n.º 11
0
 public ModHelper(IModLogger logger, IModConsole console, IHarmonyHelper harmonyHelper, IModEvents events,
                  IModAssets assets, IModStorage storage, IModMenus menus, IModManifest manifest, IModConfig config, IOwmlConfig owmlConfig, IModInteraction interaction)
 {
     Logger        = logger;
     Console       = console;
     HarmonyHelper = harmonyHelper;
     Events        = events;
     Assets        = assets;
     Storage       = storage;
     Menus         = menus;
     Manifest      = manifest;
     Config        = config;
     OwmlConfig    = owmlConfig;
     Interaction   = interaction;
 }
Exemplo n.º 12
0
        public ModMenus(IModConsole console, IModEvents events, IModInputHandler inputHandler,
                        IModManifest owmlManifest, IOwmlConfig owmlConfig, IOwmlConfig owmlDefaultConfig)
        {
            MainMenu  = new ModMainMenu(console);
            PauseMenu = new ModPauseMenu(console);
            ModsMenu  = new ModsMenu(console, this, inputHandler);
            OwmlMenu  = new OwmlConfigMenu(console, owmlManifest, owmlConfig, owmlDefaultConfig);
            InputMenu = new ModInputMenu(console);
            InputCombinationElementMenu = new ModInputCombinationElementMenu(console, inputHandler);
            InputCombinationMenu        = new ModInputCombinationMenu(console);

            events.Subscribe <SettingsManager>(Common.Events.AfterStart);
            events.Subscribe <TitleScreenManager>(Common.Events.AfterStart);
            events.OnEvent += OnEvent;
        }
Exemplo n.º 13
0
        private void LoadMod(IModManifest manifest)
        {
            var modType = LoadModType(manifest);

            if (modType == null)
            {
                _helper.Logger.Log("Mod type is null, skipping");
                return;
            }
            _helper.Logger.Log($"Loading {manifest.UniqueName} ({manifest.Version})...");
            _helper.Logger.Log("Adding mod behaviour...");
            var go  = new GameObject(manifest.UniqueName);
            var mod = (ModBehaviour)go.AddComponent(modType);

            _helper.Logger.Log("Added! Initializing...");
            mod.Init(_helper, manifest);
            _helper.Console.WriteLine($"Loaded {manifest.UniqueName} ({manifest.Version}).");
            _helper.Logger.Log($"Loaded {manifest.UniqueName} ({manifest.Version}).");
        }
Exemplo n.º 14
0
        private Type LoadModType(IModManifest manifest)
        {
            if (!manifest.Enabled)
            {
                _helper.Logger.Log($"{manifest.UniqueName} is disabled");
                return(null);
            }
            _helper.Logger.Log("Loading assembly: " + manifest.AssemblyPath);
            var assembly = Assembly.LoadFile(manifest.AssemblyPath);

            _helper.Logger.Log($"Loaded {assembly.FullName}");
            try
            {
                return(assembly.GetTypes().FirstOrDefault(x => x.IsSubclassOf(typeof(ModBehaviour))));
            }
            catch (Exception ex)
            {
                _helper.Logger.Log($"Error while trying to get {typeof(ModBehaviour)}: {ex.Message}");
                _helper.Console.WriteLine($"Error while trying to get {typeof(ModBehaviour)}: {ex.Message}");
                return(null);
            }
        }
Exemplo n.º 15
0
        public static IModConsole CreateOutput(IOwmlConfig owmlConfig, IModLogger logger, IModManifest manifest)
        {
            if (CommandLineArguments.HasArgument(Constants.ConsolePortArgument))
            {
                return(new ModSocketOutput(owmlConfig, logger, manifest));
            }

            if (logger == null)
            {
                return(new OutputWriter());
            }

            return(new ModFileOutput(owmlConfig, logger, manifest));
        }
Exemplo n.º 16
0
 protected ModConfigMenuBase(IModConsole console, IModManifest manifest) : base(console)
 {
     Manifest = manifest;
     Storage  = new ModStorage(manifest);
 }
Exemplo n.º 17
0
 public ModStorage(IModManifest manifest)
 {
     _manifest = manifest;
 }
Exemplo n.º 18
0
 public void Init(IModHelper modHelper, IModManifest manifest)
 {
     ModHelper   = modHelper;
     ModManifest = manifest;
     DontDestroyOnLoad(gameObject);
 }
Exemplo n.º 19
0
 public OwmlConfigMenu(IModConsole console, IModManifest manifest, IOwmlConfig config, IOwmlConfig defaultConfig)
     : base(console, manifest)
 {
     _config        = config;
     _defaultConfig = defaultConfig;
 }
Exemplo n.º 20
0
 public ModAssets(IModConsole console, IModManifest manifest)
 {
     _console     = console;
     _manifest    = manifest;
     _objImporter = new ObjImporter();
 }
Exemplo n.º 21
0
 public ModData(IModManifest manifest, IModConfig config, IModConfig defaultConfig)
 {
     Manifest      = manifest;
     Config        = config;
     DefaultConfig = defaultConfig;
 }
Exemplo n.º 22
0
 internal static void CallWriteCallback(IModManifest manifest, string text)
 {
     OnConsole?.Invoke(manifest, text);
 }
Exemplo n.º 23
0
 /// <summary>
 ///     Registers a mod
 /// </summary>
 /// <param name="itemId">The UniqueID of the mod</param>
 /// <param name="item">The mod manifest</param>
 public static void RegisterItem(UniqueId <string> itemId, IModManifest item)
 {
     RegistryInstance.RegisterItem(itemId, item);
 }
Exemplo n.º 24
0
 public ModStorage(IModConsole console, IModManifest manifest)
 {
     _console  = console;
     _manifest = manifest;
 }