Skip to content

Commit

Permalink
Add CBT achievement
Browse files Browse the repository at this point in the history
  • Loading branch information
toberge committed Jul 12, 2024
1 parent c0ca0bc commit 1363ceb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Assets/Scripts/Gamestate/MatchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private IEnumerator DisplayWinScreenAndRestart(PlayerIdentity winner)
{
globalHUDController.DisplayWinScreen(winner);

// TODO extract to achievement class
// TODO extract to achievement class?
var isNotCustomGamemode = MatchRules.Current.GameMode is not GameModeVariant.Custom;
var winnerIsLocalPlayer = Peer2PeerTransport.PlayerDetails.Any(p => p.id == winner.id && p.type is PlayerType.Local);
if (isNotCustomGamemode && winnerIsLocalPlayer)
Expand All @@ -301,6 +301,11 @@ private IEnumerator DisplayWinScreenAndRestart(PlayerIdentity winner)
});
}

var isWinnerInAllRoundsAndHasNotDied =
rounds.All(r => r.Winner == winner.id && !r.Kills.Values.Any(k => k.Contains(winner.id)));
if (isNotCustomGamemode && isWinnerInAllRoundsAndHasNotDied)
SteamManager.Singleton.UnlockAchievement(AchievementType.CogAndBoltTinkering);

yield return new WaitForSecondsRealtime(matchEndDelay);

ReturnToMainMenu();
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Utils/SteamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum AchievementType
AllIn,
Clutch,
MatchPoint,
CogAndBoltTinkering,
}

public class Lobby
Expand Down Expand Up @@ -205,6 +206,7 @@ private void RequestStats()
{ AchievementType.SitThroughCredits, "ACHIEVEMENT_CREDITS" },
{ AchievementType.Clutch, "ACHIEVEMENT_CLUTCH" },
{ AchievementType.MatchPoint, "ACHIEVEMENT_MATCH_POINT" },
{ AchievementType.CogAndBoltTinkering, "ACHIEVEMENT_CBT" },
};

public void UnlockAchievement(SecretCombinationType type)
Expand Down

0 comments on commit 1363ceb

Please sign in to comment.