Refactor avatar skilldepot and constellation/talent changing

Ensures Traveler retains talent levels and constellations on inactive elements when switching elements.
Relevant for any other skillDepot-changing activities like Windtrace too, though keeping those in the db might not be as useful.

Refactor avatar talent upgrade and access
Refactor skillExtraCharges
This commit is contained in:
AnimeGitB
2022-08-17 19:48:41 +09:30
parent 78b7fb70ac
commit fb1bacb0f8
14 changed files with 399 additions and 476 deletions

View File

@@ -1,25 +1,20 @@
package emu.grasscutter.server.packet.send;
import java.util.Map.Entry;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarSkillInfoNotifyOuterClass.AvatarSkillInfoNotify;
import emu.grasscutter.net.proto.AvatarSkillInfoOuterClass.AvatarSkillInfo;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
public class PacketAvatarSkillInfoNotify extends BasePacket {
public PacketAvatarSkillInfoNotify(Avatar avatar) {
super(PacketOpcodes.AvatarSkillInfoNotify);
public PacketAvatarSkillInfoNotify(long avatarGuid, Int2IntMap skillExtraChargeMap) {
super(PacketOpcodes.AvatarSkillInfoNotify);
AvatarSkillInfoNotify.Builder proto = AvatarSkillInfoNotify.newBuilder()
.setGuid(avatar.getGuid());
for (Entry<Integer, Integer> entry : avatar.getSkillExtraChargeMap().entrySet()) {
proto.putSkillMap(entry.getKey(), AvatarSkillInfo.newBuilder().setMaxChargeCount(entry.getValue()).build());
}
this.setData(proto);
}
var proto = AvatarSkillInfoNotify.newBuilder().setGuid(avatarGuid);
skillExtraChargeMap.forEach((skillId, count) ->
proto.putSkillMap(skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build()));
this.setData(proto);
}
}