Init
This commit is contained in:
226
content/world/worldgen/zones.fr.md
Normal file
226
content/world/worldgen/zones.fr.md
Normal file
@@ -0,0 +1,226 @@
|
||||
---
|
||||
title: Zones
|
||||
type: docs
|
||||
weight: 6
|
||||
---
|
||||
|
||||
Les zones définissent des régions distinctes du monde avec des règles de génération, des biomes et des caractéristiques spécifiques.
|
||||
|
||||
**Package:** `com.hypixel.hytale.server.worldgen.zone`
|
||||
|
||||
## Système de Zones
|
||||
|
||||
Les zones partitionnent le monde en zones distinctes :
|
||||
|
||||
```java
|
||||
public class ZoneManager {
|
||||
// Obtenir la zone à une position
|
||||
public Zone getZone(int x, int z);
|
||||
|
||||
// Enregistrer une zone
|
||||
public void registerZone(Zone zone);
|
||||
|
||||
// Obtenir toutes les zones
|
||||
public List<Zone> getZones();
|
||||
}
|
||||
```
|
||||
|
||||
## Définition de Zone
|
||||
|
||||
```yaml
|
||||
# zones/emerald_grove.yaml
|
||||
Type: Zone
|
||||
Id: emerald_grove
|
||||
DisplayName: "Bosquet d'Émeraude"
|
||||
Shape: Circle
|
||||
Center: [0, 0]
|
||||
Radius: 1000
|
||||
Biomes:
|
||||
- forest
|
||||
- dense_forest
|
||||
Climate:
|
||||
TemperatureOffset: 0.1
|
||||
HumidityOffset: 0.2
|
||||
Features:
|
||||
- giant_trees
|
||||
- fairy_circles
|
||||
Prefabs:
|
||||
- elf_village
|
||||
- forest_shrine
|
||||
MobSpawns:
|
||||
- Type: deer
|
||||
Weight: 20
|
||||
- Type: forest_spirit
|
||||
Weight: 5
|
||||
```
|
||||
|
||||
## Classe Zone
|
||||
|
||||
```java
|
||||
public class Zone {
|
||||
private String id;
|
||||
private String displayName;
|
||||
private ZoneShape shape;
|
||||
private List<String> biomes;
|
||||
private ClimateModifier climate;
|
||||
private List<String> features;
|
||||
private List<String> prefabs;
|
||||
private List<MobSpawn> mobSpawns;
|
||||
|
||||
// Vérifier si une position est dans la zone
|
||||
public boolean contains(int x, int z);
|
||||
|
||||
// Obtenir le biome spécifique à la zone
|
||||
public Biome getBiome(int x, int z);
|
||||
|
||||
// Modifier la génération
|
||||
public void modifyGeneration(GenerationContainer container);
|
||||
}
|
||||
```
|
||||
|
||||
## Formes de Zones
|
||||
|
||||
```java
|
||||
public interface ZoneShape {
|
||||
boolean contains(int x, int z);
|
||||
float getDistanceToEdge(int x, int z);
|
||||
}
|
||||
|
||||
public class CircleZone implements ZoneShape {
|
||||
private int centerX, centerZ;
|
||||
private int radius;
|
||||
|
||||
public boolean contains(int x, int z) {
|
||||
int dx = x - centerX;
|
||||
int dz = z - centerZ;
|
||||
return dx * dx + dz * dz <= radius * radius;
|
||||
}
|
||||
}
|
||||
|
||||
public class RectangleZone implements ZoneShape {
|
||||
private int minX, minZ, maxX, maxZ;
|
||||
|
||||
public boolean contains(int x, int z) {
|
||||
return x >= minX && x <= maxX && z >= minZ && z <= maxZ;
|
||||
}
|
||||
}
|
||||
|
||||
public class PolygonZone implements ZoneShape {
|
||||
private List<Vector2i> vertices;
|
||||
|
||||
public boolean contains(int x, int z) {
|
||||
// Algorithme point-dans-polygone
|
||||
return isPointInPolygon(x, z, vertices);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Transitions de Zones
|
||||
|
||||
Transitions douces entre zones :
|
||||
|
||||
```java
|
||||
public class ZoneTransition {
|
||||
private int transitionWidth;
|
||||
|
||||
public float getBlendFactor(Zone from, Zone to, int x, int z) {
|
||||
float distFrom = from.getShape().getDistanceToEdge(x, z);
|
||||
float distTo = to.getShape().getDistanceToEdge(x, z);
|
||||
|
||||
if (distFrom > transitionWidth) {
|
||||
return 0.0f; // Complètement dans la zone 'from'
|
||||
}
|
||||
if (distTo > transitionWidth) {
|
||||
return 1.0f; // Complètement dans la zone 'to'
|
||||
}
|
||||
|
||||
return distFrom / (distFrom + distTo);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Couches de Zones
|
||||
|
||||
Les zones peuvent avoir des couches verticales :
|
||||
|
||||
```yaml
|
||||
# zones/underground_kingdom.yaml
|
||||
Type: Zone
|
||||
Id: underground_kingdom
|
||||
Shape: Circle
|
||||
Center: [5000, 5000]
|
||||
Radius: 500
|
||||
VerticalRange:
|
||||
MinY: 0
|
||||
MaxY: 40
|
||||
Biomes:
|
||||
- crystal_cave
|
||||
- mushroom_forest
|
||||
Features:
|
||||
- glowing_crystals
|
||||
- underground_lake
|
||||
```
|
||||
|
||||
## Priorité des Zones
|
||||
|
||||
Quand les zones se chevauchent, la priorité détermine laquelle s'applique :
|
||||
|
||||
```java
|
||||
public class ZonePriority {
|
||||
public Zone getActiveZone(int x, int y, int z) {
|
||||
List<Zone> containing = zones.stream()
|
||||
.filter(z -> z.contains(x, z) && z.containsY(y))
|
||||
.sorted(Comparator.comparing(Zone::getPriority).reversed())
|
||||
.toList();
|
||||
|
||||
return containing.isEmpty() ? defaultZone : containing.get(0);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Zones Dynamiques
|
||||
|
||||
Zones qui peuvent changer à l'exécution :
|
||||
|
||||
```java
|
||||
public class DynamicZone extends Zone {
|
||||
public void expand(int amount) {
|
||||
if (shape instanceof CircleZone circle) {
|
||||
circle.setRadius(circle.getRadius() + amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void move(int dx, int dz) {
|
||||
shape.translate(dx, dz);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
```yaml
|
||||
# worldgen/zone_config.yaml
|
||||
Zones:
|
||||
Default: wilderness
|
||||
TransitionWidth: 32
|
||||
List:
|
||||
- Id: spawn_area
|
||||
Priority: 100
|
||||
Shape: Circle
|
||||
Center: [0, 0]
|
||||
Radius: 200
|
||||
- Id: wilderness
|
||||
Priority: 0
|
||||
Shape: Infinite
|
||||
```
|
||||
|
||||
## Bonnes Pratiques
|
||||
|
||||
{{< callout type="info" >}}
|
||||
**Directives des Zones :**
|
||||
- Utilisez les zones pour des régions distinctes du monde
|
||||
- Définissez des transitions douces entre zones
|
||||
- Considérez la priorité des zones pour les chevauchements
|
||||
- Utilisez des formes appropriées pour les limites de zones
|
||||
- Testez minutieusement la génération des zones
|
||||
{{< /callout >}}
|
||||
Reference in New Issue
Block a user