mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-06 10:06:51 +01:00
Fix grid parsing
now compatiable with Yukki's resources!
This commit is contained in:
@@ -3,12 +3,31 @@ package emu.grasscutter.data.server;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.utils.GridPosition;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Grid {
|
||||
public Map<GridPosition, Set<Integer>> grid;
|
||||
public Map<String, Set<Integer>> grid;
|
||||
public Map<GridPosition, Set<Integer>> gridMap
|
||||
= new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Loads the correct grid map.
|
||||
*/
|
||||
public void load() {
|
||||
this.grid.forEach((position, groups) ->
|
||||
this.gridMap.put(new GridPosition(position), groups));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The correctly loaded grid map.
|
||||
*/
|
||||
public Map<GridPosition, Set<Integer>> getGrid() {
|
||||
return this.gridMap;
|
||||
}
|
||||
|
||||
public Set<Integer> getNearbyGroups(int vision_level, Position position) {
|
||||
int width = Grasscutter.getConfig().server.game.visionOptions[vision_level].gridWidth;
|
||||
@@ -22,10 +41,10 @@ public class Grid {
|
||||
// should not affect much the loading
|
||||
for (int x = 0; x < vision_range_grid + 1; x++) {
|
||||
for (int z = 0; z < vision_range_grid + 1; z++) {
|
||||
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(x, z), new HashSet<>()));
|
||||
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(-x, z), new HashSet<>()));
|
||||
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(x, -z), new HashSet<>()));
|
||||
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(-x, -z), new HashSet<>()));
|
||||
nearbyGroups.addAll(gridMap.getOrDefault(pos.addClone(x, z), new HashSet<>()));
|
||||
nearbyGroups.addAll(gridMap.getOrDefault(pos.addClone(-x, z), new HashSet<>()));
|
||||
nearbyGroups.addAll(gridMap.getOrDefault(pos.addClone(x, -z), new HashSet<>()));
|
||||
nearbyGroups.addAll(gridMap.getOrDefault(pos.addClone(-x, -z), new HashSet<>()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user