use deconstruction

This commit is contained in:
Gurge44 committed 2026-05-19 16:27:14 +02:00
1 parent 5cce26dc88
commit b44f713dda
1 file changed
+12 -12
+12 -12
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using AmongUs.GameOptions; using AmongUs.GameOptions;
using EHR.Modules; using EHR.Modules;
@@ -539,9 +540,7 @@ internal class Chemist : RoleBase
var processesEnumerator = processes.GetEnumerator(); var processesEnumerator = processes.GetEnumerator();
while (processesEnumerator.MoveNext()) while (processesEnumerator.MoveNext())
{ {
var pair = processesEnumerator.Current; (string processKey, (List<(int Count, Item Item)> ingredients, _)) = processesEnumerator.Current;
var processKey = pair.Key;
var ingredients = pair.Value.Ingredients;
bool available = true; bool available = true;
for (int index = 0; index < ingredients.Count; index++) for (int index = 0; index < ingredients.Count; index++)
@@ -620,17 +619,17 @@ internal class Chemist : RoleBase
{ {
if (SelectedProcess == string.Empty) return; if (SelectedProcess == string.Empty) return;
(List<(int Count, Item Item)> Ingredients, List<(int Count, Item Item)> Results) = Processes[CurrentFactory][SelectedProcess]; (List<(int Count, Item Item)> ingredients, List<(int Count, Item Item)> results) = Processes[CurrentFactory][SelectedProcess];
if (!Ingredients.TrueForAll(x => ItemCounts[x.Item] >= x.Count)) return; if (!ingredients.TrueForAll(x => ItemCounts[x.Item] >= x.Count)) return;
Ingredients.ForEach(x => ingredients.ForEach(x =>
{ {
ItemCounts[x.Item] -= x.Count; ItemCounts[x.Item] -= x.Count;
Utils.SendRPC(CustomRPC.SyncRoleData, pc.PlayerId, 1, (int)x.Item, -x.Count); Utils.SendRPC(CustomRPC.SyncRoleData, pc.PlayerId, 1, (int)x.Item, -x.Count);
}); });
Results.ForEach(x => results.ForEach(x =>
{ {
ItemCounts[x.Item] += x.Count; ItemCounts[x.Item] += x.Count;
Utils.SendRPC(CustomRPC.SyncRoleData, pc.PlayerId, 1, (int)x.Item, x.Count); Utils.SendRPC(CustomRPC.SyncRoleData, pc.PlayerId, 1, (int)x.Item, x.Count);
@@ -638,7 +637,7 @@ internal class Chemist : RoleBase
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc); Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
if (pc.AmOwner && Results.Exists(x => x.Item == Item.SulfuricAcid)) if (pc.AmOwner && results.Exists(x => x.Item == Item.SulfuricAcid))
Achievements.Type.HeyRabek.Complete(); Achievements.Type.HeyRabek.Complete();
} }
@@ -694,12 +693,12 @@ internal class Chemist : RoleBase
if (SelectedProcess == string.Empty) return Suffix.ToString().TrimEnd(); if (SelectedProcess == string.Empty) return Suffix.ToString().TrimEnd();
(List<(int Count, Item Item)> Ingredients, List<(int Count, Item Item)> Results) = Processes[CurrentFactory][SelectedProcess]; (List<(int Count, Item Item)> ingredients, List<(int Count, Item Item)> results) = Processes[CurrentFactory][SelectedProcess];
Func<(int Count, Item Item), string> selector = x => $"{x.Count} {Utils.ColorString(GetItemColor(x.Item), $"{GetChemicalForm(x.Item)}")}"; Func<(int Count, Item Item), string> selector = x => $"{x.Count} {Utils.ColorString(GetItemColor(x.Item), $"{GetChemicalForm(x.Item)}")}";
Suffix.Append(string.Join(", ", Ingredients.Select(selector))); Suffix.Append(string.Join(", ", ingredients.Select(selector)));
Suffix.Append(Ingredients.Count + Results.Count > 2 ? "\n\u2192 " : " → "); Suffix.Append(" → ");
Suffix.Append(string.Join(", ", Results.Select(selector))); Suffix.Append(string.Join(", ", results.Select(selector)));
} }
if ((AcidPlayersDieOptions)AcidPlayersDie.GetValue() == AcidPlayersDieOptions.AfterTime) if ((AcidPlayersDieOptions)AcidPlayersDie.GetValue() == AcidPlayersDieOptions.AfterTime)
@@ -770,6 +769,7 @@ internal class Chemist : RoleBase
return sb.ToString(); return sb.ToString();
} }
[SuppressMessage("ReSharper", "UnusedMember.Local")]
private enum AcidPlayersDieOptions private enum AcidPlayersDieOptions
{ {
AfterMeeting, AfterMeeting,