mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 06:07:22 +00:00
implement furniture make system
This commit is contained in:
parent
a695d0c33e
commit
d35ff068cf
13
proto/FurnitureMakeBeHelpedData.proto
Normal file
13
proto/FurnitureMakeBeHelpedData.proto
Normal file
@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "ProfilePicture.proto";
|
||||
|
||||
message FurnitureMakeBeHelpedData {
|
||||
string player_name = 1;
|
||||
uint32 time = 2;
|
||||
uint32 uid = 3;
|
||||
uint32 icon = 4;
|
||||
ProfilePicture profile_picture = 5;
|
||||
}
|
12
proto/FurnitureMakeData.proto
Normal file
12
proto/FurnitureMakeData.proto
Normal file
@ -0,0 +1,12 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
message FurnitureMakeData {
|
||||
uint32 index = 1;
|
||||
uint32 make_id = 2;
|
||||
uint32 begin_time = 3;
|
||||
uint32 dur_time = 4;
|
||||
uint32 accelerate_time = 5;
|
||||
uint32 avatar_id = 6;
|
||||
}
|
8
proto/FurnitureMakeHelpData.proto
Normal file
8
proto/FurnitureMakeHelpData.proto
Normal file
@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
message FurnitureMakeHelpData {
|
||||
uint32 uid = 1;
|
||||
uint32 times = 2;
|
||||
}
|
8
proto/FurnitureMakeMakeInfo.proto
Normal file
8
proto/FurnitureMakeMakeInfo.proto
Normal file
@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
message FurnitureMakeMakeInfo {
|
||||
uint32 furniture_id = 1;
|
||||
uint32 make_count = 2;
|
||||
}
|
10
proto/FurnitureMakeReq.proto
Normal file
10
proto/FurnitureMakeReq.proto
Normal file
@ -0,0 +1,10 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
// CmdId: 4551
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
// IsAllowClient: true
|
||||
message FurnitureMakeReq {
|
||||
}
|
19
proto/FurnitureMakeRsp.proto
Normal file
19
proto/FurnitureMakeRsp.proto
Normal file
@ -0,0 +1,19 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "FurnitureMakeBeHelpedData.proto";
|
||||
import "FurnitureMakeHelpData.proto";
|
||||
import "FurnitureMakeMakeInfo.proto";
|
||||
import "FurnitureMakeSlot.proto";
|
||||
|
||||
// CmdId: 4530
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
message FurnitureMakeRsp {
|
||||
int32 retcode = 6;
|
||||
FurnitureMakeSlot furniture_make_slot = 10;
|
||||
repeated FurnitureMakeHelpData help_data_list = 13;
|
||||
repeated FurnitureMakeBeHelpedData helped_data_list = 12;
|
||||
repeated FurnitureMakeMakeInfo make_info_list = 11;
|
||||
}
|
9
proto/FurnitureMakeSlot.proto
Normal file
9
proto/FurnitureMakeSlot.proto
Normal file
@ -0,0 +1,9 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "FurnitureMakeData.proto";
|
||||
|
||||
message FurnitureMakeSlot {
|
||||
repeated FurnitureMakeData furniture_make_data_list = 1;
|
||||
}
|
12
proto/FurnitureMakeStartReq.proto
Normal file
12
proto/FurnitureMakeStartReq.proto
Normal file
@ -0,0 +1,12 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
// CmdId: 4582
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
// IsAllowClient: true
|
||||
message FurnitureMakeStartReq {
|
||||
uint32 make_id = 1;
|
||||
uint32 avatar_id = 14;
|
||||
}
|
13
proto/FurnitureMakeStartRsp.proto
Normal file
13
proto/FurnitureMakeStartRsp.proto
Normal file
@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "FurnitureMakeSlot.proto";
|
||||
|
||||
// CmdId: 4463
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
message FurnitureMakeStartRsp {
|
||||
int32 retcode = 8;
|
||||
FurnitureMakeSlot furniture_make_slot = 10;
|
||||
}
|
13
proto/TakeFurnitureMakeReq.proto
Normal file
13
proto/TakeFurnitureMakeReq.proto
Normal file
@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
// CmdId: 4768
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
// IsAllowClient: true
|
||||
message TakeFurnitureMakeReq {
|
||||
uint32 index = 9;
|
||||
uint32 make_id = 4;
|
||||
bool is_fast_finish = 2;
|
||||
}
|
17
proto/TakeFurnitureMakeRsp.proto
Normal file
17
proto/TakeFurnitureMakeRsp.proto
Normal file
@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "FurnitureMakeSlot.proto";
|
||||
import "ItemParam.proto";
|
||||
|
||||
// CmdId: 4599
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
message TakeFurnitureMakeRsp {
|
||||
int32 retcode = 9;
|
||||
uint32 make_id = 2;
|
||||
FurnitureMakeSlot furniture_make_slot = 15;
|
||||
repeated ItemParam output_item_list = 10;
|
||||
repeated ItemParam return_item_list = 5;
|
||||
}
|
11
proto/UnlockedFurnitureSuiteDataNotify.proto
Normal file
11
proto/UnlockedFurnitureSuiteDataNotify.proto
Normal file
@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
// CmdId: 4717
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
message UnlockedFurnitureSuiteDataNotify {
|
||||
bool is_all = 10;
|
||||
repeated uint32 furniture_suite_id_list = 15;
|
||||
}
|
@ -87,6 +87,8 @@ public class GameData {
|
||||
private static final Int2ObjectMap<TowerLevelData> towerLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<TowerScheduleData> towerScheduleDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ForgeData> forgeDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<HomeWorldLevelData> homeWorldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<FurnitureMakeConfigData> furnitureMakeConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// Cache
|
||||
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
||||
@ -377,4 +379,10 @@ public class GameData {
|
||||
public static Int2ObjectMap<ForgeData> getForgeDataMap() {
|
||||
return forgeDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<HomeWorldLevelData> getHomeWorldLevelDataMap() {
|
||||
return homeWorldLevelDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<FurnitureMakeConfigData> getFurnitureMakeConfigDataMap() {
|
||||
return furnitureMakeConfigDataMap;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package emu.grasscutter.data.excels;
|
||||
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import emu.grasscutter.data.common.ItemParamData;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
@ResourceType(name = {"FurnitureMakeExcelConfigData.json"})
|
||||
public class FurnitureMakeConfigData extends GameResource {
|
||||
|
||||
int configID;
|
||||
int furnitureItemID;
|
||||
int count;
|
||||
int exp;
|
||||
List<ItemParamData> materialItems;
|
||||
int makeTime;
|
||||
int maxAccelerateTime;
|
||||
int quickFetchMaterialNum;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return configID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.materialItems = materialItems.stream()
|
||||
.filter(x -> x.getId() > 0)
|
||||
.toList();
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package emu.grasscutter.data.excels;
|
||||
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
@ResourceType(name = {"HomeworldLevelExcelConfigData.json"})
|
||||
public class HomeWorldLevelData extends GameResource {
|
||||
|
||||
int level;
|
||||
int exp;
|
||||
int homeCoinStoreLimit;
|
||||
int homeFetterExpStoreLimit;
|
||||
int rewardId;
|
||||
int furnitureMakeSlotCount;
|
||||
int outdoorUnlockBlockCount;
|
||||
int freeUnlockModuleCount;
|
||||
int deployNpcCount;
|
||||
int limitShopGoodsCount;
|
||||
List<String> levelFuncs;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package emu.grasscutter.game.home;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeDataOuterClass;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeSlotOuterClass;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
@Builder(builderMethodName = "of")
|
||||
public class FurnitureMakeSlotItem {
|
||||
@Id
|
||||
int index;
|
||||
int makeId;
|
||||
int avatarId;
|
||||
int beginTime;
|
||||
int durTime;
|
||||
|
||||
public FurnitureMakeDataOuterClass.FurnitureMakeData toProto() {
|
||||
return FurnitureMakeDataOuterClass.FurnitureMakeData.newBuilder()
|
||||
.setIndex(index)
|
||||
.setAvatarId(avatarId)
|
||||
.setMakeId(makeId)
|
||||
.setBeginTime(beginTime)
|
||||
.setDurTime(durTime)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import dev.morphia.annotations.IndexOptions;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.HomeWorldLevelData;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
@ -14,6 +15,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Entity(value = "homes", useDiscriminator = false)
|
||||
@ -28,6 +30,9 @@ public class GameHome {
|
||||
@Indexed(options = @IndexOptions(unique = true))
|
||||
long ownerUid;
|
||||
|
||||
int level;
|
||||
int exp;
|
||||
List<FurnitureMakeSlotItem> furnitureMakeSlotItemList;
|
||||
ConcurrentHashMap<Integer, HomeSceneItem> sceneMap;
|
||||
|
||||
public void save(){
|
||||
@ -45,6 +50,7 @@ public class GameHome {
|
||||
public static GameHome create(Integer uid){
|
||||
return GameHome.of()
|
||||
.ownerUid(uid)
|
||||
.level(1)
|
||||
.sceneMap(new ConcurrentHashMap<>())
|
||||
.build();
|
||||
}
|
||||
@ -65,6 +71,10 @@ public class GameHome {
|
||||
player.getSession().send(new PacketPlayerHomeCompInfoNotify(player));
|
||||
player.getSession().send(new PacketHomeComfortInfoNotify(player));
|
||||
player.getSession().send(new PacketFurnitureCurModuleArrangeCountNotify());
|
||||
player.getSession().send(new PacketHomeMarkPointNotify(player, this));
|
||||
player.getSession().send(new PacketHomeMarkPointNotify(player));
|
||||
}
|
||||
|
||||
public HomeWorldLevelData getLevelData(){
|
||||
return GameData.getHomeWorldLevelDataMap().get(level);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.binout.HomeworldDefaultSaveData;
|
||||
import emu.grasscutter.net.proto.HomeBasicInfoOuterClass.HomeBasicInfo;
|
||||
import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.AccessLevel;
|
||||
|
@ -0,0 +1,146 @@
|
||||
package emu.grasscutter.game.managers;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.common.ItemParamData;
|
||||
import emu.grasscutter.game.home.FurnitureMakeSlotItem;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FurnitureManager {
|
||||
private final Player player;
|
||||
|
||||
public FurnitureManager(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void onLogin(){
|
||||
notifyUnlockFurniture();
|
||||
notifyUnlockFurnitureSuite();
|
||||
}
|
||||
|
||||
public void notifyUnlockFurniture(){
|
||||
player.getSession().send(new PacketUnlockedFurnitureFormulaDataNotify(player.getUnlockedFurniture()));
|
||||
}
|
||||
|
||||
public void notifyUnlockFurnitureSuite(){
|
||||
player.getSession().send(new PacketUnlockedFurnitureSuiteDataNotify(player.getUnlockedFurnitureSuite()));
|
||||
}
|
||||
|
||||
public synchronized boolean unlockFurnitureOrSuite(GameItem useItem){
|
||||
// Check
|
||||
if (!List.of("ITEM_USE_UNLOCK_FURNITURE_FORMULA", "ITEM_USE_UNLOCK_FURNITURE_SUITE")
|
||||
.contains(useItem.getItemData().getItemUse().get(0).getUseOp())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int furnitureIdOrSuiteId = Integer.parseInt(useItem.getItemData().getItemUse().get(0).getUseParam().get(0));
|
||||
|
||||
// Remove first
|
||||
player.getInventory().removeItem(useItem, 1);
|
||||
|
||||
if("ITEM_USE_UNLOCK_FURNITURE_FORMULA".equals(useItem.getItemData().getItemUse().get(0).getUseOp())){
|
||||
player.getUnlockedFurniture().add(furnitureIdOrSuiteId);
|
||||
notifyUnlockFurniture();
|
||||
}else{
|
||||
player.getUnlockedFurnitureSuite().add(furnitureIdOrSuiteId);
|
||||
notifyUnlockFurnitureSuite();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void startMake(int makeId, int avatarId) {
|
||||
var makeData = GameData.getFurnitureMakeConfigDataMap().get(makeId);
|
||||
if(makeData == null){
|
||||
player.getSession().send(new PacketFurnitureMakeStartRsp(Retcode.RET_FURNITURE_MAKE_CONFIG_ERROR_VALUE, null));
|
||||
return;
|
||||
}
|
||||
|
||||
// check slot count
|
||||
if (player.getHome().getLevelData().getFurnitureMakeSlotCount() <= player.getHome().getFurnitureMakeSlotItemList().size()){
|
||||
player.getSession().send(new PacketFurnitureMakeStartRsp(Retcode.RET_FURNITURE_MAKE_SLOT_FULL_VALUE, null));
|
||||
return;
|
||||
}
|
||||
|
||||
// pay items first
|
||||
if(!player.getInventory().payItems(makeData.getMaterialItems().toArray(new ItemParamData[0]))){
|
||||
player.getSession().send(new PacketFurnitureMakeStartRsp(Retcode.RET_HOME_FURNITURE_COUNT_NOT_ENOUGH_VALUE, null));
|
||||
return;
|
||||
}
|
||||
|
||||
var furnitureSlot = FurnitureMakeSlotItem.of()
|
||||
.avatarId(avatarId)
|
||||
.makeId(makeId)
|
||||
.beginTime(Utils.getCurrentSeconds())
|
||||
.durTime(makeData.getMakeTime())
|
||||
.build();
|
||||
|
||||
// add furniture make task
|
||||
player.getHome().getFurnitureMakeSlotItemList().add(furnitureSlot);
|
||||
player.getSession().send(new PacketFurnitureMakeStartRsp(Retcode.RET_SUCC_VALUE,
|
||||
player.getHome().getFurnitureMakeSlotItemList().stream()
|
||||
.map(FurnitureMakeSlotItem::toProto)
|
||||
.toList()
|
||||
));
|
||||
|
||||
player.getHome().save();
|
||||
}
|
||||
|
||||
public void queryStatus() {
|
||||
if (player.getHome().getFurnitureMakeSlotItemList() == null){
|
||||
player.getHome().setFurnitureMakeSlotItemList(new ArrayList<>());
|
||||
}
|
||||
|
||||
player.sendPacket(new PacketFurnitureMakeRsp(player.getHome()));
|
||||
}
|
||||
|
||||
|
||||
public void take(int index, int makeId, boolean isFastFinish) {
|
||||
var makeData = GameData.getFurnitureMakeConfigDataMap().get(makeId);
|
||||
if(makeData == null){
|
||||
player.getSession().send(new PacketTakeFurnitureMakeRsp(Retcode.RET_FURNITURE_MAKE_CONFIG_ERROR_VALUE, makeId, null, null));
|
||||
return;
|
||||
}
|
||||
|
||||
var slotItem = player.getHome().getFurnitureMakeSlotItemList().stream()
|
||||
.filter(x -> x.getIndex() == index && x.getMakeId() == makeId)
|
||||
.findFirst();
|
||||
|
||||
if(slotItem.isEmpty()){
|
||||
player.getSession().send(new PacketTakeFurnitureMakeRsp(Retcode.RET_FURNITURE_MAKE_NO_MAKE_DATA_VALUE, makeId, null, null));
|
||||
return;
|
||||
}
|
||||
|
||||
// pay the speedup item
|
||||
if(isFastFinish && !player.getInventory().payItem(107013,1)){
|
||||
player.getSession().send(new PacketTakeFurnitureMakeRsp(Retcode.RET_FURNITURE_MAKE_UNFINISH_VALUE, makeId, null, null));
|
||||
return;
|
||||
}
|
||||
|
||||
// check if player can take
|
||||
if(slotItem.get().getBeginTime() + slotItem.get().getDurTime() >= Utils.getCurrentSeconds() && !isFastFinish){
|
||||
player.getSession().send(new PacketTakeFurnitureMakeRsp(Retcode.RET_FURNITURE_MAKE_UNFINISH_VALUE, makeId, null, null));
|
||||
return;
|
||||
}
|
||||
|
||||
player.getInventory().addItem(makeData.getFurnitureItemID(), makeData.getCount());
|
||||
player.getHome().getFurnitureMakeSlotItemList().remove(slotItem.get());
|
||||
|
||||
player.getSession().send(new PacketTakeFurnitureMakeRsp(Retcode.RET_SUCC_VALUE, makeId,
|
||||
List.of(ItemParamOuterClass.ItemParam.newBuilder()
|
||||
.setItemId(makeData.getFurnitureItemID())
|
||||
.setCount(makeData.getCount())
|
||||
.build()),
|
||||
player.getHome().getFurnitureMakeSlotItemList().stream()
|
||||
.map(FurnitureMakeSlotItem::toProto)
|
||||
.toList()
|
||||
));
|
||||
player.getHome().save();
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.binout.OpenConfigEntry;
|
||||
import emu.grasscutter.data.binout.OpenConfigEntry.SkillPointModifier;
|
||||
@ -22,14 +21,12 @@ import emu.grasscutter.data.excels.AvatarSkillDepotData.InherentProudSkillOpens;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.inventory.ItemType;
|
||||
import emu.grasscutter.game.inventory.MaterialType;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.game.shop.ShopChestBatchUseTable;
|
||||
import emu.grasscutter.game.shop.ShopChestTable;
|
||||
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
||||
import emu.grasscutter.net.proto.MaterialInfoOuterClass.MaterialInfo;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeFormulaDataNotify;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
@ -861,6 +858,14 @@ public class InventoryManager {
|
||||
// Unlock.
|
||||
useSuccess = player.getServer().getCombineManger().unlockCombineDiagram(player, useItem);
|
||||
}
|
||||
break;
|
||||
case MATERIAL_FURNITURE_FORMULA:
|
||||
case MATERIAL_FURNITURE_SUITE_FORMULA:
|
||||
if (useItem.getItemData().getItemUse() == null) {
|
||||
break;
|
||||
}
|
||||
useSuccess = player.getFurnitureManager().unlockFurnitureOrSuite(useItem);
|
||||
|
||||
break;
|
||||
case MATERIAL_CONSUME_BATCH_USE:
|
||||
// Make sure we have usage data for this material.
|
||||
|
@ -27,6 +27,7 @@ import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.inventory.Inventory;
|
||||
import emu.grasscutter.game.mail.Mail;
|
||||
import emu.grasscutter.game.mail.MailHandler;
|
||||
import emu.grasscutter.game.managers.FurnitureManager;
|
||||
import emu.grasscutter.game.managers.InsectCaptureManager;
|
||||
import emu.grasscutter.game.managers.ResinManager;
|
||||
import emu.grasscutter.game.managers.deforestation.DeforestationManager;
|
||||
@ -99,6 +100,8 @@ public class Player {
|
||||
private Set<Integer> costumeList;
|
||||
private Set<Integer> unlockedForgingBlueprints;
|
||||
private Set<Integer> unlockedCombines;
|
||||
private Set<Integer> unlockedFurniture;
|
||||
private Set<Integer> unlockedFurnitureSuite;
|
||||
private List<ActiveForgeData> activeForges;
|
||||
|
||||
private Integer widgetId;
|
||||
@ -167,6 +170,7 @@ public class Player {
|
||||
@Transient private ForgingManager forgingManager;
|
||||
@Transient private DeforestationManager deforestationManager;
|
||||
@Transient private GameHome home;
|
||||
@Transient private FurnitureManager furnitureManager;
|
||||
|
||||
private long springLastUsed;
|
||||
private HashMap<String, MapMark> mapMarks;
|
||||
@ -202,6 +206,8 @@ public class Player {
|
||||
this.towerData = new TowerData();
|
||||
this.unlockedForgingBlueprints = new HashSet<>();
|
||||
this.unlockedCombines = new HashSet<>();
|
||||
this.unlockedFurniture = new HashSet<>();
|
||||
this.unlockedFurnitureSuite = new HashSet<>();
|
||||
this.activeForges = new ArrayList<>();
|
||||
|
||||
this.setSceneId(3);
|
||||
@ -228,6 +234,7 @@ public class Player {
|
||||
this.energyManager = new EnergyManager(this);
|
||||
this.resinManager = new ResinManager(this);
|
||||
this.forgingManager = new ForgingManager(this);
|
||||
this.furnitureManager = new FurnitureManager(this);
|
||||
}
|
||||
|
||||
// On player creation
|
||||
@ -261,6 +268,7 @@ public class Player {
|
||||
this.resinManager = new ResinManager(this);
|
||||
this.deforestationManager = new DeforestationManager(this);
|
||||
this.forgingManager = new ForgingManager(this);
|
||||
this.furnitureManager = new FurnitureManager(this);
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
@ -565,6 +573,14 @@ public class Player {
|
||||
return this.unlockedCombines;
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedFurniture() {
|
||||
return unlockedFurniture;
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedFurnitureSuite() {
|
||||
return unlockedFurnitureSuite;
|
||||
}
|
||||
|
||||
public List<ActiveForgeData> getActiveForges() {
|
||||
return this.activeForges;
|
||||
}
|
||||
@ -1183,6 +1199,10 @@ public class Player {
|
||||
return this.forgingManager;
|
||||
}
|
||||
|
||||
public FurnitureManager getFurnitureManager() {
|
||||
return furnitureManager;
|
||||
}
|
||||
|
||||
public AbilityManager getAbilityManager() {
|
||||
return abilityManager;
|
||||
}
|
||||
@ -1335,6 +1355,7 @@ public class Player {
|
||||
|
||||
getTodayMoonCard(); // The timer works at 0:0, some users log in after that, use this method to check if they have received a reward today or not. If not, send the reward.
|
||||
|
||||
this.furnitureManager.onLogin();
|
||||
// Home
|
||||
home = GameHome.getByUid(getUid());
|
||||
home.onOwnerLogin(this);
|
||||
|
@ -0,0 +1,16 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
|
||||
@Opcodes(PacketOpcodes.FurnitureMakeReq)
|
||||
public class HandlerFurnitureMakeReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
session.getPlayer().getFurnitureManager().queryStatus();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeStartReqOuterClass;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
|
||||
@Opcodes(PacketOpcodes.FurnitureMakeStartReq)
|
||||
public class HandlerFurnitureMakeStartReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
var req = FurnitureMakeStartReqOuterClass.FurnitureMakeStartReq.parseFrom(payload);
|
||||
|
||||
session.getPlayer().getFurnitureManager().startMake(req.getMakeId(), req.getAvatarId());
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -24,7 +24,7 @@ public class HandlerHomeSceneJumpReq extends PacketHandler {
|
||||
|
||||
Scene scene = session.getPlayer().getWorld().getSceneById(req.getIsEnterRoomScene() ? homeScene.getRoomSceneId() : realmId);
|
||||
Position pos = scene.getScriptManager().getConfig().born_pos;
|
||||
|
||||
|
||||
session.getPlayer().getWorld().transferPlayerToScene(
|
||||
session.getPlayer(),
|
||||
req.getIsEnterRoomScene() ? homeScene.getRoomSceneId() : realmId,
|
||||
|
@ -0,0 +1,19 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.TakeFurnitureMakeReqOuterClass;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
|
||||
@Opcodes(PacketOpcodes.TakeFurnitureMakeReq)
|
||||
public class HandlerTakeFurnitureMakeReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
var req = TakeFurnitureMakeReqOuterClass.TakeFurnitureMakeReq.parseFrom(payload);
|
||||
|
||||
session.getPlayer().getFurnitureManager().take(req.getIndex(), req.getMakeId(), req.getIsFastFinish());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.game.home.FurnitureMakeSlotItem;
|
||||
import emu.grasscutter.game.home.GameHome;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeRspOuterClass;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeSlotOuterClass;
|
||||
|
||||
public class PacketFurnitureMakeRsp extends BasePacket {
|
||||
|
||||
public PacketFurnitureMakeRsp(GameHome home) {
|
||||
super(PacketOpcodes.FurnitureMakeRsp);
|
||||
|
||||
var proto = FurnitureMakeRspOuterClass.FurnitureMakeRsp.newBuilder();
|
||||
|
||||
proto.setFurnitureMakeSlot(FurnitureMakeSlotOuterClass.FurnitureMakeSlot.newBuilder()
|
||||
.addAllFurnitureMakeDataList(home.getFurnitureMakeSlotItemList().stream()
|
||||
.map(FurnitureMakeSlotItem::toProto)
|
||||
.toList())
|
||||
.build());
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeDataOuterClass;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeSlotOuterClass;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeStartRspOuterClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PacketFurnitureMakeStartRsp extends BasePacket {
|
||||
|
||||
public PacketFurnitureMakeStartRsp(int ret, List<FurnitureMakeDataOuterClass.FurnitureMakeData> furnitureMakeData) {
|
||||
super(PacketOpcodes.FurnitureMakeStartRsp);
|
||||
|
||||
var proto = FurnitureMakeStartRspOuterClass.FurnitureMakeStartRsp.newBuilder();
|
||||
|
||||
proto.setRetcode(ret);
|
||||
|
||||
if(furnitureMakeData != null){
|
||||
proto.setFurnitureMakeSlot(FurnitureMakeSlotOuterClass.FurnitureMakeSlot.newBuilder()
|
||||
.addAllFurnitureMakeDataList(furnitureMakeData)
|
||||
.build());
|
||||
}
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
@ -12,13 +12,16 @@ import java.util.Collection;
|
||||
|
||||
public class PacketHomeMarkPointNotify extends BasePacket {
|
||||
|
||||
public PacketHomeMarkPointNotify(Player player, GameHome home) {
|
||||
public PacketHomeMarkPointNotify(Player player) {
|
||||
super(PacketOpcodes.HomeMarkPointNotify);
|
||||
|
||||
var proto = HomeMarkPointNotifyOuterClass.HomeMarkPointNotify.newBuilder();
|
||||
|
||||
if(player.getRealmList() == null){
|
||||
return;
|
||||
}
|
||||
for(var moduleId : player.getRealmList()){
|
||||
var homeScene = home.getHomeSceneItem(moduleId + 2000);
|
||||
var homeScene = player.getHome().getHomeSceneItem(moduleId + 2000);
|
||||
|
||||
var markPointData = HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData.newBuilder()
|
||||
.setModuleId(moduleId)
|
||||
|
@ -0,0 +1,38 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.data.common.ItemParamData;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeDataOuterClass;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeSlotOuterClass;
|
||||
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||
import emu.grasscutter.net.proto.TakeFurnitureMakeRspOuterClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PacketTakeFurnitureMakeRsp extends BasePacket {
|
||||
|
||||
public PacketTakeFurnitureMakeRsp(int ret,
|
||||
int makeId,
|
||||
List<ItemParamOuterClass.ItemParam> output,
|
||||
List<FurnitureMakeDataOuterClass.FurnitureMakeData> others) {
|
||||
super(PacketOpcodes.TakeFurnitureMakeRsp);
|
||||
|
||||
var proto = TakeFurnitureMakeRspOuterClass.TakeFurnitureMakeRsp.newBuilder();
|
||||
|
||||
proto.setRetcode(ret)
|
||||
.setMakeId(makeId);
|
||||
|
||||
if(output != null){
|
||||
proto.addAllOutputItemList(output);
|
||||
}
|
||||
|
||||
if(others != null){
|
||||
proto.setFurnitureMakeSlot(FurnitureMakeSlotOuterClass.FurnitureMakeSlot.newBuilder()
|
||||
.addAllFurnitureMakeDataList(others)
|
||||
.build());
|
||||
}
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
@ -4,22 +4,16 @@ import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.UnlockedFurnitureFormulaDataNotifyOuterClass;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class PacketUnlockedFurnitureFormulaDataNotify extends BasePacket {
|
||||
|
||||
public PacketUnlockedFurnitureFormulaDataNotify() {
|
||||
public PacketUnlockedFurnitureFormulaDataNotify(Set<Integer> unlockList) {
|
||||
super(PacketOpcodes.UnlockedFurnitureFormulaDataNotify);
|
||||
|
||||
var proto = UnlockedFurnitureFormulaDataNotifyOuterClass.UnlockedFurnitureFormulaDataNotify.newBuilder();
|
||||
|
||||
proto.addFurnitureIdList(361207);
|
||||
proto.addFurnitureIdList(362202);
|
||||
proto.addFurnitureIdList(362304);
|
||||
proto.addFurnitureIdList(363102);
|
||||
proto.addFurnitureIdList(363103);
|
||||
proto.addFurnitureIdList(363203);
|
||||
proto.addFurnitureIdList(370201);
|
||||
proto.addFurnitureIdList(370302);
|
||||
|
||||
proto.addAllFurnitureIdList(unlockList);
|
||||
proto.setIsAll(true);
|
||||
|
||||
this.setData(proto);
|
||||
|
@ -0,0 +1,21 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.UnlockedFurnitureSuiteDataNotifyOuterClass;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class PacketUnlockedFurnitureSuiteDataNotify extends BasePacket {
|
||||
|
||||
public PacketUnlockedFurnitureSuiteDataNotify(Set<Integer> unlockList) {
|
||||
super(PacketOpcodes.UnlockedFurnitureSuiteDataNotify);
|
||||
|
||||
var proto = UnlockedFurnitureSuiteDataNotifyOuterClass.UnlockedFurnitureSuiteDataNotify.newBuilder();
|
||||
|
||||
proto.addAllFurnitureSuiteIdList(unlockList);
|
||||
proto.setIsAll(true);
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user