Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions ChaosTokens/ChaosTokensRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public enum RpcCalls : uint

public static class ChaosTokensRpc
{
private static int _revealsLeft = (int)OptionGroupSingleton<BalanceOptions>.Instance.MaxRoleReveals;

[MethodRpc((uint)RpcCalls.Roll)]
public static void RpcRoll(this PlayerControl player)
{
Expand Down Expand Up @@ -156,8 +158,6 @@ void Reroll()
}

var playerRole = player.Data.Role;
int revealCount = ModifierUtils.GetPlayersWithModifier<RevealModifier>().Count();

switch (effect)
{
case ChaosEffects.Defense:
Expand Down Expand Up @@ -277,14 +277,14 @@ void Reroll()
Reroll();
break;
}

if (revealCount != 0 && revealCount >= OptionGroupSingleton<BalanceOptions>.Instance.MaxRoleReveals)
if (_revealsLeft <= 0)
{
Reroll();
break;
}

player.RpcAddModifier<TokenReveal>(player.Data.Role.Role, player.Data.PlayerId);
_revealsLeft--;
break;
case ChaosEffects.Death:
if (player.HasModifier<TokenDeath>())
Expand Down Expand Up @@ -326,7 +326,7 @@ void Reroll()
break;
}

if (revealCount != 0 && revealCount >= OptionGroupSingleton<BalanceOptions>.Instance.MaxRoleReveals)
if (_revealsLeft <= 0)
{
Reroll();
break;
Expand All @@ -336,6 +336,7 @@ void Reroll()
.Where(r => r.Team != player.GetTownOfUsRole()?.Team)
.Select(r => (r as RoleBehaviour).Role);
player.RpcAddModifier<TokenReveal>(validRoles.Random(), player.Data.PlayerId);
_revealsLeft--;
break;
case ChaosEffects.Hyperactive:
if (player.HasModifier<TokenHyperactive>())
Expand All @@ -346,10 +347,8 @@ void Reroll()

player.RpcAddModifier<TokenHyperactive>();
break;
/*
case ChaosEffects.Nausea:
Reroll();
break;

if (player.HasModifier<TokenColorblind>() || player.HasModifier<TokenNausea>())
{
Reroll();
Expand All @@ -364,25 +363,20 @@ void Reroll()

player.RpcAddModifier<TokenNausea>();
break;
*/
case ChaosEffects.Colorblind:
if (player.HasModifier<TokenColorblind>() || player.HasModifier<TokenNausea>())
{
Reroll();
break;
}

if (OptionGroupSingleton<BalanceOptions>.Instance.ScreenEffectsDisabled)
{
Reroll();
break;
}

player.RpcAddModifier<TokenColorblind>();
break;


case ChaosEffects.RevealRandom:
if (revealCount != 0 && revealCount >= OptionGroupSingleton<BalanceOptions>.Instance.MaxRoleReveals)
if (_revealsLeft <= 0)
{
Reroll();
break;
Expand All @@ -401,6 +395,7 @@ void Reroll()

var revealVictim = revealVictims.Random();
revealVictim.RpcAddModifier<TokenReveal>(revealVictim.Data.Role.Role, player.PlayerId);
_revealsLeft--;
break;
case ChaosEffects.PositionSwap:
var swapVictim = Helpers.GetAlivePlayers()
Expand Down
31 changes: 29 additions & 2 deletions ChaosTokens/Modifiers/Effects/TokenColorblind.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System.Collections;
using HarmonyLib;
using MiraAPI.Utilities;
using Reactor.Utilities;
using Reactor.Utilities.Extensions;
using TownOfUs.Modifiers.Game.Universal;
using TownOfUs.Roles.Impostor;
using TownOfUs.Utilities;
using TownOfUs.Utilities.Appearances;
using UnityEngine;

namespace ChaosTokens.Modifiers.Effects;
Expand All @@ -19,15 +24,37 @@ public sealed class TokenColorblind : TokenEffect
public override void OnActivate()
{
base.OnActivate();
if (!Player.AmOwner) return;

_filter = Utils.CreatePostprocessFilter(Assets.ColorblindMaterial.LoadAsset());
Coroutines.Start(CoAnimateFilter(_filter));
Helpers.GetAlivePlayers().Do(p =>
{
if (!p.AmOwner)
{
p.cosmetics.nameText.gameObject.SetActive(false);
p.cosmetics.colorBlindText.gameObject.SetActive(false);
}
});
}

public override void OnDeactivate()
{
base.OnDeactivate();
_filter.gameObject.DestroyImmediate();
_filter = null;
if (Player.AmOwner)
{
_filter.gameObject.DestroyImmediate();
_filter = null;
Helpers.GetAlivePlayers().Do(p =>
{
if (Player.GetAppearanceType() != TownOfUsAppearances.Swooper &&
Player.GetAppearanceType() != TownOfUsAppearances.Camouflage)
{
p.cosmetics.nameText.gameObject.SetActive(true);
p.cosmetics.colorBlindText.gameObject.SetActive(true);
}
});
}
}

private IEnumerator CoAnimateFilter(SpriteRenderer rend)
Expand Down
1 change: 1 addition & 0 deletions ChaosTokens/Modifiers/Effects/TokenReveal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public override void OnActivate()
base.OnActivate();

FakeReveal = !Player.Is(role);
AdditionalModifier.RevealSource = MiscUtils.PlayerById(source);

if (Player.AmOwner && FakeReveal)
{
Expand Down
2 changes: 2 additions & 0 deletions ChaosTokens/Options/BalanceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public class BalanceOptions : AbstractOptionGroup
[ModdedToggleOption("Disable Revival")]
public bool ReviveDisabled { get; set; } = false;

/*
[ModdedToggleOption("Disable Screen Effects")]
public bool ScreenEffectsDisabled { get; set; } = false;
*/

[ModdedNumberOption("Max Role Reveals", 0, 15, zeroInfinity: true)]
public float MaxRoleReveals { get; set; } = 0;
Expand Down