Exemplo n.º 1
0
 public bool ParseManifest(string strManifestPath)
 {
     try
     {
         string        json    = File.ReadAllText(strManifestPath);
         VortexModData modData = JsonConvert.DeserializeObject <VortexModData>(json,
                                                                               new JsonSerializerSettings {
             MissingMemberHandling = MissingMemberHandling.Error,
         });
         if (modData.Base_Id != null)
         {
             AssignBaseData(modData);
             AssignAssemblyName(strManifestPath);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception exc)
     {
         VortexPatcher.Logger.Error("Failed to parse mod manifest", exc);
         return(false);
     }
 }
Exemplo n.º 2
0
        public void InjectPatches()
        {
            try
            {
                if (null == m_ModData)
                {
                    throw new ArgumentNullException("Mod data is not available");
                }

                VortexModData data = (m_ModData as VortexModData);
                if (null == data)
                {
                    throw new InvalidDataException("Invalid Vortex mod data");
                }

                string[] entryPoint = data.EntryPoint.Split(new string[] { "::" }, StringSplitOptions.None);
                if (entryPoint.Length != 2)
                {
                    throw new InvalidDataException(string.Format("Invalid EntryPoint", entryPoint.Length));
                }

                Type type = m_ModAssembly.GetType(entryPoint[0]);
                if (null == type)
                {
                    throw new NullReferenceException("Failed to find entry Type in mod assembly");
                }

                MethodInfo methodInfo = type.GetMethod(entryPoint[1]);
                if (null == methodInfo)
                {
                    throw new NullReferenceException("Failed to find entry Method in mod assembly");
                }

                bool hasVortexParam = methodInfo.GetParameters().SingleOrDefault() != null;
                if (hasVortexParam)
                {
                    VortexMod mod   = VortexMod.GetModEntry(data, "D:\\Games\\UntitledGooseGame\\Untitled_Data\\Managed");
                    object[]  param = new object[] { mod };
                    try
                    {
                        methodInfo.Invoke(null, param);
                    }
                    catch (Exception exc)
                    {
                        VortexPatcher.Logger.Error("Failed to invoke starter method", exc);
                    }
                }
                else
                {
                    methodInfo.Invoke(null, null);
                }
            }
            catch (Exception exc)
            {
                VortexPatcher.Logger.Error("Failed to invoke starter method", exc);
                return;
            }
        }
Exemplo n.º 3
0
 public static VortexMod GetModEntry(VortexModData data, string strDataPath)
 {
     return(new VortexMod(data, strDataPath));
 }
Exemplo n.º 4
0
 public VortexMod(VortexModData data, string strDataPath)
 {
     m_ModData         = data;
     m_strGameDataPath = strDataPath;
 }