Exemplo n.º 1
0
 /// <summary>
 /// Loads the module.
 /// </summary>
 /// <param name="name">The module name.</param>
 public override void Load(string name)
 {
     WorldModule = ModuleFactory.FindModule("Com.Latipium.Modules.World");
     if (WorldModule != null)
     {
         CreateWorld  = WorldModule.GetFunction <LatipiumObject>("CreateWorld");
         CreateRealm  = WorldModule.GetFunction <string, LatipiumObject>("CreateRealm");
         CreateObject = WorldModule.GetFunction <LatipiumObject, LatipiumObject>("CreateObject");
     }
     ObjectModule = ModuleFactory.FindModule("Com.Latipium.Modules.World.Objects");
     if (ObjectModule != null)
     {
         GetObject = ObjectModule.GetFunction <string, LatipiumObject>("Get");
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the loader and loads all assemblies.
        /// </summary>
        /// <param name="io">The assembly containing the io module</param>
        public static void Init(Assembly io)
        {
            List <Assembly> assemblies = new List <Assembly>();

            // Register the IO assembly first so we can use it
            ModuleLoader.RegisterAssembly(io);
            assemblies.Add(io);
            Assemblies[io.GetName().Name] = io;
            LatipiumModule mod = ModuleFactory.FindModule("Com.Latipium.Modules.IO");

            if (mod != null)
            {
                Func <string, FileMode, FileAccess, Stream> Open = mod.GetFunction <string, FileMode, FileAccess, Stream>("Open");
                if (Open != null)
                {
                    // Pull the list of mods from the IO assembly
                    foreach (string file in mod.InvokeFunction <IEnumerable <string> >("GetModules"))
                    {
                        try {
                            Stream stream = Open(file, FileMode.Open, FileAccess.Read);
                            if (stream == null)
                            {
                                Log.ErrorFormat("IO module was unable to open file {0}", file);
                            }
                            else
                            {
                                byte[] buffer = new byte[stream.Length];
                                stream.Read(buffer, 0, buffer.Length);
                                stream.Close();
                                stream.Dispose();
                                Assembly asm = Assembly.Load(buffer);
                                assemblies.Add(asm);
                                Assemblies[asm.GetName().Name] = asm;
                            }
                        } catch (Exception ex) {
                            Log.Error(ex);
                        }
                    }
                }
            }
            AppDomain.CurrentDomain.AssemblyResolve += ResolveDependency;
            foreach (Assembly asm in assemblies)
            {
                ModuleLoader.RegisterAssembly(asm);
            }
            LoaderLoader.LoadLoaderModules();
            foreach (Assembly asm in assemblies)
            {
                LoaderLoader.LoadAssembly(asm);
            }
        }
Exemplo n.º 3
0
 internal WorldImpl(WorldModule world)
 {
     Realms       = new List <LatipiumObject>();
     Players      = new Dictionary <string, LatipiumObject>();
     WorldModule  = world;
     PlayerModule = ModuleFactory.FindModule("Com.Latipium.Modules.Player");
     if (PlayerModule == null)
     {
         GetPlayer = null;
     }
     else
     {
         GetPlayer = PlayerModule.GetFunction <LatipiumObject>("GetPlayer");
     }
     WorldLock = new object();
 }