mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-20 10:55:08 +01:00
Implement map marking features
Teleport still exists on fish hook mark. Added mapMark-related protos. Map marking data is stored in players collection.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package emu.grasscutter.game.managers.MapMarkManager;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.net.proto.MapMarkFromTypeOuterClass;
|
||||
import emu.grasscutter.net.proto.MapMarkPointOuterClass;
|
||||
import emu.grasscutter.net.proto.MapMarkPointTypeOuterClass;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
@Entity
|
||||
public class MapMark {
|
||||
private int sceneId;
|
||||
private String name;
|
||||
private Position position;
|
||||
private MapMarkPointTypeOuterClass.MapMarkPointType pointType;
|
||||
private int monsterId = 0;
|
||||
private MapMarkFromTypeOuterClass.MapMarkFromType fromType;
|
||||
private int questId = 7;
|
||||
|
||||
public MapMark(Position position, MapMarkPointTypeOuterClass.MapMarkPointType type) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public MapMark(MapMarkPointOuterClass.MapMarkPoint mapMarkPoint) {
|
||||
this.sceneId = mapMarkPoint.getSceneId();
|
||||
this.name = mapMarkPoint.getName();
|
||||
this.position = new Position(mapMarkPoint.getPos().getX(), mapMarkPoint.getPos().getY(), mapMarkPoint.getPos().getZ());
|
||||
this.pointType = mapMarkPoint.getPointType();
|
||||
this.monsterId = mapMarkPoint.getMonsterId();
|
||||
this.fromType = mapMarkPoint.getFromType();
|
||||
this.questId = mapMarkPoint.getQuestId();
|
||||
}
|
||||
|
||||
public int getSceneId() {
|
||||
return this.sceneId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public MapMarkPointTypeOuterClass.MapMarkPointType getMapMarkPointType() {
|
||||
return this.pointType;
|
||||
}
|
||||
|
||||
public void setMapMarkPointType(MapMarkPointTypeOuterClass.MapMarkPointType pointType) {
|
||||
this.pointType = pointType;
|
||||
}
|
||||
|
||||
public int getMonsterId() {
|
||||
return this.monsterId;
|
||||
}
|
||||
|
||||
public void setMonsterId(int monsterId) {
|
||||
this.monsterId = monsterId;
|
||||
}
|
||||
|
||||
public MapMarkFromTypeOuterClass.MapMarkFromType getMapMarkFromType() {
|
||||
return this.fromType;
|
||||
}
|
||||
|
||||
public int getQuestId() {
|
||||
return this.questId;
|
||||
}
|
||||
|
||||
public void setQuestId(int questId) {
|
||||
this.questId = questId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package emu.grasscutter.game.managers.MapMarkManager;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Entity
|
||||
public class MapMarksManager {
|
||||
|
||||
static final int mapMarkMaxCount = 150;
|
||||
private HashMap<String, MapMark> mapMarks;
|
||||
|
||||
public MapMarksManager() {
|
||||
mapMarks = new HashMap<String, MapMark>();
|
||||
}
|
||||
|
||||
public MapMarksManager(HashMap<String, MapMark> mapMarks) {
|
||||
this.mapMarks = mapMarks;
|
||||
}
|
||||
|
||||
public HashMap<String, MapMark> getAllMapMarks() {
|
||||
return mapMarks;
|
||||
}
|
||||
|
||||
public MapMark getMapMark(Position position) {
|
||||
String key = getMapMarkKey(position);
|
||||
if (mapMarks.containsKey(key)) {
|
||||
return mapMarks.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getMapMarkKey(Position position) {
|
||||
return "x" + (int)position.getX()+ "z" + (int)position.getZ();
|
||||
}
|
||||
|
||||
public boolean removeMapMark(Position position) {
|
||||
String key = getMapMarkKey(position);
|
||||
if (mapMarks.containsKey(key)) {
|
||||
mapMarks.remove(key);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addMapMark(MapMark mapMark) {
|
||||
if (mapMarks.size() < mapMarkMaxCount) {
|
||||
if (!mapMarks.containsKey(mapMark.getPosition())) {
|
||||
mapMarks.put(getMapMarkKey(mapMark.getPosition()), mapMark);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setMapMarks(HashMap<String, MapMark> mapMarks) {
|
||||
this.mapMarks = mapMarks;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user