mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-14 16:04:40 +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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.game.props.EntityType;
|
||||
import emu.grasscutter.game.props.PlayerProperty;
|
||||
import emu.grasscutter.game.shop.ShopLimit;
|
||||
import emu.grasscutter.game.managers.MapMarkManager.*;
|
||||
import emu.grasscutter.game.world.Scene;
|
||||
import emu.grasscutter.game.world.World;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
@@ -37,13 +38,12 @@ import emu.grasscutter.net.proto.OnlinePlayerInfoOuterClass.OnlinePlayerInfo;
|
||||
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass;
|
||||
import emu.grasscutter.net.proto.PlayerLocationInfoOuterClass.PlayerLocationInfo;
|
||||
import emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass;
|
||||
import emu.grasscutter.net.proto.ShowAvatarInfoOuterClass;
|
||||
import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture;
|
||||
import emu.grasscutter.net.proto.ShowAvatarInfoOuterClass;
|
||||
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
|
||||
import emu.grasscutter.net.proto.SocialShowAvatarInfoOuterClass;
|
||||
import emu.grasscutter.server.event.player.PlayerJoinEvent;
|
||||
import emu.grasscutter.server.event.player.PlayerQuitEvent;
|
||||
import emu.grasscutter.server.event.player.PlayerReceiveMailEvent;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
@@ -53,12 +53,12 @@ import emu.grasscutter.utils.MessageHandler;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@Entity(value = "players", useDiscriminator = false)
|
||||
public class Player {
|
||||
|
||||
@Id private int id;
|
||||
@Indexed(options = @IndexOptions(unique = true)) private String accountId;
|
||||
|
||||
@@ -120,6 +120,8 @@ public class Player {
|
||||
@Transient private final InvokeHandler<AbilityInvokeEntry> abilityInvokeHandler;
|
||||
@Transient private final InvokeHandler<AbilityInvokeEntry> clientAbilityInitFinishHandler;
|
||||
|
||||
private MapMarksManager mapMarksManager;
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings({"rawtypes", "unchecked"}) // Morphia only!
|
||||
public Player() {
|
||||
@@ -158,6 +160,7 @@ public class Player {
|
||||
|
||||
this.shopLimit = new ArrayList<>();
|
||||
this.messageHandler = null;
|
||||
this.mapMarksManager = new MapMarksManager();
|
||||
}
|
||||
|
||||
// On player creation
|
||||
@@ -183,6 +186,7 @@ public class Player {
|
||||
this.getPos().set(GameConstants.START_POSITION);
|
||||
this.getRotation().set(0, 307, 0);
|
||||
this.messageHandler = null;
|
||||
this.mapMarksManager = new MapMarksManager();
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
@@ -959,6 +963,10 @@ public class Player {
|
||||
.build();
|
||||
}
|
||||
|
||||
public MapMarksManager getMapMarksManager() {
|
||||
return mapMarksManager;
|
||||
}
|
||||
|
||||
public synchronized void onTick() {
|
||||
// Check ping
|
||||
if (this.getLastPingTime() > System.currentTimeMillis() + 60000) {
|
||||
|
||||
Reference in New Issue
Block a user