Skip to content

Commit

Permalink
v0.4.3 Source
Browse files Browse the repository at this point in the history
  • Loading branch information
AlchlcDvl committed Jul 31, 2023
1 parent 9f3cede commit 6bd88f3
Show file tree
Hide file tree
Showing 102 changed files with 1,007 additions and 1,066 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @AlchlcDvl
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,6 @@ Among Us/BepInEx/cache/
Among Us/BepInEx/LogOutput.*
Among Us/output_log.txt

*.txt
TODO.txt
.vscode/
packages.lock.json
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Quick warning: This mod adds a LOT of stuff, and is currently not very beginner

| Among Us | Mod Version | Link |
|----------|-------------|------|
| 2023.7.12 (s & e) | v0.4.3 | [Download](https://github.com/AlchlcDvl/TownOfUsReworked/releases/download/v0.4.3/Reworked.zip) |
| 2023.7.12 (s & e) | v0.4.2 | [Download](https://github.com/AlchlcDvl/TownOfUsReworked/releases/download/v0.4.2/Reworked.zip) |
| 2023.6.13 (s & e) | v0.4.1 | [Download](https://github.com/AlchlcDvl/TownOfUsReworked/releases/download/v0.4.1/Reworked.zip) |
| 2023.6.13 (s & e) | v0.4.0 | [Download](https://github.com/AlchlcDvl/TownOfUsReworked/releases/download/v0.4.0/Reworked.zip) |
Expand Down Expand Up @@ -179,6 +180,14 @@ Quick warning: This mod adds a LOT of stuff, and is currently not very beginner
<details>
<summary>Changelog</summary>
<details>
<summary>v0.4.3</summary>
<ul> <li>Update: Updated presets</li> </ul>
<ul> <li>Optimisation: The code was optimised in certain parts</li> </ul>
<ul> <li>Improvement: Improved how Operative bugs and Bomber bombs are handled</li> </ul>
<ul> <li>Critical Fix: Fixed teleporting crashing games</li> </ul>
<ul> <li>Bug Fix: Fixed meeting results not being sent to roles with meeting info (like Operative and Coroner)</li> </ul>
</details>
<details>
<summary>v0.4.2</summary>
<ul> <li>New Game Mode: New way to edit the role generation yourself! Role Lists! (also includes the ability to ban the spawning of up to 5 roles)</li> </ul>
<ul> <li>New Objectifier: Linked</li> </ul>
Expand All @@ -202,7 +211,7 @@ Quick warning: This mod adds a LOT of stuff, and is currently not very beginner
<ul> <li>Change: Radar will now also point towards the closest body if it happens to be closer than the closest alive player</li> </ul>
<ul> <li>Change: Split the "Assassin Is Unique" setting into settings for each faction</li> </ul>
<ul> <li>Change: A Retributionist's inspector results now change based on the role they are mimicking</li> </ul>
<ul> <li>Recode: The in-game wiki has recieved a full recode (WIP)</li> </ul>
<ul> <li>Recode: The in-game wiki has received a full recode (WIP)</li> </ul>
<ul> <li>Recode: The role gen has been slightly recoded again for like the 30th time (I promise they get better with each change)</li> </ul>
<ul> <li>Return: Executioner, Guardian Angel and Guesser automatically get their targets again, but can be toggled to pick their own targets</li> </ul>
<ul> <li>Return: Custom hats are back (nameplates and visors soon to follow)</li> </ul>
Expand Down Expand Up @@ -2389,7 +2398,7 @@ The Rebel can only spawn in 3+ Syndicate games. They can choose to promote a fel
## Shapeshifter
### Alignment: Syndicate (Support)

The Shapeshifter can swap the appearances of 2 players. WIth the Chaos Drive, everyone's appearances are suffled.
The Shapeshifter can swap the appearances of 2 players. With the Chaos Drive, everyone's appearances are suffled.

### Game Options

Expand Down
6 changes: 1 addition & 5 deletions TownOfUsReworked/Classes/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ public static void Stop(string path)
SoundManager.Instance.StopSound(GetAudio(path));
}

public static void StopAll()
{
foreach (var path in SoundEffects.Keys)
Stop(path);
}
public static void StopAll() => SoundEffects.Keys.ToList().ForEach(Stop);

public static string GetLanguage() => (uint)DataManager.Settings.Language.CurrentLanguage switch
{
Expand Down
1 change: 0 additions & 1 deletion TownOfUsReworked/Classes/ModCompatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ public static void GhostRoleBegin()
startingVent = ShipStatus.Instance.AllVents[URandom.RandomRangeInt(0, ShipStatus.Instance.AllVents.Count)];

ChangeFloor(startingVent.transform.position.y > -7f);
CallRpc(CustomRPC.Misc, MiscRPC.SetPos, CustomPlayer.Local);
CustomPlayer.Local.NetTransform.RpcSnapTo(new(startingVent.transform.position.x, startingVent.transform.position.y + 0.3636f));
CustomPlayer.Local.MyPhysics.RpcEnterVent(startingVent.Id);
}
Expand Down
9 changes: 0 additions & 9 deletions TownOfUsReworked/Classes/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ public static void VersionHandshake(int major, int minor, int build, int revisio
GameStartManagerPatch.PlayerVersions.Add(clientId, new(new(major, minor, build, revision), guid));
}

public static void Write(this MessageWriter writer, Vector3 vector3)
{
var vector2 = new Vector2(vector3.x, vector3.y);
writer.Write(vector2);
writer.Write(vector3.z);
}

public static Vector3 ReadVector3(this MessageReader reader)
{
var vector2 = reader.ReadVector2();
Expand Down Expand Up @@ -166,8 +159,6 @@ public static void CallRpc(params object[] data)
writer.Write(sByte);
else if (item is Vector2 vector2)
writer.Write(vector2);
else if (item is Vector3 vector3)
writer.Write(vector3);
else if (item is ulong Ulong)
writer.Write(Ulong);
else if (item is ushort Ushort)
Expand Down
3 changes: 0 additions & 3 deletions TownOfUsReworked/Classes/RoleGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3974,9 +3974,6 @@ private static void SetTargets()

if (TownOfUsReworked.IsTest)
LogSomething($"{player.name} -> {Role.GetRole(player)}, {Objectifier.GetObjectifier(player)}, {Modifier.GetModifier(player)}, {Ability.GetAbility(player)}");

player.MaxReportDistance = CustomGameOptions.ReportDistance;
CallRpc(CustomRPC.Misc, MiscRPC.SetReports, player);
}

LogSomething("Players Set");
Expand Down
4 changes: 1 addition & 3 deletions TownOfUsReworked/Classes/Updates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public static void ClearOldVersions()
try
{
var d = new DirectoryInfo(TownOfUsReworked.DataPath + "\\BepInEx\\plugins");

foreach (var f in d.GetFiles("*.old").Select(x => x.FullName).ToArray())
File.Delete(f);
d.GetFiles("*.old").Select(x => x.FullName).ToList().ForEach(File.Delete);
}
catch (Exception e)
{
Expand Down
89 changes: 32 additions & 57 deletions TownOfUsReworked/Classes/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static class Utils
public static HudManager HUD => HudManager.Instance;
public static MeetingHud Meeting => MeetingHud.Instance;
public static ShipStatus Ship => ShipStatus.Instance;
public static MapBehaviour Map => MapBehaviour.Instance;
private const string Everything = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()|{}[],.<>;':\"-+=*/`~_\\ ⟡☆♡♧♤ø▶❥✔εΔΓικνστυφψΨωχӪζδ♠♥βαµ♣✚Ξρλς§π★ηΛ" +
"γΣΦΘξ✧¢";
private static readonly Dictionary<string, string> KeyWords = new()
Expand Down Expand Up @@ -487,8 +488,8 @@ public static void MurderPlayer(PlayerControl killer, PlayerControl target, Deat
if (Minigame.Instance)
Minigame.Instance.Close();

if (MapBehaviour.Instance)
MapBehaviour.Instance.Close();
if (Map)
Map.Close();

HUD.KillOverlay.ShowKillAnimation(killer.Data, data);
HUD.ShadowQuad.gameObject.SetActive(false);
Expand Down Expand Up @@ -715,7 +716,7 @@ public static void MarkMeetingDead(PlayerControl target, PlayerControl killer, b
ret.RetMenu.GenButtons(Meeting);
}

foreach (var area in Meeting.playerStates)
foreach (var area in AllVoteAreas)
{
if (area.VotedFor != target.PlayerId)
continue;
Expand Down Expand Up @@ -924,8 +925,8 @@ public static List<bool> Interact(PlayerControl player, PlayerControl target, bo
return new() { fullReset, gaReset, survReset, abilityUsed };
}

public static List<PlayerControl> GetClosestPlayers(Vector2 truePosition, float radius) => CustomPlayer.AllPlayers.Where(x => Vector2.Distance(truePosition,
x.GetTruePosition()) <= radius).ToList();
public static List<PlayerControl> GetClosestPlayers(Vector2 truePosition, float radius, bool includeDead = false) => CustomPlayer.AllPlayers.Where(x =>
Vector2.Distance(truePosition, x.GetTruePosition()) <= radius && (!x.Data.IsDead || (x.Data.IsDead && includeDead))).ToList();

public static bool IsTooFar(PlayerControl player, PlayerControl target)
{
Expand Down Expand Up @@ -968,14 +969,9 @@ public static bool IsTooFar(PlayerControl player, Vent target)

public static void Spread(PlayerControl interacter, PlayerControl target)
{
foreach (var pb in Role.GetRoles<Plaguebearer>(RoleEnum.Plaguebearer))
pb.RpcSpreadInfection(interacter, target);

foreach (var arso in Role.GetRoles<Arsonist>(RoleEnum.Arsonist))
arso.RpcSpreadDouse(target, interacter);

foreach (var cryo in Role.GetRoles<Cryomaniac>(RoleEnum.Cryomaniac))
cryo.RpcSpreadDouse(target, interacter);
Role.GetRoles<Plaguebearer>(RoleEnum.Plaguebearer).ForEach(pb => pb.RpcSpreadInfection(interacter, target));
Role.GetRoles<Arsonist>(RoleEnum.Arsonist).ForEach(arso => arso.RpcSpreadDouse(target, interacter));
Role.GetRoles<Cryomaniac>(RoleEnum.Cryomaniac).ForEach(cryo => cryo.RpcSpreadDouse(target, interacter));
}

public static bool Check(int probability)
Expand All @@ -992,11 +988,8 @@ public static bool Check(int probability)

public static void StopDragging(byte id)
{
foreach (var janitor in Role.GetRoles<Janitor>(RoleEnum.Janitor).Where(x => x.CurrentlyDragging != null && x.CurrentlyDragging.ParentId == id))
janitor.Drop();

foreach (var godfather in Role.GetRoles<PromotedGodfather>(RoleEnum.PromotedGodfather).Where(x => x.CurrentlyDragging != null && x.CurrentlyDragging.ParentId == id))
godfather.Drop();
Role.GetRoles<Janitor>(RoleEnum.Janitor).Where(x => x.CurrentlyDragging != null && x.CurrentlyDragging.ParentId == id).ToList().ForEach(x => x.Drop());
Role.GetRoles<PromotedGodfather>(RoleEnum.PromotedGodfather).Where(x => x.CurrentlyDragging != null && x.CurrentlyDragging.ParentId == id).ToList().ForEach(x => x.Drop());
}

public static void LogSomething(object message, ModLogType type = ModLogType.Message)
Expand Down Expand Up @@ -1029,10 +1022,7 @@ public static string CreateText(string itemName, string folder = "")
var stream = TownOfUsReworked.Executing.GetManifestResourceStream(resourceName);
var reader = new StreamReader(stream);
var text = reader.ReadToEnd();

foreach (var (key, value) in KeyWords)
text = text.Replace(key, value);

KeyWords.ToList().ForEach(x => text = text.Replace(x.Key, x.Value));
return text;
}
catch
Expand Down Expand Up @@ -1202,12 +1192,11 @@ public static IEnumerator FlashCoro(Color color, float duration, string message,

public static void SetFullScreenHUD()
{
var fullscreen = HUD.FullScreen;
var red = new Color(1f, 0f, 0f, 0.37254903f);

if (fullscreen.color.Equals(red))
fullscreen.color = red;
if (!(HudManager.InstanceExists && HudManager.Instance.FullScreen))
return;

var fullscreen = HUD.FullScreen;
fullscreen.color = new(0.6f, 0.6f, 0.6f, 0f);
var fs = false;

if (ShipStatus.Instance)
Expand Down Expand Up @@ -1245,8 +1234,11 @@ public static void SetFullScreenHUD()
}
}

fullscreen.enabled = fs;
fullscreen.gameObject.active = fs;
fullscreen.enabled = true;
fullscreen.gameObject.active = true;

if (fs)
fullscreen.color = new(1f, 0f, 0f, 0.37254903f);
}

public static void Warp()
Expand Down Expand Up @@ -1276,8 +1268,8 @@ public static void WarpPlayersToCoordinates(Dictionary<byte, Vector2> coordinate
if (Minigame.Instance)
Minigame.Instance.Close();

if (MapBehaviour.Instance)
MapBehaviour.Instance.Close();
if (Map)
Map.Close();

if (CustomPlayer.Local.inVent)
{
Expand All @@ -1297,11 +1289,8 @@ public static void WarpPlayersToCoordinates(Dictionary<byte, Vector2> coordinate

if (AmongUsClient.Instance.AmHost)
{
foreach (var janitor in Role.GetRoles<Janitor>(RoleEnum.Janitor).Where(x => x.CurrentlyDragging != null))
janitor.Drop();

foreach (var godfather in Role.GetRoles<PromotedGodfather>(RoleEnum.PromotedGodfather).Where(x => x.CurrentlyDragging != null))
godfather.Drop();
Role.GetRoles<Janitor>(RoleEnum.Janitor).Where(x => x.CurrentlyDragging != null).ToList().ForEach(x => x.Drop());
Role.GetRoles<PromotedGodfather>(RoleEnum.PromotedGodfather).Where(x => x.CurrentlyDragging != null).ToList().ForEach(x => x.Drop());
}
}

Expand All @@ -1317,9 +1306,7 @@ public static void WarpPlayersToCoordinates(Dictionary<byte, Vector2> coordinate
allLocations.Add(player.transform.position);
}

foreach (var vent in AllVents)
allLocations.Add(GetVentPosition(vent));

AllVents.ForEach(x => allLocations.Add(GetVentPosition(x)));
var tobeadded = TownOfUsReworked.NormalOptions.MapId switch
{
0 => SkeldSpawns,
Expand All @@ -1332,9 +1319,7 @@ public static void WarpPlayersToCoordinates(Dictionary<byte, Vector2> coordinate
if (tobeadded != null)
allLocations.AddRange(tobeadded);

foreach (var target in targets)
coordinates.Add(target.PlayerId, allLocations.Random());

targets.ForEach(x => coordinates.Add(x.PlayerId, allLocations.Random()));
return coordinates;
}

Expand Down Expand Up @@ -1396,8 +1381,8 @@ public static void Teleport(PlayerControl player, Vector3 position)
if (Minigame.Instance)
Minigame.Instance.Close();

if (MapBehaviour.Instance)
MapBehaviour.Instance.Close();
if (Map)
Map.Close();
}

player.moveable = true;
Expand Down Expand Up @@ -1734,10 +1719,7 @@ public static void RemoveTasks(PlayerControl player)
normalPlayerTask.Initialize();

if (normalPlayerTask.TaskType == TaskTypes.PickUpTowels)
{
foreach (var console in UObject.FindObjectsOfType<TowelTaskConsole>())
console.Image.color = UColor.white;
}
UObject.FindObjectsOfType<TowelTaskConsole>().ToList().ForEach(x => x.Image.color = UColor.white);

normalPlayerTask.taskStep = 0;

Expand Down Expand Up @@ -1842,15 +1824,8 @@ void AddWord(string word)

public static string WrapTexts(List<string> texts, int width = 90, bool overflow = true)
{
var result = "";
var pos = 0;

foreach (var text in texts)
{
result += (pos == 0 ? "" : "\n") + WrapText(text, width, overflow);
pos++;
}

var result = WrapText(texts[0], width, overflow);
texts.Skip(1).ToList().ForEach(x => result += $"\n{WrapText(x, width, overflow)}");
return result;
}
}
Expand Down
14 changes: 3 additions & 11 deletions TownOfUsReworked/Cosmetics/CosmeticsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ private static async Task<HttpStatusCode> FetchHats(bool update)
if (update && Directory.Exists(TownOfUsReworked.Hats))
{
var d = new DirectoryInfo(TownOfUsReworked.Hats);

foreach (var f in d.GetFiles("*.png").Select(x => x.FullName).ToArray())
File.Delete(f);
d.GetFiles("*.png").Select(x => x.FullName).ToArray().ToList().ForEach(File.Delete);
}

if (!Directory.Exists(TownOfUsReworked.Hats))
Expand Down Expand Up @@ -268,12 +266,9 @@ private static async Task<HttpStatusCode> FetchHats(bool update)
if (update && Directory.Exists(TownOfUsReworked.Visors))
{
var d = new DirectoryInfo(TownOfUsReworked.Visors);
foreach (var f in d.GetFiles("*.png").Select(x => x.FullName).ToArray())
File.Delete(f);
d.GetFiles("*.png").Select(x => x.FullName).ToArray().ToList().ForEach(File.Delete);
}
if (!Directory.Exists(TownOfUsReworked.Visors))
Directory.CreateDirectory(TownOfUsReworked.Visors);
Expand Down Expand Up @@ -364,12 +359,9 @@ private static async Task<HttpStatusCode> FetchNameplates(bool update)
if (update && Directory.Exists(TownOfUsReworked.Nameplates))
{
var d = new DirectoryInfo(TownOfUsReworked.Nameplates);
foreach (var f in d.GetFiles("*.png").Select(x => x.FullName).ToArray())
File.Delete(f);
d.GetFiles("*.png").Select(x => x.FullName).ToArray().ToList().ForEach(File.Delete);
}
if (!Directory.Exists(TownOfUsReworked.Nameplates))
Directory.CreateDirectory(TownOfUsReworked.Nameplates);
Expand Down
6 changes: 1 addition & 5 deletions TownOfUsReworked/Cosmetics/CustomHats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,7 @@ public static bool Prefix(HatsTab __instance)
return 500;
});

foreach (var key in orderedKeys)
{
var value = packages[key];
YOffset = CreateHatPackage(value, key, YOffset, __instance);
}
orderedKeys.ToList().ForEach(key => YOffset = CreateHatPackage(packages[key], key, YOffset, __instance));

foreach (var colorChip in __instance.ColorChips)
{
Expand Down
4 changes: 1 addition & 3 deletions TownOfUsReworked/Cosmetics/CustomNameplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ public static bool Prefix(NameplatesTab __instance)
return 500;
});
foreach (var key in keys)
YOffset = CreateNameplatePackage(packages[key], key, YOffset, __instance);
orderedKeys.ToList().ForEach(key => YOffset = CreateHatPackage(packages[key], key, YOffset, __instance));
__instance.scroller.ContentYBounds.max = -(YOffset + 3.8f);
return false;
}
Expand Down
4 changes: 1 addition & 3 deletions TownOfUsReworked/Cosmetics/CustomVisors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ public static bool Prefix(VisorsTab __instance)
return 500;
});
foreach (var key in keys)
YOffset = CreateVisorPackage(packages[key], key, YOffset, __instance);
orderedKeys.ToList().ForEach(key => YOffset = CreateHatPackage(packages[key], key, YOffset, __instance));
__instance.scroller.ContentYBounds.max = -(YOffset + 4.1f);
return false;
}
Expand Down
Loading

0 comments on commit 6bd88f3

Please sign in to comment.