Unstable 0.17.0.0
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Barotrauma
|
||||
{
|
||||
private const float UpdateInterval = 1.0f;
|
||||
|
||||
private static HashSet<string> unlockedAchievements = new HashSet<string>();
|
||||
private static HashSet<Identifier> unlockedAchievements = new HashSet<Identifier>();
|
||||
|
||||
public static bool CheatsEnabled = false;
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.GameSession.EventManager.CurrentIntensity > 0.99f)
|
||||
{
|
||||
UnlockAchievement("maxintensity", true, c => c != null && !c.IsDead && !c.IsUnconscious);
|
||||
UnlockAchievement("maxintensity".ToIdentifier(), true, c => c != null && !c.IsDead && !c.IsUnconscious);
|
||||
}
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
@@ -84,7 +84,7 @@ namespace Barotrauma
|
||||
else if (Level.Loaded.GetRealWorldDepth(c.WorldPosition.Y) < Level.Loaded.RealWorldCrushDepth * 0.5f)
|
||||
{
|
||||
//all characters that have entered crush depth and are still alive get an achievement
|
||||
if (roundData.EnteredCrushDepth.Contains(c)) UnlockAchievement(c, "survivecrushdepth");
|
||||
if (roundData.EnteredCrushDepth.Contains(c)) UnlockAchievement(c, "survivecrushdepth".ToIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ namespace Barotrauma
|
||||
if (Math.Abs(submarineVel.X) > 100.0f)
|
||||
{
|
||||
//all conscious characters inside the sub get an achievement
|
||||
UnlockAchievement("subhighvelocity", true, c => c != null && c.Submarine == sub && !c.IsDead && !c.IsUnconscious);
|
||||
UnlockAchievement("subhighvelocity".ToIdentifier(), true, c => c != null && c.Submarine == sub && !c.IsDead && !c.IsUnconscious);
|
||||
}
|
||||
|
||||
//achievement for descending ridiculously deep
|
||||
@@ -118,7 +118,7 @@ namespace Barotrauma
|
||||
if (realWorldDepth > 5000.0f && Timing.TotalTime > GameMain.GameSession.RoundStartTime + 30.0f)
|
||||
{
|
||||
//all conscious characters inside the sub get an achievement
|
||||
UnlockAchievement("subdeep", true, c => c != null && c.Submarine == sub && !c.IsDead && !c.IsUnconscious);
|
||||
UnlockAchievement("subdeep".ToIdentifier(), true, c => c != null && c.Submarine == sub && !c.IsDead && !c.IsUnconscious);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,13 +151,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (c == null || c.Removed) { return; }
|
||||
|
||||
if (c.HasEquippedItem("clownmask") &&
|
||||
c.HasEquippedItem("clowncostume"))
|
||||
if (c.HasEquippedItem("clownmask".ToIdentifier()) &&
|
||||
c.HasEquippedItem("clowncostume".ToIdentifier()))
|
||||
{
|
||||
UnlockAchievement(c, "clowncostume");
|
||||
UnlockAchievement(c, "clowncostume".ToIdentifier());
|
||||
}
|
||||
|
||||
if (Submarine.MainSub != null && c.Submarine == null && c.SpeciesName.Equals(CharacterPrefab.HumanSpeciesName, StringComparison.OrdinalIgnoreCase))
|
||||
if (Submarine.MainSub != null && c.Submarine == null && c.SpeciesName == CharacterPrefab.HumanSpeciesName)
|
||||
{
|
||||
float requiredDist = 500 / Physics.DisplayToRealWorldRatio;
|
||||
float distSquared = Vector2.DistanceSquared(c.WorldPosition, Submarine.MainSub.WorldPosition);
|
||||
@@ -187,7 +187,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (distSquared > requiredDist * requiredDist)
|
||||
{
|
||||
UnlockAchievement(c, "crewaway");
|
||||
UnlockAchievement(c, "crewaway".ToIdentifier());
|
||||
}
|
||||
|
||||
static CachedDistance CalculateNewCachedDistance(Character c)
|
||||
@@ -218,7 +218,7 @@ namespace Barotrauma
|
||||
|
||||
public static void OnBiomeDiscovered(Biome biome)
|
||||
{
|
||||
UnlockAchievement("discover" + biome.Identifier.ToLowerInvariant().Replace(" ", ""));
|
||||
UnlockAchievement($"discover{biome.Identifier.Value.Replace(" ", "")}".ToIdentifier());
|
||||
}
|
||||
|
||||
public static void OnItemRepaired(Item item, Character fixer)
|
||||
@@ -228,13 +228,13 @@ namespace Barotrauma
|
||||
#endif
|
||||
if (fixer == null) { return; }
|
||||
|
||||
UnlockAchievement(fixer, "repairdevice");
|
||||
UnlockAchievement(fixer, "repair" + item.Prefab.Identifier);
|
||||
UnlockAchievement(fixer, "repairdevice".ToIdentifier());
|
||||
UnlockAchievement(fixer, $"repair{item.Prefab.Identifier}".ToIdentifier());
|
||||
}
|
||||
|
||||
public static void OnAfflictionRemoved(Affliction affliction, Character character)
|
||||
{
|
||||
if (string.IsNullOrEmpty(affliction.Prefab.AchievementOnRemoved)) { return; }
|
||||
if (affliction.Prefab.AchievementOnRemoved.IsEmpty) { return; }
|
||||
|
||||
#if CLIENT
|
||||
if (GameMain.Client != null) { return; }
|
||||
@@ -248,7 +248,7 @@ namespace Barotrauma
|
||||
if (GameMain.Client != null) { return; }
|
||||
#endif
|
||||
if (reviver == null) { return; }
|
||||
UnlockAchievement(reviver, "healcrit");
|
||||
UnlockAchievement(reviver, "healcrit".ToIdentifier());
|
||||
}
|
||||
|
||||
public static void OnCharacterKilled(Character character, CauseOfDeath causeOfDeath)
|
||||
@@ -260,68 +260,67 @@ namespace Barotrauma
|
||||
causeOfDeath.Killer != null &&
|
||||
causeOfDeath.Killer == Character.Controlled)
|
||||
{
|
||||
IncrementStat(causeOfDeath.Killer, character.IsHuman ? "humanskilled" : "monsterskilled", 1);
|
||||
IncrementStat(causeOfDeath.Killer, (character.IsHuman ? "humanskilled" : "monsterskilled").ToIdentifier(), 1);
|
||||
}
|
||||
#elif SERVER
|
||||
if (character != causeOfDeath.Killer && causeOfDeath.Killer != null)
|
||||
{
|
||||
IncrementStat(causeOfDeath.Killer, character.IsHuman ? "humanskilled" : "monsterskilled", 1);
|
||||
IncrementStat(causeOfDeath.Killer, (character.IsHuman ? "humanskilled" : "monsterskilled").ToIdentifier(), 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
roundData?.Casualties.Add(character);
|
||||
|
||||
UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName);
|
||||
UnlockAchievement(causeOfDeath.Killer, $"kill{character.SpeciesName}".ToIdentifier());
|
||||
if (character.CurrentHull != null)
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName + "indoors");
|
||||
UnlockAchievement(causeOfDeath.Killer, $"kill{character.SpeciesName}indoors".ToIdentifier());
|
||||
}
|
||||
if (character.SpeciesName.EndsWith("boss"))
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("boss", ""));
|
||||
UnlockAchievement(causeOfDeath.Killer, $"kill{character.SpeciesName.Replace("boss", "")}".ToIdentifier());
|
||||
if (character.CurrentHull != null)
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("boss", "") + "indoors");
|
||||
UnlockAchievement(causeOfDeath.Killer, $"kill{character.SpeciesName.Replace("boss", "")}indoors".ToIdentifier());
|
||||
}
|
||||
}
|
||||
if (character.SpeciesName.EndsWith("_m"))
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("_m", ""));
|
||||
UnlockAchievement(causeOfDeath.Killer, $"kill{character.SpeciesName.Replace("_m", "")}".ToIdentifier());
|
||||
if (character.CurrentHull != null)
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "kill" + character.SpeciesName.Replace("_m", "") + "indoors");
|
||||
UnlockAchievement(causeOfDeath.Killer, $"kill{character.SpeciesName.Replace("_m", "")}indoors".ToIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
if (character.HasEquippedItem("clownmask") &&
|
||||
character.HasEquippedItem("clowncostume") &&
|
||||
if (character.HasEquippedItem("clownmask".ToIdentifier()) &&
|
||||
character.HasEquippedItem("clowncostume".ToIdentifier()) &&
|
||||
causeOfDeath.Killer != character)
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "killclown");
|
||||
UnlockAchievement(causeOfDeath.Killer, "killclown".ToIdentifier());
|
||||
}
|
||||
|
||||
if (character.CharacterHealth?.GetAffliction("morbusinepoisoning") != null)
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "killpoison");
|
||||
UnlockAchievement(causeOfDeath.Killer, "killpoison".ToIdentifier());
|
||||
}
|
||||
|
||||
if (causeOfDeath.DamageSource is Item item)
|
||||
{
|
||||
if (item.HasTag("tool"))
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "killtool");
|
||||
UnlockAchievement(causeOfDeath.Killer, "killtool".ToIdentifier());
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (item.Prefab.Identifier)
|
||||
if (item.Prefab.Identifier == "morbusine")
|
||||
{
|
||||
case "morbusine":
|
||||
UnlockAchievement(causeOfDeath.Killer, "killpoison");
|
||||
break;
|
||||
case "nuclearshell":
|
||||
case "nucleardepthcharge":
|
||||
UnlockAchievement(causeOfDeath.Killer, "killnuke");
|
||||
break;
|
||||
UnlockAchievement(causeOfDeath.Killer, "killpoison".ToIdentifier());
|
||||
}
|
||||
else if (item.Prefab.Identifier == "nuclearshell" ||
|
||||
item.Prefab.Identifier == "nucleardepthcharge")
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "killnuke".ToIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,7 +330,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Server.TraitorManager.IsTraitor(character))
|
||||
{
|
||||
UnlockAchievement(causeOfDeath.Killer, "killtraitor");
|
||||
UnlockAchievement(causeOfDeath.Killer, "killtraitor".ToIdentifier());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -342,7 +341,7 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
if (GameMain.Client != null || GameMain.GameSession == null) { return; }
|
||||
#endif
|
||||
UnlockAchievement(character, "traitorwin");
|
||||
UnlockAchievement(character, "traitorwin".ToIdentifier());
|
||||
}
|
||||
|
||||
public static void OnRoundEnded(GameSession gameSession)
|
||||
@@ -363,14 +362,14 @@ namespace Barotrauma
|
||||
!myCharacter.IsDead &&
|
||||
(myCharacter.Submarine == gameSession.Submarine || (Level.Loaded?.EndOutpost != null && myCharacter.Submarine == Level.Loaded.EndOutpost)))
|
||||
{
|
||||
IncrementStat("kmstraveled", levelLengthKilometers);
|
||||
IncrementStat("kmstraveled".ToIdentifier(), levelLengthKilometers);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
//in sp making it to the end is enough
|
||||
IncrementStat("kmstraveled", levelLengthKilometers);
|
||||
IncrementStat("kmstraveled".ToIdentifier(), levelLengthKilometers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +383,10 @@ namespace Barotrauma
|
||||
if (mission is CombatMission combatMission && GameMain.GameSession.WinningTeam.HasValue)
|
||||
{
|
||||
//all characters that are alive and in the winning team get an achievement
|
||||
UnlockAchievement(mission.Prefab.AchievementIdentifier + (int)GameMain.GameSession.WinningTeam, true,
|
||||
var achvIdentifier =
|
||||
$"{mission.Prefab.AchievementIdentifier}{(int) GameMain.GameSession.WinningTeam}"
|
||||
.ToIdentifier();
|
||||
UnlockAchievement(achvIdentifier, true,
|
||||
c => c != null && !c.IsDead && !c.IsUnconscious && combatMission.IsInWinningTeam(c));
|
||||
}
|
||||
else if (mission.Completed)
|
||||
@@ -410,18 +412,18 @@ namespace Barotrauma
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
//in MP all characters that were inside the sub during reactor meltdown and still alive at the end of the round get an achievement
|
||||
UnlockAchievement("survivereactormeltdown", true, c => c != null && !c.IsDead && roundData.ReactorMeltdown.Contains(c));
|
||||
UnlockAchievement("survivereactormeltdown".ToIdentifier(), true, c => c != null && !c.IsDead && roundData.ReactorMeltdown.Contains(c));
|
||||
if (noDamageRun)
|
||||
{
|
||||
UnlockAchievement("nodamagerun", true, c => c != null && !c.IsDead);
|
||||
UnlockAchievement("nodamagerun".ToIdentifier(), true, c => c != null && !c.IsDead);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if CLIENT
|
||||
if (noDamageRun) { UnlockAchievement("nodamagerun"); }
|
||||
if (noDamageRun) { UnlockAchievement("nodamagerun".ToIdentifier()); }
|
||||
if (roundData.ReactorMeltdown.Any()) //in SP getting to the destination after a meltdown is enough
|
||||
{
|
||||
UnlockAchievement("survivereactormeltdown");
|
||||
UnlockAchievement("survivereactormeltdown".ToIdentifier());
|
||||
}
|
||||
#endif
|
||||
var charactersInSub = Character.CharacterList.FindAll(c =>
|
||||
@@ -435,12 +437,12 @@ namespace Barotrauma
|
||||
//there must be some non-enemy casualties to get the last mant standing achievement
|
||||
if (roundData.Casualties.Any(c => !(c.AIController is EnemyAIController) && c.TeamID == charactersInSub[0].TeamID))
|
||||
{
|
||||
UnlockAchievement(charactersInSub[0], "lastmanstanding");
|
||||
UnlockAchievement(charactersInSub[0], "lastmanstanding".ToIdentifier());
|
||||
}
|
||||
#if CLIENT
|
||||
else if (GameMain.GameSession.CrewManager.GetCharacters().Count() == 1)
|
||||
{
|
||||
UnlockAchievement(charactersInSub[0], "lonesailor");
|
||||
UnlockAchievement(charactersInSub[0], "lonesailor".ToIdentifier());
|
||||
}
|
||||
#else
|
||||
//lone sailor achievement if alone in the sub and there are no other characters with the same team ID
|
||||
@@ -449,7 +451,7 @@ namespace Barotrauma
|
||||
c.TeamID == charactersInSub[0].TeamID &&
|
||||
!(c.AIController is EnemyAIController)))
|
||||
{
|
||||
UnlockAchievement(charactersInSub[0], "lonesailor");
|
||||
UnlockAchievement(charactersInSub[0], "lonesailor".ToIdentifier());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -457,14 +459,14 @@ namespace Barotrauma
|
||||
foreach (Character character in charactersInSub)
|
||||
{
|
||||
if (character.Info.Job == null) { continue; }
|
||||
UnlockAchievement(character, character.Info.Job.Prefab.Identifier + "round");
|
||||
UnlockAchievement(character, $"{character.Info.Job.Prefab.Identifier}round".ToIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
pathFinder = null;
|
||||
}
|
||||
|
||||
private static void UnlockAchievement(Character recipient, string identifier)
|
||||
private static void UnlockAchievement(Character recipient, Identifier identifier)
|
||||
{
|
||||
if (CheatsEnabled || recipient == null) { return; }
|
||||
#if CLIENT
|
||||
@@ -477,7 +479,7 @@ namespace Barotrauma
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void IncrementStat(Character recipient, string identifier, int amount)
|
||||
private static void IncrementStat(Character recipient, Identifier identifier, int amount)
|
||||
{
|
||||
if (CheatsEnabled || recipient == null) { return; }
|
||||
#if CLIENT
|
||||
@@ -490,23 +492,22 @@ namespace Barotrauma
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void IncrementStat(string identifier, int amount)
|
||||
public static void IncrementStat(Identifier identifier, int amount)
|
||||
{
|
||||
if (CheatsEnabled) { return; }
|
||||
SteamManager.IncrementStat(identifier, amount);
|
||||
}
|
||||
|
||||
public static void IncrementStat(string identifier, float amount)
|
||||
public static void IncrementStat(Identifier identifier, float amount)
|
||||
{
|
||||
if (CheatsEnabled) { return; }
|
||||
SteamManager.IncrementStat(identifier, amount);
|
||||
}
|
||||
|
||||
public static void UnlockAchievement(string identifier, bool unlockClients = false, Func<Character, bool> conditions = null)
|
||||
public static void UnlockAchievement(Identifier identifier, bool unlockClients = false, Func<Character, bool> conditions = null)
|
||||
{
|
||||
if (CheatsEnabled) { return; }
|
||||
identifier = identifier.ToLowerInvariant();
|
||||
|
||||
|
||||
#if SERVER
|
||||
if (unlockClients && GameMain.Server != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user