static void Refresh(ICharacter character) { var newAchievements = PlayerCharacter.GetPrivateState(character)?.Achievements; if (newAchievements is null || clientCurrentAchievements == newAchievements) { return; } if (clientCurrentAchievements is not null) { var list = clientCurrentAchievements.UnlockedAchievements; list.ClientElementInserted -= ClientUnlockedAchievementAdded; } clientCurrentAchievements = newAchievements; if (clientCurrentAchievements is not null) { var list = clientCurrentAchievements.UnlockedAchievements; list.ClientElementInserted += ClientUnlockedAchievementAdded; } Logger.Important("Achievements received from the server: " + Environment.NewLine + clientCurrentAchievements.UnlockedAchievements .Select(a => a.Achievement.AchievementId) .Select(a => "* " + a) .GetJoinedString(Environment.NewLine)); ClientSyncAchievements(); }
public override void ClientInitialize() { BootstrapperClientGame.InitCallback += Refresh; void Refresh(ICharacter character) { var newAchievements = PlayerCharacter.GetPrivateState(character)?.Achievements; if (newAchievements is null || clientCurrentAchievements == newAchievements) { return; } if (clientCurrentAchievements != null) { var list = clientCurrentAchievements.UnlockedAchievements; list.ClientElementInserted -= this.ClientUnlockedAchievementAdded; } clientCurrentAchievements = newAchievements; if (clientCurrentAchievements != null) { var list = clientCurrentAchievements.UnlockedAchievements; list.ClientElementInserted += this.ClientUnlockedAchievementAdded; } ClientSyncAchievements(); } }
public static void ServerInitCharacterAchievements(PlayerCharacterAchievements characterAchievements) { // add all achievements as locked foreach (var protoAchievement in AllAchievements) { characterAchievements.ServerTryAddAchievement(protoAchievement, isUnlocked: false); } }