Skip to content

Commit

Permalink
v0.6.0 Source
Browse files Browse the repository at this point in the history
  • Loading branch information
AlchlcDvl committed Nov 1, 2023
1 parent 1797a31 commit deef201
Show file tree
Hide file tree
Showing 125 changed files with 4,710 additions and 4,185 deletions.
Binary file added Images/Herbalist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Hunted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Hunter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Runner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,649 changes: 1,344 additions & 1,305 deletions README.md

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions TownOfUsReworked/BetterMaps/BetterAirship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ static class Repositioning
{
public static void Postfix()
{
if (!CustomGameOptions.EnableBetterAirship)
return;

var adminTable = UObject.FindObjectOfType<MapConsole>();

if (CustomGameOptions.MoveAdmin != 0)
Expand Down Expand Up @@ -94,6 +97,9 @@ public static bool Prefix(SpawnInMinigame __instance)
}
}

if (!CustomGameOptions.EnableBetterAirship)
return true;

if (!GameStarted && CustomGameOptions.SpawnType != AirshipSpawnType.Meeting)
{
GameStarted = true;
Expand Down Expand Up @@ -146,12 +152,15 @@ static class GameEndedPatch
public static void Prefix() => GameStarted = false;
}

[HarmonyPatch(typeof(HeliSabotageSystem), nameof(HeliSabotageSystem.RepairDamage))]
[HarmonyPatch(typeof(HeliSabotageSystem), nameof(HeliSabotageSystem.UpdateSystem))]
public static class HeliCountdownPatch
{
public static bool Prefix(HeliSabotageSystem __instance, ref byte amount)
public static bool Prefix(HeliSabotageSystem __instance, ref MessageReader msgReader)
{
if ((HeliSabotageSystem.Tags)(amount & 240) == HeliSabotageSystem.Tags.DamageBit)
if (!CustomGameOptions.EnableBetterAirship)
return true;

if ((HeliSabotageSystem.Tags)(msgReader.ReadByte() & 240) == HeliSabotageSystem.Tags.DamageBit)
{
__instance.Countdown = CustomGameOptions.CrashTimer;
HeliSabotageSystem.CharlesDuration = CustomGameOptions.CrashTimer;
Expand Down
43 changes: 43 additions & 0 deletions TownOfUsReworked/BetterMaps/BetterFungle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace TownOfUsReworked.BetterMaps;

[HarmonyPatch(typeof(ReactorSystemType), nameof(ReactorSystemType.UpdateSystem))]
public static class ReactorFungle
{
public static bool Prefix(ReactorSystemType __instance, ref MessageReader msgReader)
{
if (!CustomGameOptions.EnableBetterFungle)
return true;

if (ShipStatus.Instance.Type == ShipStatus.MapType.Fungle && msgReader.ReadByte() == 128 && !__instance.IsActive)
{
__instance.Countdown = __instance.ReactorDuration = CustomGameOptions.FungleReactorTimer;
__instance.UserConsolePairs.Clear();
__instance.IsDirty = true;
return false;
}

return true;
}
}

[HarmonyPatch(typeof(MushroomMixupSabotageSystem), nameof(MushroomMixupSabotageSystem.UpdateSystem))]
public static class MushroomFungle
{
public static bool Prefix(MushroomMixupSabotageSystem __instance, ref MessageReader msgReader)
{
if (!CustomGameOptions.EnableBetterFungle)
return true;

if ((MushroomMixupSabotageSystem.Operation)msgReader.ReadByte() == MushroomMixupSabotageSystem.Operation.TriggerSabotage && !__instance.IsActive)
{
__instance.Host_GenerateRandomOutfits();
__instance.MushroomMixUp();
__instance.currentState = MushroomMixupSabotageSystem.State.JustTriggered;
__instance.secondsForAutoHeal = __instance.currentSecondsUntilHeal = CustomGameOptions.FungleMixupTimer;
__instance.IsDirty = true;
return false;
}

return true;
}
}
30 changes: 20 additions & 10 deletions TownOfUsReworked/BetterMaps/BetterMiraHQ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public static void Prefix(ShipStatus __instance)

public static void Postfix(ShipStatus __instance)
{
if (!CustomGameOptions.EnableBetterMiraHQ)
return;

if (!IsVentModified && __instance.Type == ShipStatus.MapType.Hq)
{
CommsVent.Id = GetAvailableId();
Expand All @@ -57,6 +60,9 @@ public static void Postfix(ShipStatus __instance)

private static void ApplyChanges(ShipStatus __instance)
{
if (!CustomGameOptions.EnableBetterMiraHQ)
return;

if (__instance.Type == ShipStatus.MapType.Hq)
{
FindRooms();
Expand Down Expand Up @@ -187,15 +193,17 @@ private static void MoveCommsVent()
}
}

[HarmonyPatch(typeof(ReactorSystemType), nameof(ReactorSystemType.RepairDamage))]
[HarmonyPatch(typeof(ReactorSystemType), nameof(ReactorSystemType.UpdateSystem))]
public static class ReactorMira
{
public static bool Prefix(ReactorSystemType __instance, ref byte opCode)
public static bool Prefix(ReactorSystemType __instance, ref MessageReader msgReader)
{
if (ShipStatus.Instance.Type == ShipStatus.MapType.Hq && opCode == 128 && !__instance.IsActive)
if (!CustomGameOptions.EnableBetterMiraHQ)
return true;

if (ShipStatus.Instance.Type == ShipStatus.MapType.Hq && msgReader.ReadByte() == 128 && !__instance.IsActive)
{
__instance.Countdown = CustomGameOptions.MiraReactorTimer;
__instance.ReactorDuration = CustomGameOptions.MiraReactorTimer;
__instance.Countdown = __instance.ReactorDuration = CustomGameOptions.MiraReactorTimer;
__instance.UserConsolePairs.Clear();
__instance.IsDirty = true;
return false;
Expand All @@ -205,15 +213,17 @@ public static bool Prefix(ReactorSystemType __instance, ref byte opCode)
}
}

[HarmonyPatch(typeof(LifeSuppSystemType), nameof(LifeSuppSystemType.RepairDamage))]
[HarmonyPatch(typeof(LifeSuppSystemType), nameof(LifeSuppSystemType.UpdateSystem))]
public static class O2Mira
{
public static bool Prefix(LifeSuppSystemType __instance, ref byte opCode)
public static bool Prefix(LifeSuppSystemType __instance, ref MessageReader msgReader)
{
if (ShipStatus.Instance.Type == ShipStatus.MapType.Hq && opCode == 128 && !__instance.IsActive)
if (!CustomGameOptions.EnableBetterMiraHQ)
return true;

if (ShipStatus.Instance.Type == ShipStatus.MapType.Hq && msgReader.ReadByte() == 128 && !__instance.IsActive)
{
__instance.Countdown = CustomGameOptions.MiraO2Timer;
__instance.LifeSuppDuration = CustomGameOptions.MiraO2Timer;
__instance.Countdown = __instance.LifeSuppDuration = CustomGameOptions.MiraO2Timer;
__instance.CompletedConsoles.Clear();
__instance.IsDirty = true;
return false;
Expand Down
70 changes: 65 additions & 5 deletions TownOfUsReworked/BetterMaps/BetterPolus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public static void Prefix(ShipStatus __instance)

public static void Postfix(ShipStatus __instance)
{
if (!CustomGameOptions.EnableBetterPolus)
return;

if (!IsVentModified && __instance.Type == ShipStatus.MapType.Pb)
{
SpeciVent.Id = GetAvailableId();
Expand All @@ -73,6 +76,9 @@ public static void Postfix(ShipStatus __instance)

private static void ApplyChanges(ShipStatus __instance)
{
if (!CustomGameOptions.EnableBetterPolus)
return;

if (__instance.Type == ShipStatus.MapType.Pb)
{
FindPolusObjects();
Expand Down Expand Up @@ -291,20 +297,74 @@ private static void MoveVitals()
}
}

[HarmonyPatch(typeof(ReactorSystemType), nameof(ReactorSystemType.RepairDamage))]
[HarmonyPatch(typeof(ReactorSystemType), nameof(ReactorSystemType.UpdateSystem))]
public static class Seismic
{
public static bool Prefix(ReactorSystemType __instance, ref byte opCode)
public static bool Prefix(ReactorSystemType __instance, ref MessageReader msgReader)
{
if (ShipStatus.Instance.Type == ShipStatus.MapType.Pb && opCode == 128 && !__instance.IsActive)
if (!CustomGameOptions.EnableBetterPolus)
return true;

if (ShipStatus.Instance.Type == ShipStatus.MapType.Pb && msgReader.ReadByte() == 128 && !__instance.IsActive)
{
__instance.Countdown = CustomGameOptions.SeismicTimer;
__instance.ReactorDuration = CustomGameOptions.SeismicTimer;
__instance.Countdown = __instance.ReactorDuration = CustomGameOptions.SeismicTimer;
__instance.UserConsolePairs.Clear();
__instance.IsDirty = true;
return false;
}

return true;
}
}

[HarmonyPatch(typeof(NormalPlayerTask), nameof(NormalPlayerTask.AppendTaskText))]
public static class NormalPlayerTaskPatches
{
public static bool Prefix(NormalPlayerTask __instance, Il2CppSystem.Text.StringBuilder sb)
{
if (!CustomGameOptions.EnableBetterPolus || !ShipStatus.Instance || ShipStatus.Instance.Type != ShipStatus.MapType.Pb || __instance.TaskType is not (TaskTypes.RebootWifi or
TaskTypes.RecordTemperature or TaskTypes.ChartCourse))
{
return true;
}

var flag = __instance.ShouldYellowText();

if (flag)
sb.Append(__instance.IsComplete ? "<color=#00DD00FF>" : "<color=#FFFF00FF>");

var room = GetUpdatedRoom(__instance);
sb.Append(TranslationController.Instance.GetString(room));
sb.Append(": ");
sb.Append(TranslationController.Instance.GetString(__instance.TaskType));

if (__instance is { ShowTaskTimer: true, TimerStarted: NormalPlayerTask.TimerState.Started })
{
sb.Append(" (");
sb.Append(TranslationController.Instance.GetString(StringNames.SecondsAbbv, (int)__instance.TaskTimer));
sb.Append(')');
}
else if (__instance.ShowTaskStep)
{
sb.Append(" (");
sb.Append(__instance.taskStep);
sb.Append('/');
sb.Append(__instance.MaxStep);
sb.Append(')');
}

if (flag)
sb.Append("</color>");

sb.AppendLine();
return false;
}

private static SystemTypes GetUpdatedRoom(NormalPlayerTask task) => task.TaskType switch
{
TaskTypes.RecordTemperature => SystemTypes.Outside,
TaskTypes.RebootWifi => SystemTypes.Dropship,
TaskTypes.ChartCourse => SystemTypes.Comms,
_ => task.StartAt
};
}
29 changes: 18 additions & 11 deletions TownOfUsReworked/BetterMaps/BetterSkeld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public static void Prefix(ShipStatus __instance)

private static void ApplyChanges(ShipStatus __instance)
{
if (__instance.Type == ShipStatus.MapType.Ship)
if (!CustomGameOptions.EnableBetterSkeld)
return;

if (__instance.Type == ShipStatus.MapType.Ship && MapPatches.CurrentMap != 3)
{
FindVents();
AdjustSkeld();
Expand Down Expand Up @@ -165,15 +168,17 @@ private static void MoveCafeVent()
}
}

[HarmonyPatch(typeof(ReactorSystemType), nameof(ReactorSystemType.RepairDamage))]
[HarmonyPatch(typeof(ReactorSystemType), nameof(ReactorSystemType.UpdateSystem))]
public static class ReactorSkeld
{
public static bool Prefix(ReactorSystemType __instance, ref byte opCode)
public static bool Prefix(ReactorSystemType __instance, ref MessageReader msgReader)
{
if (ShipStatus.Instance.Type == ShipStatus.MapType.Ship && opCode == 128 && !__instance.IsActive)
if (!CustomGameOptions.EnableBetterSkeld)
return true;

if (ShipStatus.Instance.Type == ShipStatus.MapType.Ship && msgReader.ReadByte() == 128 && !__instance.IsActive)
{
__instance.Countdown = CustomGameOptions.SkeldReactorTimer;
__instance.ReactorDuration = CustomGameOptions.SkeldReactorTimer;
__instance.Countdown = __instance.ReactorDuration = CustomGameOptions.SkeldReactorTimer;
__instance.UserConsolePairs.Clear();
__instance.IsDirty = true;
return false;
Expand All @@ -183,15 +188,17 @@ public static bool Prefix(ReactorSystemType __instance, ref byte opCode)
}
}

[HarmonyPatch(typeof(LifeSuppSystemType), nameof(LifeSuppSystemType.RepairDamage))]
[HarmonyPatch(typeof(LifeSuppSystemType), nameof(LifeSuppSystemType.UpdateSystem))]
public static class O2Skeld
{
public static bool Prefix(LifeSuppSystemType __instance, ref byte opCode)
public static bool Prefix(LifeSuppSystemType __instance, ref MessageReader msgReader)
{
if (ShipStatus.Instance.Type == ShipStatus.MapType.Ship && opCode == 128 && !__instance.IsActive)
if (!CustomGameOptions.EnableBetterSkeld)
return true;

if (ShipStatus.Instance.Type == ShipStatus.MapType.Ship && msgReader.ReadByte() == 128 && !__instance.IsActive)
{
__instance.Countdown = CustomGameOptions.SkeldO2Timer;
__instance.LifeSuppDuration = CustomGameOptions.SkeldO2Timer;
__instance.Countdown = __instance.LifeSuppDuration = CustomGameOptions.SkeldO2Timer;
__instance.CompletedConsoles.Clear();
__instance.IsDirty = true;
return false;
Expand Down
6 changes: 3 additions & 3 deletions TownOfUsReworked/Classes/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ public static Sprite GetSprite(string path)
{
if (!Sprites.ContainsKey(path))
{
LogError($"{path} does not exist");
//LogError($"{path} does not exist");
return Meeting ? Sprites["MeetingPlaceholder"] : Sprites["Placeholder"];
}

return Sprites[path];
}

public static void Play(string path, bool loop = false)
public static void Play(string path, bool loop = false, float volume = 1f)
{
try
{
Stop(path);

if (Constants.ShouldPlaySfx())
SoundManager.Instance.PlaySound(GetAudio(path), loop);
SoundManager.Instance.PlaySound(GetAudio(path), loop, volume);
}
catch
{
Expand Down
Loading

0 comments on commit deef201

Please sign in to comment.