Exemplo n.º 1
0
        public void Load()
        {
            if (!Directory.Exists(Paths.Worlds))
            {
                Directory.CreateDirectory(Paths.Worlds);
            }
            BlockRepository = new BlockRepository();
            BlockRepository.DiscoverBlockProviders();
            var directories = Directory.GetDirectories(Paths.Worlds);
            var saves       = new List <World.World>();

            foreach (var d in directories)
            {
                try
                {
                    var w = World.World.LoadWorld(d);
                    saves.Add(w);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    /* Who cares */
                }
            }

            Saves = saves.ToArray();
        }
Exemplo n.º 2
0
        public MultiplayerClient(TrueCraftUser user)
        {
            User         = user;
            Client       = new TcpClient();
            PacketReader = new PacketReader();
            PacketReader.RegisterCorePackets();
            PacketHandlers = new PacketHandler[0x100];
            Handlers.PacketHandlers.RegisterHandlers(this);
            World     = new ReadOnlyWorld();
            Inventory = new InventoryWindow(null);
            var repo = new BlockRepository();

            repo.DiscoverBlockProviders();
            World.World.BlockRepository = repo;
            World.World.ChunkProvider   = new EmptyGenerator();
            Physics    = new PhysicsEngine(World.World, repo);
            SocketPool = new SocketAsyncEventArgsPool(100, 200, 65536);
            connected  = 0;
            cancel     = new CancellationTokenSource();
            Health     = 20;
            var crafting = new CraftingRepository();

            CraftingRepository = crafting;
            crafting.DiscoverRecipes();
        }
Exemplo n.º 3
0
        public MultiPlayerServer(ServerConfiguration configuration)
        {
            Trace = new TraceSource(configuration.ServerAddress);
            Trace.Switch.Level = SourceLevels.All;
            Trace.Listeners.Add(new ServerTraceWriter());

            ServerConfiguration = configuration;

            PacketReader      = new PacketReader(Trace);
            Clients           = new List <IRemoteClient>();
            EnvironmentWorker = new Timer(DoEnvironment);
            PacketHandlers    = new PacketHandler[0x100];
            Worlds            = new List <IWorld>();
            EntityManagers    = new List <IEntityManager>();
            Scheduler         = new EventScheduler(this);
            var blockRepository = new BlockRepository();

            blockRepository.DiscoverBlockProviders();
            BlockRepository = blockRepository;
            var itemRepository = new ItemRepository();

            itemRepository.DiscoverItemProviders();
            ItemRepository = itemRepository;
            BlockProvider.ItemRepository  = ItemRepository;
            BlockProvider.BlockRepository = BlockRepository;
            var craftingRepository = new CraftingRepository();

            craftingRepository.DiscoverRecipes();
            CraftingRepository  = craftingRepository;
            PendingBlockUpdates = new Queue <BlockUpdate>();
            EnableClientLogging = configuration.EnableClientLogging;
            QueryProtocol       = new QueryProtocol(this, configuration);
            WorldLighters       = new List <WorldLighting>();
            ChunksToSchedule    = new ConcurrentBag <Tuple <IWorld, IChunk> >();
            Time = new Stopwatch();

            AccessConfiguration = Configuration.LoadConfiguration <AccessConfiguration>(Bootstrap.ResolvePath("access.yaml"));

            ((PacketReader)PacketReader).RegisterCorePackets(typeof(KeepAlivePacket).Assembly);
            Handlers.PacketHandlers.RegisterHandlers(this);
        }