public override void _Ready()
    {
        Registry reg = new Registry();

        PrimitiveResources.Register(reg);
        mesher = (GodotMesher)GetParent().FindNode("GameMesher");
        mesher.SetRegistry(reg);
        chunkFiller = new ChunkFiller(1, 2);
        weltschmerz = new Weltschmerz();
        Thread thread = new Thread();

        thread.Start(this, nameof(Generate));
    }
Beispiel #2
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        registry = new Registry();
        PrimitiveResources.Register(registry);
        weltschmerz = new Weltschmerz();
        Config config = weltschmerz.GetConfig();

        config.elevation.max_elevation = MAX_ELEVATION;
        config.elevation.min_elevation = MIN_ELEVATION;
        config.map.latitude            = LATITUDE;
        config.map.longitude           = LONGITUDE;

        if (LONGITUDE < 2)
        {
            LONGITUDE = 2;
        }

        if (LATITUDE < 2)
        {
            LATITUDE = 2;
        }

        if (MAX_ELEVATION < 2)
        {
            MAX_ELEVATION = 2;
        }

        Position boundries = new Position();

        boundries.x = LONGITUDE;
        boundries.y = MAX_ELEVATION;
        boundries.z = LATITUDE;

        terra = new Terra(boundries, this);
        GodotSemaphore semaphore1 = new GodotSemaphore();
        GodotSemaphore semaphore2 = new GodotSemaphore();

        foreman = new Foreman(weltschmerz, registry, terra, LOAD_RADIUS);

        GameClient  client = (GameClient)FindNode("GameClient");
        GodotMesher mesher = (GodotMesher)FindNode("GameMesher");

        mesher.SetRegistry(registry);
        client.AddServer(this, mesher);
    }
    public void Prepare(Camera camera, LoadMarker marker)
    {
        registry = new Registry();
        PrimitiveResources.Register(registry);
        weltschmerz = new Weltschmerz();
        Config config = weltschmerz.GetConfig();

        config.elevation.max_elevation = MAX_ELEVATION;
        config.elevation.min_elevation = MIN_ELEVATION;
        config.map.latitude            = LATITUDE;
        config.map.longitude           = LONGITUDE;
        mesher = (GodotMesher)FindNode("GameMesher");
        mesher.SetRegistry(registry);

        if (LONGITUDE < 2)
        {
            LONGITUDE = 2;
        }

        if (LATITUDE < 2)
        {
            LATITUDE = 2;
        }

        if (MAX_ELEVATION < 2)
        {
            MAX_ELEVATION = 2;
        }

        GD.Print("Using " + GENERATION_THREADS + " threads");

        Position boundries = new Position();

        boundries.x = LONGITUDE;
        boundries.y = MAX_ELEVATION;
        boundries.z = LATITUDE;

        terra  = new Terra(boundries, this);
        picker = new Picker(terra, mesher);
        GodotSemaphore semaphore1 = new GodotSemaphore();
        GodotSemaphore semaphore2 = new GodotSemaphore();

        foreman = new Foreman(weltschmerz, terra, registry, mesher, VIEW_DISTANCE, camera.Fov, GENERATION_THREADS,
                              semaphore1, semaphore2);

        for (int t = 0; t < GENERATION_THREADS; t++)
        {
            Thread thread = new Thread();
            thread.Start(this, nameof(Generation));
        }

        for (int t = 0; t < PROCESS_THREADS; t++)
        {
            Thread thread = new Thread();
            thread.Start(this, nameof(Loading));
        }

        foreman.SetMaterials(registry);
        marker.Attach(foreman);

        foreman.AddLoadMarker(marker);
    }