mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 02:43:15 +00:00
Attempt to keep parity with Grasscutter-Quests
& Fix add trial avatar issue
This commit is contained in:
parent
ae45177ed5
commit
375bb77abe
@ -132,7 +132,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EntityAvatar getCurrentAvatarEntity() {
|
public EntityAvatar getCurrentAvatarEntity() {
|
||||||
return this.getActiveTeam().get(currentCharacterIndex);
|
return this.getActiveTeam().get(this.currentCharacterIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSpawned() {
|
public boolean isSpawned() {
|
||||||
@ -431,7 +431,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
this.setPreviousIndex(this.getCurrentCharacterIndex());
|
this.setPreviousIndex(this.getCurrentCharacterIndex());
|
||||||
|
|
||||||
if (save) {
|
if (save) {
|
||||||
var originalTeam = getCurrentTeamInfo();
|
var originalTeam = this.getCurrentTeamInfo();
|
||||||
this.getTrialAvatarTeam().copyFrom(originalTeam);
|
this.getTrialAvatarTeam().copyFrom(originalTeam);
|
||||||
} else this.getActiveTeam().clear();
|
} else this.getActiveTeam().clear();
|
||||||
|
|
||||||
@ -480,15 +480,14 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
/**
|
/**
|
||||||
* Get the GUID of a trial avatar.
|
* Get the GUID of a trial avatar.
|
||||||
*
|
*
|
||||||
* @param avatarId The avatar ID.
|
* @param trialAvatarId The avatar ID.
|
||||||
* @return The GUID of the avatar.
|
* @return The GUID of the avatar.
|
||||||
*/
|
*/
|
||||||
public long getTrialAvatarGuid(int avatarId) {
|
public long getTrialAvatarGuid(int trialAvatarId) {
|
||||||
return getTrialAvatars().values().stream()
|
return this.getTrialAvatars().values().stream()
|
||||||
.filter(avatar -> avatar.getTrialAvatarId() == avatarId)
|
.filter(avatar -> avatar.getTrialAvatarId() == trialAvatarId)
|
||||||
.map(Avatar::getGuid)
|
.map(Avatar::getGuid)
|
||||||
.findFirst()
|
.findFirst().orElse(0L);
|
||||||
.orElse(0L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Rollback changes from using a trial avatar team. */
|
/** Rollback changes from using a trial avatar team. */
|
||||||
@ -515,9 +514,9 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
/**
|
/**
|
||||||
* Removes a collection of avatars from the trial avatar team.
|
* Removes a collection of avatars from the trial avatar team.
|
||||||
*
|
*
|
||||||
* @param avatarIds The avatar IDs to remove.
|
* @param trialAvatarIds The avatar IDs to remove.
|
||||||
*/
|
*/
|
||||||
public void removeTrialAvatarTeam(List<Integer> avatarIds) {
|
public void removeTrialAvatarTeam(List<Integer> trialAvatarIds) {
|
||||||
var player = this.getPlayer();
|
var player = this.getPlayer();
|
||||||
|
|
||||||
// Disable the trial team.
|
// Disable the trial team.
|
||||||
@ -525,16 +524,16 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
this.trialAvatarTeam = new TeamInfo();
|
this.trialAvatarTeam = new TeamInfo();
|
||||||
|
|
||||||
// Remove the avatars from the team.
|
// Remove the avatars from the team.
|
||||||
avatarIds.forEach(
|
trialAvatarIds.forEach(
|
||||||
avatarId -> {
|
trialAvatarId -> {
|
||||||
this.getActiveTeam()
|
this.getActiveTeam()
|
||||||
.forEach(
|
.forEach(
|
||||||
x ->
|
x ->
|
||||||
player
|
player
|
||||||
.getScene()
|
.getScene()
|
||||||
.removeEntity(x, VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE));
|
.removeEntity(x, VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE));
|
||||||
this.getActiveTeam().removeIf(x -> x.getAvatar().getTrialAvatarId() == avatarId);
|
this.getActiveTeam().removeIf(x -> x.getAvatar().getTrialAvatarId() == trialAvatarId);
|
||||||
this.getTrialAvatars().values().removeIf(x -> x.getTrialAvatarId() == avatarId);
|
this.getTrialAvatars().values().removeIf(x -> x.getTrialAvatarId() == trialAvatarId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-add the avatars to the team.
|
// Re-add the avatars to the team.
|
||||||
@ -1021,19 +1020,19 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
/**
|
/**
|
||||||
* Adds a list of trial avatars to the player's team.
|
* Adds a list of trial avatars to the player's team.
|
||||||
*
|
*
|
||||||
* @param avatarIds List of trial avatar IDs.
|
* @param trialAvatarIds List of trial avatar IDs.
|
||||||
* @param questId The ID of the quest this trial team is associated with.
|
* @param questId The ID of the quest this trial team is associated with.
|
||||||
* @param save Whether to retain the currently equipped avatars.
|
* @param save Whether to retain the currently equipped avatars.
|
||||||
*/
|
*/
|
||||||
public void addTrialAvatars(List<Integer> avatarIds, int questId, boolean save) {
|
public void addTrialAvatars(List<Integer> trialAvatarIds, int questId, boolean save) {
|
||||||
this.setupTrialAvatars(save); // Perform initial setup.
|
this.setupTrialAvatars(save); // Perform initial setup.
|
||||||
|
|
||||||
// Add the avatars to the team.
|
// Add the avatars to the team.
|
||||||
avatarIds.forEach(
|
trialAvatarIds.forEach(
|
||||||
avatarId -> {
|
trialAvatarId -> {
|
||||||
var result =
|
var result =
|
||||||
this.addTrialAvatar(
|
this.addTrialAvatar(
|
||||||
avatarId,
|
trialAvatarId,
|
||||||
questId,
|
questId,
|
||||||
questId == 0
|
questId == 0
|
||||||
? GrantReason.GRANT_REASON_BY_QUEST
|
? GrantReason.GRANT_REASON_BY_QUEST
|
||||||
@ -1043,7 +1042,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Update the team.
|
// Update the team.
|
||||||
this.trialAvatarTeamPostUpdate(questId == 0 ? getActiveTeam().size() - 1 : 0);
|
this.trialAvatarTeamPostUpdate(questId != 0 ? this.getActiveTeam().size() - 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes all trial avatars from the player's team. */
|
/** Removes all trial avatars from the player's team. */
|
||||||
@ -1059,26 +1058,26 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
* Removes a trial avatar from the player's team. Additionally, unlocks the ability to change the
|
* Removes a trial avatar from the player's team. Additionally, unlocks the ability to change the
|
||||||
* team configuration.
|
* team configuration.
|
||||||
*
|
*
|
||||||
* @param avatarId The ID of the avatar.
|
* @param trialAvatarId The ID of the avatar.
|
||||||
*/
|
*/
|
||||||
public void removeTrialAvatar(int avatarId) {
|
public void removeTrialAvatar(int trialAvatarId) {
|
||||||
this.removeTrialAvatar(List.of(avatarId));
|
this.removeTrialAvatar(List.of(trialAvatarId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a collection of trial avatars from the player's team.
|
* Removes a collection of trial avatars from the player's team.
|
||||||
*
|
*
|
||||||
* @param avatarIds List of trial avatar IDs.
|
* @param trialAvatarIds List of trial avatar IDs.
|
||||||
*/
|
*/
|
||||||
public void removeTrialAvatar(List<Integer> avatarIds) {
|
public void removeTrialAvatar(List<Integer> trialAvatarIds) {
|
||||||
if (!this.isUsingTrialTeam()) throw new RuntimeException("Player is not using a trial team.");
|
if (!this.isUsingTrialTeam()) throw new RuntimeException("Player is not using a trial team.");
|
||||||
|
|
||||||
this.getPlayer()
|
this.getPlayer()
|
||||||
.sendPacket(
|
.sendPacket(
|
||||||
new PacketAvatarDelNotify(avatarIds.stream().map(this::getTrialAvatarGuid).toList()));
|
new PacketAvatarDelNotify(trialAvatarIds.stream().map(this::getTrialAvatarGuid).toList()));
|
||||||
this.removeTrialAvatarTeam(avatarIds);
|
this.removeTrialAvatarTeam(trialAvatarIds);
|
||||||
|
|
||||||
// Update the team.
|
// Update the team.
|
||||||
if (avatarIds.size() == 1) this.getPlayer().sendPacket(new PacketAvatarTeamUpdateNotify());
|
if (trialAvatarIds.size() == 1) this.getPlayer().sendPacket(new PacketAvatarTeamUpdateNotify());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user