Пример #1
0
        public override void InitCore(Mod Mod)
        {
            if (!FilesystemUtil.Sys.DirContainsFiles(Mod.Path, Mod.ModID + ".dll"))
            {
                ConsoleSys.Panic("Core mod cant exist without assembly");
            }
            else
            {
                if (!Assemblies.ContainsKey(Mod.ModID))
                {
                    try
                    {
                        Assemblies[Mod.ModID] = Assembly.LoadFrom(Mod.Path + '/' + Mod.ModID + ".dll");
                    }
                    catch (Exception Exception)
                    {
                        ConsoleSys.Error(Exception.Message);
                    }

                    AddTypes(Assemblies[Mod.ModID]);
                }
                else
                {
                    ConsoleSys.Error("Tried to init Core twice in AssemblySys");
                }
            }
        }
Пример #2
0
        private void ParseMod(string Path)
        {
            ModManifest NewMod;

            try
            {
                string Manifest = FilesystemUtil.Sys.FileRead(Path + '/' + "Manifest.json");
                NewMod          = JsonConvert.DeserializeObject <ModManifest>(Manifest);
                NewMod.Mod.Path = Path;
            }
            catch (System.Exception Exception)
            {
                ConsoleSys.Error("Failed to parse " + Path + '/' + "Manifest.json");
                ConsoleSys.Error(Exception.Message);
                return;
            }

            if (NewMod.Mod.ModID == null)
            {
                ConsoleSys.Error("Failed to parse " + Path + '/' + "Manifest.json");
                return;
            }

            if (ExistingMods.ContainsKey(NewMod.Mod))
            {
                ConsoleSys.Error("Duplicate mod " + NewMod.Name);
                return;
            }

            if (NewMod.Core)
            {
                if (Core.Mod.ModID == null)
                {
                    Core = NewMod;
                }
                else
                {
                    ConsoleSys.Error("Duplicated Core ModID of " + Core.Name + " and " + NewMod.Name);
                }
            }
            else
            {
                ExistingMods[NewMod.Mod] = NewMod;
            }
        }
Пример #3
0
        public void ListSystems(string Type)
        {
            List <string> Systems;

            Type = Type.ToLower();

            if (Type == "shared")
            {
                Systems = Sys.Ref.Shared.Order;
            }
            else if (Type == "server")
            {
                Systems = Sys.Ref.Server.Order;
            }
            else if (Type == "client")
            {
                Systems = Sys.Ref.Client.Order;
            }
            else
            {
                ConsoleSys.Error("Invalid system type");
                ConsoleSys.Message(GetSystemTypes());
                return;
            }

            ConsoleSys.Message(GetSystems(char.ToUpper(Type[0]) + Type.Substring(1), Systems));
        }
Пример #4
0
        private void LoadEntries(string ModID, bool Core)
        {
            string EntriesDir = "res://" + ModID + "/Entries";

            if (!FilesystemUtil.GD.DirExists(EntriesDir))
            {
                ConsoleSys.Error("Failed to load entries at " + EntriesDir + " because folder does not exist");
                return;
            }

            List <string> EntriesFiles = FilesystemUtil.GD.DirGetFiles(EntriesDir);

            for (int i = EntriesFiles.Count - 1; i >= 0; --i)
            {
                if (!EntriesFiles[i].EndsWith(".json"))
                {
                    EntriesFiles.RemoveAt(i);
                }
            }

            for (int i = EntriesFiles.Count - 1; i >= 0; --i)
            {
                string EntryManifest = FilesystemUtil.GD.FileRead(EntriesFiles[i]);

                try
                {
                    var Entries = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, JObject> > >(EntryManifest);

                    foreach (var TypeName in Entries)
                    {
                        if (!ModIDUtil.Validate(TypeName.Key))
                        {
                            ConsoleSys.Error("Entry " + TypeName.Key + " is not a valid ModIDEntry");
                            continue;
                        }

                        string NewModID = ModIDUtil.ModID(TypeName.Key) + ".Entries." + ModIDUtil.ModIDEntry(TypeName.Key);

                        Type Type = AssemblySys.GetType(NewModID);

                        if (Type == null)
                        {
                            ConsoleSys.Error("Type " + TypeName.Key + " is not a valid type");
                            continue;
                        }

                        foreach (var Entry in TypeName.Value)
                        {
                            if (Core)
                            {
                                AddCoreEntry(NewModID, JsonConvert.DeserializeObject(Entry.Value.ToString(Formatting.None), Type));
                            }
                            else
                            {
                                AddModEntry(NewModID, JsonConvert.DeserializeObject(Entry.Value.ToString(Formatting.None), Type));
                            }
                        }
                    }
                }
                catch (Exception Exception)
                {
                    ConsoleSys.Error("Failed to parse entries manifest at " + EntriesFiles[i]);
                    ConsoleSys.Error(Exception.Message);
                    continue;
                }
            }
        }