Program.cs 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9
using System;
using System.IO;
using System.Reflection;
using Base;
using Model;
using Object = Base.Object;

namespace App
{
T
tanghai 已提交
10
	internal static class Program
11
	{
T
tanghai 已提交
12
		private static void Main(string[] args)
13 14 15 16 17 18 19 20 21 22 23
		{
			try
			{
				Log.Info("server start........................");

				Object.ObjectManager.Register("Base", typeof(Game).Assembly);
				Object.ObjectManager.Register("Model", typeof(Opcode).Assembly);
				byte[] dllBytes = File.ReadAllBytes("./Controller.dll");
				byte[] pdbBytes = File.ReadAllBytes("./Controller.pdb");
				Assembly controller = Assembly.Load(dllBytes, pdbBytes);
				Object.ObjectManager.Register("Controller", controller);
T
tanghai 已提交
24

25 26 27
				Game.Scene.AddComponent<EventComponent>();
				TimeComponent timeComponent = Game.Scene.AddComponent<TimeComponent>();
				Game.Scene.AddComponent<TimerComponent, TimeComponent>(timeComponent);
T
tanghai 已提交
28 29 30 31 32

				Options options = Game.Scene.AddComponent<OptionsComponent, string[]>(args).Options;

				Game.Scene.AddComponent<NetworkComponent, NetworkProtocol, string, int>(options.Protocol, options.Host, options.Port);
				Game.Scene.AddComponent<MessageHandlerComponent, string>(options.AppType);
33 34 35 36 37 38 39 40 41 42 43 44 45

				while (true)
				{
					Object.ObjectManager.Update();
				}
			}
			catch (Exception e)
			{
				Log.Error(e.ToString());
			}
		}
	}
}