mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-20 19:04:40 +01:00
Blossom Implement (#1606)
* Blossom! * rename * delete SpawnBlossomEntry.java * use MAP * use List * use LIST * use List * useCondensedResin * useCondensedResin * fix build * enhance * fix bug * REMOVE BOSS * fix condensed resin * fix condensed resin * use POSITIVE_INFINITY * use RewardPreviewData * fix build * fix resources * add BLOSSOM_MONSTER_FIGHTING_VOLUME * edit monster score * edit monster score * fix bug * fix bug * improve logic * fix monsters level * Deleted comment blocks * nitpick * Fix compilation problems * nitpick * Refactor + nitpick * Clean up overall diff to develop * Clean up other usage of condensed resin * Clean up overall diff to develop * Lombokify Scene.java * Missed an odd getter name * Unhardcode reward previews * EDIT NAME * remove leyline 1 * remove leyline 2 * Update BlossomManager.java Co-authored-by: AnimeGitB <AnimeGitB@bigblueball.in>
This commit is contained in:
@@ -8,6 +8,8 @@ import emu.grasscutter.data.excels.*;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.dungeons.DungeonSettleListener;
|
||||
import emu.grasscutter.game.entity.*;
|
||||
import emu.grasscutter.game.entity.gadget.GadgetWorktop;
|
||||
import emu.grasscutter.game.managers.blossom.BlossomManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.player.TeamInfo;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
@@ -17,6 +19,7 @@ import emu.grasscutter.game.quest.QuestGroupSuite;
|
||||
import emu.grasscutter.game.dungeons.challenge.WorldChallenge;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
|
||||
import emu.grasscutter.net.proto.SelectWorktopOptionReqOuterClass;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
||||
import emu.grasscutter.scripts.SceneIndexManager;
|
||||
import emu.grasscutter.scripts.SceneScriptManager;
|
||||
@@ -25,6 +28,8 @@ import emu.grasscutter.scripts.data.SceneGadget;
|
||||
import emu.grasscutter.scripts.data.SceneGroup;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -32,25 +37,26 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Scene {
|
||||
private final World world;
|
||||
private final SceneData sceneData;
|
||||
private final List<Player> players;
|
||||
private final Map<Integer, GameEntity> entities;
|
||||
private final Set<SpawnDataEntry> spawnedEntities;
|
||||
private final Set<SpawnDataEntry> deadSpawnedEntities;
|
||||
private final Set<SceneBlock> loadedBlocks;
|
||||
@Getter private final World world;
|
||||
@Getter private final SceneData sceneData;
|
||||
@Getter private final List<Player> players;
|
||||
@Getter private final Map<Integer, GameEntity> entities;
|
||||
@Getter private final Set<SpawnDataEntry> spawnedEntities;
|
||||
@Getter private final Set<SpawnDataEntry> deadSpawnedEntities;
|
||||
@Getter private final Set<SceneBlock> loadedBlocks;
|
||||
@Getter private final BlossomManager blossomManager;
|
||||
private Set<SpawnDataEntry.GridBlockId> loadedGridBlocks;
|
||||
private boolean dontDestroyWhenEmpty;
|
||||
@Getter @Setter private boolean dontDestroyWhenEmpty;
|
||||
|
||||
private int autoCloseTime;
|
||||
private int time;
|
||||
@Getter @Setter private int autoCloseTime;
|
||||
@Getter private int time;
|
||||
|
||||
private SceneScriptManager scriptManager;
|
||||
private WorldChallenge challenge;
|
||||
private List<DungeonSettleListener> dungeonSettleListeners;
|
||||
private DungeonData dungeonData;
|
||||
private int prevScene; // Id of the previous scene
|
||||
private int prevScenePoint;
|
||||
@Getter private SceneScriptManager scriptManager;
|
||||
@Getter @Setter private WorldChallenge challenge;
|
||||
@Getter private List<DungeonSettleListener> dungeonSettleListeners;
|
||||
@Getter private DungeonData dungeonData;
|
||||
@Getter @Setter private int prevScene; // Id of the previous scene
|
||||
@Getter @Setter private int prevScenePoint;
|
||||
private Set<SceneNpcBornEntry> npcBornEntrySet;
|
||||
public Scene(World world, SceneData sceneData) {
|
||||
this.world = world;
|
||||
@@ -67,36 +73,21 @@ public class Scene {
|
||||
this.loadedGridBlocks = new HashSet<>();
|
||||
this.npcBornEntrySet = ConcurrentHashMap.newKeySet();
|
||||
this.scriptManager = new SceneScriptManager(this);
|
||||
this.blossomManager = new BlossomManager(this);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return sceneData.getId();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public SceneData getSceneData() {
|
||||
return this.sceneData;
|
||||
}
|
||||
|
||||
public SceneType getSceneType() {
|
||||
return getSceneData().getSceneType();
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
return this.getPlayers().size();
|
||||
}
|
||||
|
||||
public Map<Integer, GameEntity> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public GameEntity getEntityById(int id) {
|
||||
return this.entities.get(id);
|
||||
}
|
||||
@@ -107,72 +98,11 @@ public class Scene {
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
/**
|
||||
* @return the autoCloseTime
|
||||
*/
|
||||
public int getAutoCloseTime() {
|
||||
return autoCloseTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param autoCloseTime the autoCloseTime to set
|
||||
*/
|
||||
public void setAutoCloseTime(int autoCloseTime) {
|
||||
this.autoCloseTime = autoCloseTime;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void changeTime(int time) {
|
||||
this.time = time % 1440;
|
||||
}
|
||||
|
||||
public int getPrevScene() {
|
||||
return prevScene;
|
||||
}
|
||||
|
||||
public void setPrevScene(int prevScene) {
|
||||
this.prevScene = prevScene;
|
||||
}
|
||||
|
||||
public int getPrevScenePoint() {
|
||||
return prevScenePoint;
|
||||
}
|
||||
|
||||
public void setPrevScenePoint(int prevPoint) {
|
||||
this.prevScenePoint = prevPoint;
|
||||
}
|
||||
|
||||
public boolean dontDestroyWhenEmpty() {
|
||||
return dontDestroyWhenEmpty;
|
||||
}
|
||||
|
||||
public void setDontDestroyWhenEmpty(boolean dontDestroyWhenEmpty) {
|
||||
this.dontDestroyWhenEmpty = dontDestroyWhenEmpty;
|
||||
}
|
||||
|
||||
public Set<SceneBlock> getLoadedBlocks() {
|
||||
return loadedBlocks;
|
||||
}
|
||||
|
||||
public Set<SpawnDataEntry> getSpawnedEntities() {
|
||||
return spawnedEntities;
|
||||
}
|
||||
|
||||
public Set<SpawnDataEntry> getDeadSpawnedEntities() {
|
||||
return deadSpawnedEntities;
|
||||
}
|
||||
|
||||
public SceneScriptManager getScriptManager() {
|
||||
return scriptManager;
|
||||
}
|
||||
|
||||
public DungeonData getDungeonData() {
|
||||
return dungeonData;
|
||||
}
|
||||
|
||||
public void setDungeonData(DungeonData dungeonData) {
|
||||
if (dungeonData == null || this.dungeonData != null || this.getSceneType() != SceneType.SCENE_DUNGEON || dungeonData.getSceneId() != this.getId()) {
|
||||
return;
|
||||
@@ -180,14 +110,6 @@ public class Scene {
|
||||
this.dungeonData = dungeonData;
|
||||
}
|
||||
|
||||
public WorldChallenge getChallenge() {
|
||||
return challenge;
|
||||
}
|
||||
|
||||
public void setChallenge(WorldChallenge challenge) {
|
||||
this.challenge = challenge;
|
||||
}
|
||||
|
||||
public void addDungeonSettleObserver(DungeonSettleListener dungeonSettleListener) {
|
||||
if (dungeonSettleListeners == null) {
|
||||
dungeonSettleListeners = new ArrayList<>();
|
||||
@@ -195,10 +117,6 @@ public class Scene {
|
||||
dungeonSettleListeners.add(dungeonSettleListener);
|
||||
}
|
||||
|
||||
public List<DungeonSettleListener> getDungeonSettleObservers() {
|
||||
return dungeonSettleListeners;
|
||||
}
|
||||
|
||||
public boolean isInScene(GameEntity entity) {
|
||||
return this.entities.containsKey(entity.getId());
|
||||
}
|
||||
@@ -241,7 +159,7 @@ public class Scene {
|
||||
}
|
||||
|
||||
// Deregister scene if not in use
|
||||
if (this.getPlayerCount() <= 0 && !this.dontDestroyWhenEmpty()) {
|
||||
if (this.getPlayerCount() <= 0 && !this.dontDestroyWhenEmpty) {
|
||||
this.getWorld().deregisterScene(this);
|
||||
}
|
||||
}
|
||||
@@ -434,6 +352,8 @@ public class Scene {
|
||||
challenge.onCheckTimeOut();
|
||||
}
|
||||
|
||||
blossomManager.onTick();
|
||||
|
||||
checkNpcGroup();
|
||||
}
|
||||
|
||||
@@ -527,11 +447,12 @@ public class Scene {
|
||||
}
|
||||
gadget.buildContent();
|
||||
|
||||
gadget.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, 99999);
|
||||
gadget.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 99999);
|
||||
gadget.setFightProperty(FightProperty.FIGHT_PROP_MAX_HP, 99999);
|
||||
gadget.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, Float.POSITIVE_INFINITY);
|
||||
gadget.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, Float.POSITIVE_INFINITY);
|
||||
gadget.setFightProperty(FightProperty.FIGHT_PROP_MAX_HP, Float.POSITIVE_INFINITY);
|
||||
|
||||
entity = gadget;
|
||||
blossomManager.initBlossom(gadget);
|
||||
}
|
||||
|
||||
if (entity == null) continue;
|
||||
@@ -557,6 +478,7 @@ public class Scene {
|
||||
if (toRemove.size() > 0) {
|
||||
toRemove.stream().forEach(this::removeEntityDirectly);
|
||||
this.broadcastPacket(new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE));
|
||||
blossomManager.recycleGadgetEntity(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,4 +747,20 @@ public class Scene {
|
||||
scriptManager.addGroupSuite(group, suite);
|
||||
});
|
||||
}
|
||||
|
||||
public void selectWorktopOptionWith(SelectWorktopOptionReqOuterClass.SelectWorktopOptionReq req) {
|
||||
GameEntity entity = getEntityById(req.getGadgetEntityId());
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
// Handle
|
||||
if (entity instanceof EntityGadget gadget) {
|
||||
if (gadget.getContent() instanceof GadgetWorktop worktop) {
|
||||
boolean shouldDelete = worktop.onSelectWorktopOption(req);
|
||||
if (shouldDelete) {
|
||||
entity.getScene().removeEntity(entity, VisionType.VISION_TYPE_REMOVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,62 +5,20 @@ import java.util.Objects;
|
||||
|
||||
import emu.grasscutter.data.GameDepot;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class SpawnDataEntry {
|
||||
private transient SpawnGroupEntry group;
|
||||
private int monsterId;
|
||||
private int gadgetId;
|
||||
private int configId;
|
||||
private int level;
|
||||
private int poseId;
|
||||
private int gatherItemId;
|
||||
private int gadgetState;
|
||||
private Position pos;
|
||||
private Position rot;
|
||||
|
||||
public SpawnGroupEntry getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(SpawnGroupEntry group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public int getMonsterId() {
|
||||
return monsterId;
|
||||
}
|
||||
|
||||
public int getGadgetId() {
|
||||
return gadgetId;
|
||||
}
|
||||
|
||||
public int getGadgetState() {
|
||||
return gadgetState;
|
||||
}
|
||||
|
||||
public int getConfigId() {
|
||||
return configId;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getPoseId() {
|
||||
return poseId;
|
||||
}
|
||||
|
||||
public int getGatherItemId() {
|
||||
return gatherItemId;
|
||||
}
|
||||
|
||||
public Position getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public Position getRot() {
|
||||
return rot;
|
||||
}
|
||||
@Getter @Setter private transient SpawnGroupEntry group;
|
||||
@Getter private int monsterId;
|
||||
@Getter private int gadgetId;
|
||||
@Getter private int configId;
|
||||
@Getter private int level;
|
||||
@Getter private int poseId;
|
||||
@Getter private int gatherItemId;
|
||||
@Getter private int gadgetState;
|
||||
@Getter private Position pos;
|
||||
@Getter private Position rot;
|
||||
|
||||
public GridBlockId getBlockId() {
|
||||
int scale = GridBlockId.getScale(gadgetId);
|
||||
@@ -71,37 +29,17 @@ public class SpawnDataEntry {
|
||||
}
|
||||
|
||||
public static class SpawnGroupEntry {
|
||||
private int sceneId;
|
||||
private int groupId;
|
||||
private int blockId;
|
||||
private List<SpawnDataEntry> spawns;
|
||||
|
||||
public int getSceneId() {
|
||||
return sceneId;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public int getBlockId() {
|
||||
return blockId;
|
||||
}
|
||||
|
||||
public void setBlockId(int blockId) {
|
||||
this.blockId = blockId;
|
||||
}
|
||||
|
||||
public List<SpawnDataEntry> getSpawns() {
|
||||
return spawns;
|
||||
}
|
||||
@Getter private int sceneId;
|
||||
@Getter private int groupId;
|
||||
@Getter private int blockId;
|
||||
@Getter @Setter private List<SpawnDataEntry> spawns;
|
||||
}
|
||||
|
||||
public static class GridBlockId {
|
||||
int sceneId;
|
||||
int scale;
|
||||
int x;
|
||||
int z;
|
||||
@Getter private int sceneId;
|
||||
@Getter private int scale;
|
||||
@Getter private int x;
|
||||
@Getter private int z;
|
||||
|
||||
public GridBlockId(int sceneId, int scale, int x, int z) {
|
||||
this.sceneId = sceneId;
|
||||
|
||||
Reference in New Issue
Block a user