Ejemplo n.º 1
0
 public void AddServer(GameServer server, GodotMesher mesher)
 {
     this.server = server;
     this.mesher = mesher;
     thread      = new Thread();
     thread.Start(this, nameof(AddChunks));
 }
Ejemplo n.º 2
0
    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));
    }
Ejemplo n.º 3
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);
    }
Ejemplo n.º 4
0
 public Picker(Terra terra, GodotMesher mesher)
 {
     this.terra       = terra;
     this.mesher      = mesher;
     chunksToProccess = new List <Chunk>();
 }
Ejemplo n.º 5
0
    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);
    }