Skip to content

Commit eb436dd

Browse files
committed
Edgeveil Role, 3 New Effects, AssetBundle Update, Bug Fixes & Halloween Lobby
1 parent 0f67e5b commit eb436dd

21 files changed

Lines changed: 520 additions & 35 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using MiraAPI.GameOptions;
2+
using MiraAPI.Hud;
3+
using MiraAPI.Utilities.Assets;
4+
using NewMod.Options.Roles.EdgeveilOptions;
5+
using EV = NewMod.Roles.ImpostorRoles.Edgeveil;
6+
using Rewired;
7+
using UnityEngine;
8+
using NewMod.Components.ScreenEffects;
9+
using NewMod.Utilities;
10+
using Reactor.Utilities;
11+
12+
namespace NewMod.Buttons.Edgeveil
13+
{
14+
/// <summary>
15+
/// Defines a custom action button for Edgeviel's Arc ability.
16+
/// </summary>
17+
public class ArcButton : CustomActionButton
18+
{
19+
/// <summary>
20+
/// The name displayed on the button.
21+
/// </summary>
22+
public override string Name => "Arc";
23+
24+
/// <summary>
25+
/// Gets the cooldown time for this button, based on <see cref="EdgeveilOptions"/>.
26+
/// </summary>
27+
public override float Cooldown => OptionGroupSingleton<EdgeveilOptions>.Instance.SlashCooldown;
28+
29+
/// <summary>
30+
/// Gets the maximum number of uses for this button (0 = infinite).
31+
/// </summary>
32+
public override int MaxUses => (int)OptionGroupSingleton<EdgeveilOptions>.Instance.SlashMaxUses;
33+
34+
/// <summary>
35+
/// Determines how long the effect lasts. For Arc, none.
36+
/// </summary>
37+
public override float EffectDuration => 0f;
38+
39+
/// <summary>
40+
/// Default keybind for Edgeveil's Arc ability.
41+
/// </summary>
42+
public override KeyboardKeyCode Defaultkeybind => KeyboardKeyCode.Q;
43+
44+
/// <summary>
45+
/// Defines where on the screen this button should appear.
46+
/// </summary>
47+
public override ButtonLocation Location => ButtonLocation.BottomLeft;
48+
49+
/// <summary>
50+
/// The visual icon for this button, set to the Edgeveil Arc sprite asset.
51+
/// </summary>
52+
public override LoadableAsset<Sprite> Sprite => NewModAsset.SlashIcon;
53+
54+
/// <summary>
55+
/// Invoked when the Arc button is clicked.
56+
/// </summary>
57+
protected override void OnClick()
58+
{
59+
var player = PlayerControl.LocalPlayer;
60+
61+
bool flipLeft = player.cosmetics.currentBodySprite.BodySprite.flipX;
62+
Vector2 dir = flipLeft ? Vector2.left : Vector2.right;
63+
64+
float spawnOffset = 0.55f;
65+
var spawnPos = player.GetTruePosition() + dir * spawnOffset;
66+
67+
var tray = SlashTray.CreateTray();
68+
tray.transform.SetParent(ShipStatus.Instance.transform, worldPositionStays: true);
69+
tray.transform.SetPositionAndRotation(
70+
new Vector3(spawnPos.x, spawnPos.y, player.transform.position.z),
71+
Quaternion.FromToRotation(Vector3.right, new Vector3(dir.x, dir.y, 0f))
72+
);
73+
74+
tray.Owner = player;
75+
tray.SetMotion(dir, OptionGroupSingleton<EdgeveilOptions>.Instance.SlashSpeed);
76+
77+
float effectDuration = OptionGroupSingleton<EdgeveilOptions>.Instance.EffectDuration;
78+
79+
HudManager.Instance.PlayerCam.ShakeScreen(effectDuration, 2f);
80+
}
81+
/// <summary>
82+
/// Determines whether this button is enabled for the role, returning true if the role is <see cref="EdgevielRole"/>.
83+
/// </summary>
84+
/// <param name="role">The current player's role.</param>
85+
/// <returns>True if the role is Edgeveil; otherwise false.</returns>
86+
public override bool Enabled(RoleBehaviour role)
87+
{
88+
return role is EV;
89+
}
90+
}
91+
}
File renamed without changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using Reactor.Utilities.Attributes;
3+
using UnityEngine;
4+
5+
namespace NewMod.Components.ScreenEffects
6+
{
7+
[RegisterInIl2Cpp]
8+
public class EarthquakeEffect(IntPtr ptr) : MonoBehaviour(ptr)
9+
{
10+
public float amplitude = 2.5f;
11+
public float frequency = 14f;
12+
public float jitter = 0.6f;
13+
public float ghost = 0.3f;
14+
public float warp = 0.015f;
15+
private readonly Shader _shader = NewModAsset.EarthquakeShader.LoadAsset();
16+
private Material _mat;
17+
public void OnEnable()
18+
{
19+
_mat = new Material(_shader) { hideFlags = HideFlags.DontSave };
20+
}
21+
public void OnDisable()
22+
{
23+
Destroy(_mat);
24+
}
25+
public void OnRenderImage(RenderTexture src, RenderTexture dst)
26+
{
27+
_mat.SetFloat("_Amplitude", amplitude);
28+
_mat.SetFloat("_Frequency", frequency);
29+
_mat.SetFloat("_Jitter", jitter);
30+
_mat.SetFloat("_Ghost", ghost);
31+
_mat.SetFloat("_Warp", warp);
32+
Graphics.Blit(src, dst, _mat);
33+
}
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using Reactor.Utilities.Attributes;
3+
using UnityEngine;
4+
5+
namespace NewMod.Components.ScreenEffects
6+
{
7+
[RegisterInIl2Cpp]
8+
public class GlitchEffect(IntPtr ptr) : MonoBehaviour(ptr)
9+
{
10+
public float intensity = 0.45f;
11+
public float blockSize = 64f;
12+
public float colorSplit = 1.2f;
13+
public float scanline = 0.15f;
14+
public float speed = 4f;
15+
private readonly Shader _shader = NewModAsset.GlitchShader.LoadAsset();
16+
public Material _mat;
17+
public void OnEnable()
18+
{
19+
_mat = new Material(_shader) { hideFlags = HideFlags.DontSave };
20+
}
21+
public void OnDisable()
22+
{
23+
Destroy(_mat);
24+
}
25+
public void OnRenderImage(RenderTexture src, RenderTexture dst)
26+
{
27+
_mat.SetFloat("_Intensity", intensity);
28+
_mat.SetFloat("_BlockSize", blockSize);
29+
_mat.SetFloat("_ColorSplit", colorSplit);
30+
_mat.SetFloat("_Scanline", scanline);
31+
_mat.SetFloat("_Speed", speed);
32+
Graphics.Blit(src, dst, _mat);
33+
}
34+
}
35+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using Reactor.Utilities.Attributes;
3+
using UnityEngine;
4+
5+
namespace NewMod.Components.ScreenEffects
6+
{
7+
[RegisterInIl2Cpp]
8+
public class SlowPulseHueEffect(IntPtr ptr) : MonoBehaviour(ptr)
9+
{
10+
public float hueSpeed = 0.35f;
11+
public float saturation = 1.0f;
12+
public float strength = 1.0f;
13+
private readonly Shader _shader = NewModAsset.SlowPulseHueShader.LoadAsset();
14+
private Material _mat;
15+
public void OnEnable()
16+
{
17+
_mat = new Material(_shader) { hideFlags = HideFlags.DontSave };
18+
}
19+
public void OnDisable()
20+
{
21+
Destroy(_mat);
22+
}
23+
24+
public void OnRenderImage(RenderTexture src, RenderTexture dst)
25+
{
26+
_mat.SetFloat("_HueSpeed", hueSpeed);
27+
_mat.SetFloat("_Saturation", saturation);
28+
_mat.SetFloat("_Strength", strength);
29+
Graphics.Blit(src, dst, _mat);
30+
}
31+
}
32+
}

NewMod/Components/SlashTray.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Collections;
3+
using Reactor.Utilities;
4+
using TMPro;
5+
using UnityEngine;
6+
using NewMod;
7+
using NewMod.Utilities;
8+
using Reactor.Utilities.Attributes;
9+
using MiraAPI.Networking;
10+
using MiraAPI.GameOptions;
11+
using NewMod.Options.Roles.EdgeveilOptions;
12+
13+
[RegisterInIl2Cpp]
14+
public class SlashTray(IntPtr ptr) : MonoBehaviour(ptr)
15+
{
16+
public PlayerControl Owner { get; set; }
17+
public SpriteRenderer SlashTrayRend;
18+
public Vector2 _dir;
19+
public float _speed;
20+
public int _kills;
21+
public void Awake()
22+
{
23+
SlashTrayRend = transform.Find("Background").GetComponent<SpriteRenderer>();
24+
var rb = transform.gameObject.AddComponent<Rigidbody2D>();
25+
rb.isKinematic = true;
26+
rb.simulated = true;
27+
}
28+
public static SlashTray CreateTray()
29+
{
30+
var gameObject = Instantiate(NewModAsset.SlashTray.LoadAsset(), HudManager.Instance.transform);
31+
var tray = gameObject.AddComponent<SlashTray>();
32+
return tray;
33+
}
34+
public void Update()
35+
{
36+
transform.position += (Vector3)(_dir * _speed * Time.deltaTime);
37+
}
38+
39+
public void SetMotion(Vector2 dir, float speed)
40+
{
41+
_dir = dir.normalized;
42+
_speed = speed;
43+
}
44+
45+
public void OnTriggerEnter2D(Collider2D other)
46+
{
47+
NewMod.NewMod.Instance.Log.LogMessage($"Hit {other.name}");
48+
var pc = other.GetComponentInParent<PlayerControl>();
49+
if (pc == null) return;
50+
if (pc == Owner) return;
51+
if (pc.Data.IsDead) return;
52+
53+
PlayerControl.LocalPlayer.RpcCustomMurder(pc, teleportMurderer: false);
54+
55+
_kills++;
56+
if (_kills >= (int)OptionGroupSingleton<EdgeveilOptions>.Instance.PlayersToKill)
57+
{
58+
Destroy(gameObject);
59+
}
60+
}
61+
}

NewMod/Components/Toast.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections;
3+
using Reactor.Utilities;
4+
using TMPro;
5+
using UnityEngine;
6+
using Reactor.Utilities.Attributes;
7+
using NewMod;
8+
9+
[RegisterInIl2Cpp]
10+
public class Toast(IntPtr ptr) : MonoBehaviour(ptr)
11+
{
12+
public SpriteRenderer toastRend;
13+
public SpriteRenderer nmLogo;
14+
public TextMeshPro TitleText;
15+
public TextMeshPro Text;
16+
public void Awake()
17+
{
18+
toastRend = transform.Find("Background").GetComponent<SpriteRenderer>();
19+
nmLogo = transform.FindChild("Background/NM").GetComponent<SpriteRenderer>();
20+
TitleText = transform.FindChild("Background/TitleText").GetComponent<TextMeshPro>();
21+
Text = transform.Find("Text").GetComponent<TextMeshPro>();
22+
23+
transform.localScale = new Vector3(0.3f, 0.1636f, 1f);
24+
nmLogo.sortingOrder = 100;
25+
}
26+
public static Toast CreateToast()
27+
{
28+
var gameObject = Instantiate(NewModAsset.Toast.LoadAsset(), HudManager.Instance.transform);
29+
var toast = gameObject.AddComponent<Toast>();
30+
return toast;
31+
}
32+
public void ShowToast(string title, string text, Color color, float displayDuration)
33+
{
34+
if (!LobbyBehaviour.Instance) return;
35+
36+
TitleText.text = title;
37+
Text.text = text;
38+
Text.color = color;
39+
40+
Coroutines.Start(CoAnimateToast(displayDuration));
41+
}
42+
public IEnumerator CoAnimateToast(float duration)
43+
{
44+
Vector3 visiblePos = new Vector3(-0.0527f, 2.7741f, 0f);
45+
Vector3 hiddenPos = visiblePos + new Vector3(0f, 1.5f, 0f);
46+
47+
transform.localPosition = hiddenPos;
48+
49+
float t = 0f;
50+
const float slideTime = 0.4f;
51+
while (t < 1f)
52+
{
53+
t += Time.deltaTime / slideTime;
54+
transform.localPosition = Vector3.Lerp(hiddenPos, visiblePos, Mathf.SmoothStep(0, 1, t));
55+
yield return null;
56+
}
57+
58+
yield return new WaitForSeconds(duration);
59+
60+
t = 0f;
61+
while (t < 1f)
62+
{
63+
t += Time.deltaTime / slideTime;
64+
transform.localPosition = Vector3.Lerp(visiblePos, hiddenPos, Mathf.SmoothStep(0, 1, t));
65+
yield return null;
66+
}
67+
Destroy(gameObject);
68+
}
69+
}

NewMod/DebugWindow.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
using Reactor.Utilities.ImGui;
1414
using Il2CppInterop.Runtime.Attributes;
1515
using AmongUs.GameOptions;
16-
using NewMod.Components;
16+
using NewMod.Components.ScreenEffects;
17+
using Reactor.Utilities;
1718

1819
namespace NewMod
1920
{
@@ -81,6 +82,30 @@ private static bool AllowDebug()
8182
var randPlayer = Utils.GetRandomPlayer(p => !p.Data.IsDead && !p.Data.Disconnected);
8283
MeetingHud.Instance.CmdCastVote(PlayerControl.LocalPlayer.PlayerId, randPlayer.PlayerId);
8384
}
85+
if (GUILayout.Button("End Meeting") && allow && MeetingHud.Instance)
86+
{
87+
MeetingHud.Instance.Close();
88+
}
89+
if (GUILayout.Button("Apply Glitch Effect to Main Camera") && allow)
90+
{
91+
Camera.main.gameObject.AddComponent<GlitchEffect>();
92+
}
93+
if (GUILayout.Button("Apply Earthquake Effect to Main Camera") && allow)
94+
{
95+
Camera.main.gameObject.AddComponent<EarthquakeEffect>();
96+
}
97+
if (GUILayout.Button("Apply Slow Hue Pulse Effect to Main Camera") && allow)
98+
{
99+
Camera.main.gameObject.AddComponent<SlowPulseHueEffect>();
100+
}
101+
if (GUILayout.Button("Reset Camera Effects") && allow)
102+
{
103+
Coroutines.Start(CoroutinesHelper.RemoveCameraEffect(Camera.main, 1f));
104+
}
105+
if (GUILayout.Button("Show Toast") && LobbyBehaviour.Instance)
106+
{
107+
Toast.CreateToast().ShowToast(string.Empty, "NewMod v1.2.6", Color.red, 5f);
108+
}
84109
/*if (GUILayout.Button("Spawn General NPC") && allow)
85110
{
86111
var npc = new GameObject("GeneralNPC").AddComponent<GeneralNPC>();

0 commit comments

Comments
 (0)