示例#1
0
        /// <summary>
        /// Sets up data for the region to work with, including the physics environment and the chunk data management.
        /// </summary>
        public void BuildRegion()
        {
            // TODO: generator registry
            if (TheWorld.Generator == "sphere")
            {
                Generator = new SphereGeneratorCore();
            }
            else
            {
                Generator = new SimpleGeneratorCore();
            }
            ParallelLooper pl = new ParallelLooper();

            for (int i = 0; i < Environment.ProcessorCount; i++)
            {
                pl.AddThread();
            }
            CollisionDetectionSettings.AllowedPenetration = 0.01f; // TODO: This is a global setting - handle it elsewhere, or make it non-global?
            PhysicsWorld = new Space(pl);
            PhysicsWorld.TimeStepSettings.MaximumTimeStepsPerFrame = 10;
            PhysicsWorld.ForceUpdater.Gravity = (GravityNormal * GravityStrength).ToBVector();
            PhysicsWorld.DuringForcesUpdateables.Add(new LiquidVolume(this));
            PhysicsWorld.TimeStepSettings.TimeStepDuration = 1f / TheServer.CVars.g_fps.ValueF;
            Collision = new CollisionUtil(PhysicsWorld);
            // TODO: Perhaps these should be on the server level, not region?
            EntityConstructors.Add(EntityType.ITEM, new ItemEntityConstructor());
            EntityConstructors.Add(EntityType.BLOCK_ITEM, new BlockItemEntityConstructor());
            EntityConstructors.Add(EntityType.GLOWSTICK, new GlowstickEntityConstructor());
            EntityConstructors.Add(EntityType.MODEL, new ModelEntityConstructor());
            EntityConstructors.Add(EntityType.SMOKE_GRENADE, new SmokeGrenadeEntityConstructor());
            EntityConstructors.Add(EntityType.MUSIC_BLOCK, new MusicBlockEntityConstructor());
            EntityConstructors.Add(EntityType.HOVER_MESSAGE, new HoverMessageEntityConstructor());
            ChunkManager = new ChunkDataManager();
            ChunkManager.Init(this);
        }
示例#2
0
        public void BuildWorld()
        {
            MainThread   = Thread.CurrentThread;
            MainThreadID = MainThread.ManagedThreadId;
            ParallelLooper pl = new ParallelLooper();

            for (int i = 0; i < Environment.ProcessorCount; i++)
            {
                pl.AddThread();
            }
            CollisionDetectionSettings.AllowedPenetration = 0.01f;
            PhysicsWorld = new Space(pl);
            PhysicsWorld.TimeStepSettings.MaximumTimeStepsPerFrame = 10;
            PhysicsWorld.ForceUpdater.Gravity = new Vector3(0, 0, -9.8f * 3f / 2f);
            PhysicsWorld.DuringForcesUpdateables.Add(new LiquidVolume(this));
            PhysicsWorld.TimeStepSettings.TimeStepDuration = 1f / TheServer.CVars.g_fps.ValueF;
            Collision = new CollisionUtil(PhysicsWorld);
            EntityConstructors.Add(EntityType.ITEM, new ItemEntityConstructor());
            EntityConstructors.Add(EntityType.BLOCK_ITEM, new BlockItemEntityConstructor());
            EntityConstructors.Add(EntityType.GLOWSTICK, new GlowstickEntityConstructor());
            EntityConstructors.Add(EntityType.MODEL, new ModelEntityConstructor());
            EntityConstructors.Add(EntityType.SMOKE_GRENADE, new SmokeGrenadeEntityConstructor());
            EntityConstructors.Add(EntityType.MUSIC_BLOCK, new MusicBlockEntityConstructor());
            ChunkManager = new ChunkDataManager();
            ChunkManager.Init(this);
            //LoadRegion(new Location(-MaxViewRadiusInChunks * 30), new Location(MaxViewRadiusInChunks * 30), true);
            //TheServer.Schedule.RunAllSyncTasks(0.016); // TODO: Separate per-region scheduler // Also don't freeze the entire server/region just because we're waiting on chunks >.>
            //SysConsole.Output(OutputType.INIT, "Finished building chunks! Now have " + LoadedChunks.Count + " chunks!");
        }