Skip to content

Commit e4d09f2

Browse files
committed
Bug Fixes
1 parent 8fdf45d commit e4d09f2

6 files changed

Lines changed: 43 additions & 47 deletions

File tree

NewMod/Buttons/Visionary/CaptureButton.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected override void OnClick()
5757
{
5858
var timestamp = System.DateTime.UtcNow.ToString("yyyy-MM-dd_HH-mm-ss");
5959
string path = Path.Combine(VisionaryUtilities.ScreenshotDirectory, $"screenshot_{timestamp}.png");
60+
NewMod.Instance.Log.LogMessage($"Screenshot will be saved to: {path}");
6061
Coroutines.Start(Utils.CaptureScreenshot(path));
6162
}
6263

NewMod/Components/ScreenEffects/ShadowFluxEffect.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,26 @@ namespace NewMod.Components.ScreenEffects
77
[RegisterInIl2Cpp]
88
public class ShadowFluxEffect(IntPtr ptr) : MonoBehaviour(ptr)
99
{
10-
public Texture2D texture = NewModAsset.NoiseTex.LoadAsset();
1110
public float noiseScale = 2f;
1211
public float speed = 0.3f;
1312
public float edgeWidth = 0.25f;
1413
public float threshold = 0.55f;
1514
public float opacity = 0.75f;
1615
public float darkness = 0.8f;
1716
public Color tint = Color.white;
18-
public static Shader _shader = NewModAsset.ShadowFluxShader.LoadAsset();
1917
public Material _mat;
2018

2119
public void OnEnable()
2220
{
23-
_mat = new Material(_shader) { hideFlags = HideFlags.DontSave };
21+
var shader = NewModAsset.ShadowFluxShader.LoadAsset();
22+
var texture = NewModAsset.NoiseTex.LoadAsset();
23+
24+
if (shader == null)
25+
{
26+
NewMod.Instance.Log.LogError("ShadowFluxEffect - Shader null");
27+
}
28+
29+
_mat = new Material(shader) { hideFlags = HideFlags.DontSave };
2430
_mat.SetTexture("_NoiseTex", texture);
2531
}
2632
public void OnDisable()

NewMod/Components/ShadowZone.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public void Update()
5454
if (active && lp.PlayerId == shadeId)
5555
{
5656
lp.cosmetics.SetPhantomRoleAlpha(1);
57+
lp.cosmetics.ToggleHat(true);
58+
lp.cosmetics.ToggleVisor(true);
59+
lp.cosmetics.TogglePet(true);
5760
lp.cosmetics.nameText.gameObject.SetActive(true);
5861

5962
if (killButton.currentTarget)
@@ -83,6 +86,9 @@ public void Update()
8386
if (mode is ShadeOptions.ShadowMode.Invisible or ShadeOptions.ShadowMode.Both)
8487
{
8588
lp.cosmetics.SetPhantomRoleAlpha(0);
89+
lp.cosmetics.ToggleHat(false);
90+
lp.cosmetics.ToggleVisor(false);
91+
lp.cosmetics.TogglePet(false);
8692
lp.cosmetics.nameText.gameObject.SetActive(false);
8793
}
8894

@@ -122,6 +128,9 @@ public void Update()
122128
if (lp.PlayerId == shadeId)
123129
{
124130
lp.cosmetics.SetPhantomRoleAlpha(1);
131+
lp.cosmetics.ToggleHat(true);
132+
lp.cosmetics.TogglePet(false);
133+
lp.cosmetics.ToggleVisor(false);
125134
lp.cosmetics.nameText.gameObject.SetActive(true);
126135

127136
if (killButton.currentTarget)

NewMod/Patches/HudPatch.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

NewMod/Utilities/Utils.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using NewMod.Roles;
2626
using NewMod.Components;
2727
using NewMod.Buttons.WraithCaller;
28+
using System.IO;
2829

2930
namespace NewMod.Utilities
3031
{
@@ -799,8 +800,11 @@ public static IEnumerator CaptureScreenshot(string filePath)
799800

800801
HudManager.Instance.SetHudActive(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer.Data.Role, false);
801802
SoundManager.Instance.PlaySound(clip, false, 1f, null);
802-
ScreenCapture.CaptureScreenshot(filePath, 4);
803-
NewMod.Instance.Log.LogInfo($"Capturing screenshot at {System.IO.Path.GetFileName(filePath)}.");
803+
yield return new WaitForEndOfFrame();
804+
var tex = ScreenCapture.CaptureScreenshotAsTexture(4);
805+
File.WriteAllBytes(filePath, tex.EncodeToPNG());
806+
Object.Destroy(tex);
807+
NewMod.Instance.Log.LogInfo($"Capturing screenshot at {Path.GetFileName(filePath)}.");
804808

805809
yield return new WaitForSeconds(0.2f);
806810

@@ -829,10 +833,6 @@ public static IEnumerator StartFeignDeath(PlayerControl player)
829833

830834
SoundManager.Instance.PlaySound(clip, false, 1f, null);
831835

832-
if (player.AmOwner)
833-
{
834-
HudManager.Instance.SetHudActive(player, player.Data.Role, false);
835-
}
836836
yield return new WaitForSeconds(0.5f);
837837

838838
var body = player.GetNearestDeadBody(15f);
@@ -847,6 +847,11 @@ public static IEnumerator StartFeignDeath(PlayerControl player)
847847

848848
Coroutines.Start(CoroutinesHelper.CoNotify("<color=green>You are now feigning death.\nYou will be revived in 10 seconds if unreported.</color>"));
849849

850+
if (player.AmOwner)
851+
{
852+
HudManager.Instance.SetHudActive(player, player.Data.Role, false);
853+
}
854+
850855
float timer = 10f;
851856
while (timer > 0)
852857
{

NewMod/Utilities/VisionaryUtilities.cs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
43
using System.Collections;
54
using UnityEngine;
@@ -33,11 +32,21 @@ public static string ScreenshotDirectory
3332
{
3433
get
3534
{
36-
string directory = OperatingSystem.IsAndroid() ? Environment.GetEnvironmentVariable("STAR_DATA_PATH") : Path.Combine(Application.persistentDataPath, "NewMod", "Screenshots");
37-
if (!Directory.Exists(directory))
35+
string basePath;
36+
37+
if (OperatingSystem.IsAndroid())
38+
{
39+
basePath = Environment.GetEnvironmentVariable("STAR_DATA_PATH")!;
40+
}
41+
else
3842
{
39-
Directory.CreateDirectory(directory);
43+
basePath = Application.persistentDataPath;
4044
}
45+
46+
string directory = Path.Combine(basePath, "NewMod", "Screenshots");
47+
48+
Directory.CreateDirectory(directory);
49+
4150
return directory;
4251
}
4352
}
@@ -151,25 +160,6 @@ public static IEnumerator ShowScreenshot(Sprite sprite, DateTime timestamp, floa
151160
_showing = false;
152161
}
153162

154-
// <summary>
155-
/// Loads and displays a screenshot from a given file path.
156-
/// If the file does not exist, no action is taken.
157-
/// </summary>
158-
/// <param name="filePath">The full path of the screenshot file to display.</param>
159-
/// <param name="displayDuration">The duration, in seconds, to display the screenshot.</param>
160-
/// <returns>An IEnumerator coroutine for handling display.</returns>
161-
public static IEnumerator ShowScreenshotByPath(string filePath, float displayDuration)
162-
{
163-
if (!File.Exists(filePath)) yield break;
164-
165-
byte[] data = File.ReadAllBytes(filePath);
166-
Texture2D tex = new(2, 2);
167-
tex.LoadImage(data);
168-
Sprite screenshotSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
169-
170-
yield return ShowScreenshot(screenshotSprite, File.GetCreationTime(filePath), displayDuration);
171-
}
172-
173163
/// <summary>
174164
/// Deletes all screenshots from the Visionary screenshot directory.
175165
/// </summary>

0 commit comments

Comments
 (0)