213 lines
4.9 KiB
Markdown
213 lines
4.9 KiB
Markdown
---
|
|
title: Spawning Local
|
|
type: docs
|
|
weight: 3
|
|
---
|
|
|
|
Le spawning local gere le spawn de NPCs autour des joueurs, assurant que les zones de jeu actives ont une densite de creatures appropriee.
|
|
|
|
**Package:** `com.hypixel.hytale.server.spawning.local`
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Spawning Local
|
|
├── Composants
|
|
│ ├── LocalSpawnController - Controleur spawn joueur
|
|
│ ├── LocalSpawnBeacon - Point de spawn local
|
|
│ └── LocalSpawnState - Suivi etat spawn
|
|
└── Systemes
|
|
├── LocalSpawnSetupSystem - Initialiser spawning local
|
|
├── LocalSpawnControllerSystem - Traiter controleurs
|
|
├── LocalSpawnBeaconSystem - Traiter beacons
|
|
└── LocalSpawnForceTriggerSystem - Declencheurs manuels
|
|
```
|
|
|
|
## LocalSpawnController
|
|
|
|
Controle le spawning local autour d'un joueur:
|
|
|
|
```java
|
|
public class LocalSpawnController implements Component<EntityStore> {
|
|
private double timeToNextRunSeconds;
|
|
|
|
public void setTimeToNextRunSeconds(double seconds);
|
|
public boolean tickTimeToNextRunSeconds(float dt);
|
|
}
|
|
```
|
|
|
|
### Acces au Composant
|
|
|
|
```java
|
|
// Obtenir type de composant
|
|
ComponentType<EntityStore, LocalSpawnController> type =
|
|
SpawningPlugin.get().getLocalSpawnControllerComponentType();
|
|
|
|
// Acceder sur entite joueur
|
|
LocalSpawnController controller = store.getComponent(playerRef, type);
|
|
```
|
|
|
|
### Timing de Spawn
|
|
|
|
Le controleur utilise un delai configurable avant spawning:
|
|
|
|
```java
|
|
// Delai initial configure dans SpawningPlugin
|
|
double joinDelay = SpawningPlugin.get().getLocalSpawnControllerJoinDelay();
|
|
```
|
|
|
|
Cela empeche le spawning immediat quand un joueur rejoint, laissant le temps au monde de charger.
|
|
|
|
## LocalSpawnBeacon
|
|
|
|
Definit les points de spawn locaux autour des joueurs:
|
|
|
|
```java
|
|
public class LocalSpawnBeacon {
|
|
// Position et configuration pour spawns locaux
|
|
// Cree dynamiquement base sur position joueur
|
|
}
|
|
```
|
|
|
|
### Utilisation des Beacons
|
|
|
|
Les beacons de spawn locaux sont geres automatiquement:
|
|
1. Crees autour des joueurs actifs
|
|
2. Mis a jour quand joueurs bougent
|
|
3. Supprimes quand joueurs quittent la zone
|
|
|
|
## LocalSpawnState
|
|
|
|
Suit l'etat de spawn local:
|
|
|
|
```java
|
|
public class LocalSpawnState {
|
|
// Etat de spawn actuel pour un controleur local
|
|
// Suit spawns actifs et cooldowns
|
|
}
|
|
```
|
|
|
|
## Systemes
|
|
|
|
### LocalSpawnSetupSystem
|
|
|
|
Initialise le spawning local pour les joueurs:
|
|
|
|
```java
|
|
getEntityStoreRegistry().registerSystem(new LocalSpawnSetupSystem());
|
|
```
|
|
|
|
Ce systeme:
|
|
- Attache `LocalSpawnController` aux nouveaux joueurs
|
|
- Configure parametres de spawn initiaux
|
|
- Configure les beacons de spawn
|
|
|
|
### LocalSpawnControllerSystem
|
|
|
|
Traite les controleurs de spawn a chaque tick:
|
|
|
|
```java
|
|
getEntityStoreRegistry().registerSystem(new LocalSpawnControllerSystem());
|
|
```
|
|
|
|
Ce systeme:
|
|
- Decremente les timers de spawn
|
|
- Verifie les conditions de spawn
|
|
- Declenche jobs de spawn quand pret
|
|
|
|
### LocalSpawnBeaconSystem
|
|
|
|
Gere les beacons de spawn locaux:
|
|
|
|
```java
|
|
getEntityStoreRegistry().registerSystem(new LocalSpawnBeaconSystem());
|
|
```
|
|
|
|
Ce systeme:
|
|
- Met a jour positions des beacons
|
|
- Traite logique spawn beacon
|
|
- Gere cycle de vie beacon
|
|
|
|
### LocalSpawnForceTriggerSystem
|
|
|
|
Gere les declencheurs de spawn forces:
|
|
|
|
```java
|
|
getEntityStoreRegistry().registerSystem(new LocalSpawnForceTriggerSystem());
|
|
```
|
|
|
|
Utilise pour:
|
|
- Commandes debug
|
|
- Spawning declenche par evenement
|
|
- Population manuelle
|
|
|
|
## Utilisation de l'API
|
|
|
|
### Obtenir Controleur Spawn Local
|
|
|
|
```java
|
|
ComponentType<EntityStore, LocalSpawnController> type =
|
|
LocalSpawnController.getComponentType();
|
|
|
|
LocalSpawnController controller = store.getComponent(playerRef, type);
|
|
if (controller != null) {
|
|
// Le joueur a le spawning local active
|
|
}
|
|
```
|
|
|
|
### Forcer Mise a Jour Spawn
|
|
|
|
```java
|
|
// Reset timer spawn pour declencher verification immediate
|
|
LocalSpawnController controller = store.getComponent(playerRef, type);
|
|
controller.setTimeToNextRunSeconds(0);
|
|
```
|
|
|
|
### Verifier Pret pour Spawn
|
|
|
|
```java
|
|
// Verifier si timer spawn ecoule
|
|
boolean ready = controller.tickTimeToNextRunSeconds(deltaTime);
|
|
if (ready) {
|
|
// Temps de tenter spawning
|
|
}
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### Delai de Connexion
|
|
|
|
Configurer le delai avant que spawning local demarre pour nouveaux joueurs:
|
|
|
|
```java
|
|
double delay = SpawningPlugin.get().getLocalSpawnControllerJoinDelay();
|
|
```
|
|
|
|
Cela empeche:
|
|
- Embuscades immediates au spawn
|
|
- Submerger les nouveaux joueurs
|
|
- Spawning avant chargement monde
|
|
|
|
### Rayon de Spawn
|
|
|
|
Le spawning local utilise un rayon configure autour des joueurs:
|
|
|
|
```java
|
|
// Le rayon de spawn determine a quelle distance du joueur les NPCs peuvent spawn
|
|
// Configure par definition de spawn
|
|
```
|
|
|
|
## Integration avec Spawning Mondial
|
|
|
|
Le spawning local fonctionne avec le spawning mondial:
|
|
|
|
| Systeme | Portee | Declencheur |
|
|
|---------|--------|-------------|
|
|
| Spawning Mondial | Base chunk | Chargement chunk |
|
|
| Spawning Local | Centre joueur | Proximite joueur |
|
|
|
|
Les deux systemes:
|
|
- Respectent la suppression de spawn
|
|
- Utilisent le meme pool NPC
|
|
- Partagent les limites de spawn
|