public NetworkEntity(ClientManagerEntity clientManager, ushort port, RootEntity root) : base(root)
        {
            this.clientManager = clientManager;

            server = new ServerNetwork();
            server.Listen(port, 100);

            server.SetMessageHandler(MessageType.Connect, ConnectHandler);
            server.SetMessageHandler(MessageType.Disconnect, DisconnectHandler);
            server.SetMessageHandler(MessageType.Timeout, TimeoutHandler);
            server.SetMessageHandler(MessageType.Move, MoveHandler);
        }
Example #2
0
        void AddEntities()
        {
            //Factory
            AddChild(new FactoryEntity(this));

            //Config
            ConfigEntity config = new ConfigEntity(this);

            AddChild(config);

            //Collision
            CollisionEntity collision = new CollisionEntity(this);

            AddChild(collision);

            //Pathfinding
            PathfindingEntity pathfinding = new PathfindingEntity(this);

            AddChild(pathfinding);

            //VisionManager
            VisionManagerEntity visionManager = new VisionManagerEntity(collision, config.GetFloat("VisionRadius"), this);

            AddChild(visionManager);

            //UnitManager
            UnitManagerEntity unitManager = new UnitManagerEntity(this);

            AddChild(unitManager);

            //ClientManager
            ClientManagerEntity clientManager = new ClientManagerEntity(this);

            clientManager.SetEntities(unitManager, collision, visionManager);
            AddChild(clientManager);

            //Network
            AddChild(new NetworkEntity(clientManager, (ushort)config.GetInt("Port"), this));
        }