Skip to content

Commit

Permalink
Update to 2024.6.18
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Jul 31, 2024
1 parent 6dc6584 commit 30ea314
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 105 deletions.
7 changes: 0 additions & 7 deletions Laboratory.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Laboratory", "Laboratory\Laboratory.csproj", "{790E5540-7655-4F57-BBED-8D644A031BC6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{095ED6FA-D3D6-4104-8322-EDD1CCCBBD30}"
ProjectSection(SolutionItems) = preProject
nuget.config = nuget.config
.github\workflows\main.yml = .github\workflows\main.yml
build.cake = build.cake
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
14 changes: 7 additions & 7 deletions Laboratory/Debugging/GeneralTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void BuildUI()
Screen.SetResolution(2560, 1080, true);
ResolutionManager.SetResolution(2560, 1080, true);
}

if (CameraZoomController.Instance != null)
{
GUILayout.Label($"Camera Zoom: {CameraZoomController.Instance.OrthographicSize}");
Expand All @@ -35,7 +35,7 @@ public override void BuildUI()
var shouldRunOg = ProgressSystem.Instance.ShouldRun;
var newShouldRun = GUILayout.Toggle(shouldRunOg, $"Progress Bar: {(ProgressSystem.Instance.ShouldRun ? "Running" : "Stopped")}", GUI.skin.button);
if (newShouldRun != shouldRunOg) ProgressSystem.Instance.ShouldRun = newShouldRun;

float timer = GUILayout.HorizontalSlider(ProgressSystem.Instance.Timer, 0, ProgressSystem.Instance.TotalTime + 0.0001f);
if (Math.Abs(timer - ProgressSystem.Instance.Timer) > 0.001f)
{
Expand All @@ -44,7 +44,7 @@ public override void BuildUI()
}
}
}

if (HealthSystem.Instance != null)
{
GUILayout.Label("Max Health: " + HealthSystem.MaxHealth);
Expand All @@ -55,26 +55,26 @@ public override void BuildUI()
{
HealthSystem.MaxHealth = maxHealth;
}

if (GUILayout.Button("Save Current Health"))
{
foreach (GameData.PlayerInfo instanceAllPlayer in GameData.Instance.AllPlayers)
foreach (NetworkedPlayerInfo instanceAllPlayer in GameData.Instance.AllPlayers)
{
OldHealths[instanceAllPlayer.PlayerName] = Math.Clamp(HealthSystem.Instance.GetHealth(instanceAllPlayer.PlayerId), 1, 999999);
}
}

if (GUILayout.Button("Load Old Health"))
{
foreach (GameData.PlayerInfo instanceAllPlayer in GameData.Instance.AllPlayers)
foreach (NetworkedPlayerInfo instanceAllPlayer in GameData.Instance.AllPlayers)
{
if (OldHealths.TryGetValue(instanceAllPlayer.PlayerName, out int health))
{
HealthSystem.Instance.SetHealth(instanceAllPlayer.PlayerId, health);
}
}
}

AllowDeath = GUILayout.Toggle(AllowDeath, "Allow Death When Changing Health");

List<(byte playerId, int newHealth)> list = new();
Expand Down
16 changes: 7 additions & 9 deletions Laboratory/Debugging/Patches/RoleManager_Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Linq;
using AmongUs.GameOptions;
using HarmonyLib;
using Il2CppSystem;
using Laboratory.Extensions;

namespace Laboratory.Debugging.Patches;

Expand All @@ -16,18 +14,18 @@ public static bool Prefix()
{
if (!ForceImpostorTab.Enabled) return true;

List<GameData.PlayerInfo> list = GameData.Instance.AllPlayers.ToArray().Where(pcd => !pcd.Disconnected && !pcd.IsDead).ToList();
List<GameData.PlayerInfo> impostors = new();
List<NetworkedPlayerInfo> list = GameData.Instance.AllPlayers.ToArray().Where(pcd => !pcd.Disconnected && !pcd.IsDead).ToList();
List<NetworkedPlayerInfo> impostors = new();

foreach (string name in ForceImpostorTab.CurrentlySelected)
{
GameData.PlayerInfo match = list.FirstOrDefault(p => p.PlayerName == name);
NetworkedPlayerInfo match = list.FirstOrDefault(p => p.PlayerName == name);
if (match == null || match.Disconnected) continue;
impostors.Add(match);
}
List<GameData.PlayerInfo> crew = list.Where(e => !impostors.Contains(e)).ToList();

List<NetworkedPlayerInfo> crew = list.Where(e => !impostors.Contains(e)).ToList();

foreach (var playerInfo in impostors)
{
playerInfo.Object.RpcSetRole(RoleTypes.Impostor);
Expand All @@ -39,4 +37,4 @@ public static bool Prefix()
}
return false;
}
}
}
44 changes: 22 additions & 22 deletions Laboratory/HUDMap/CustomMapBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ public CustomMapBehaviour(IntPtr ptr) : base(ptr) { }
public MouseClickEvent MouseUpEvent { [HideFromIl2Cpp] get; [HideFromIl2Cpp] set; }

public Action DisableEvent { [HideFromIl2Cpp] get; [HideFromIl2Cpp] set; }
private Dictionary<GameData.PlayerInfo, SpriteRenderer> HerePoints { [HideFromIl2Cpp] get; } = new();

private Dictionary<NetworkedPlayerInfo, SpriteRenderer> HerePoints { [HideFromIl2Cpp] get; } = new();

public MapBehaviour Parent { get; set; }

public void ShowAllPlayers()
{
foreach ((GameData.PlayerInfo _, SpriteRenderer value) in HerePoints)
foreach ((NetworkedPlayerInfo _, SpriteRenderer value) in HerePoints)
{
Destroy(value.gameObject);
}
HerePoints.Clear();
if (Parent == null) return;
foreach (GameData.PlayerInfo player in GameData.Instance.AllPlayers)
foreach (NetworkedPlayerInfo player in GameData.Instance.AllPlayers)
{
if (player.Disconnected) continue;
Transform hereTransform = Parent.HerePoint.transform;

GameObject newHerePoint = Instantiate(Parent.HerePoint.gameObject, hereTransform.parent, true);
newHerePoint.transform.localScale = hereTransform.localScale;

SpriteRenderer newHerePointRend = newHerePoint.GetComponent<SpriteRenderer>();
if (player.Object) player.Object.SetPlayerMaterialColors(newHerePointRend);
HerePoints[player] = newHerePointRend;
Expand All @@ -56,19 +56,19 @@ public static void ShowWithAllPlayers(Color mapColor, MouseClickEvent mouseUpEve
return;
}
if (HudManager.Instance.IsIntroDisplayed) return;

if (!ShipStatus.Instance) return;

HudManager.Instance.InitMap();

var action = (Action<MapBehaviour>)(map =>
{
if (map.IsOpen)
{
map.Close();
return;
}

map.countOverlay.gameObject.SetActive(false);
map.infectedOverlay.gameObject.SetActive(false);
map.taskOverlay.Hide();
Expand All @@ -89,7 +89,7 @@ public static void ShowWithAllPlayers(Color mapColor, MouseClickEvent mouseUpEve
instance.MouseUpEvent -= mouseClickEvent;
}
};

var disables = new Action[2];
customMapBehaviour.DisableEvent += disables[0] = () =>
{
Expand All @@ -100,18 +100,18 @@ public static void ShowWithAllPlayers(Color mapColor, MouseClickEvent mouseUpEve
foreach (var disable in disables) customMapBehaviour.DisableEvent -= disable;
};
});

action(MapBehaviour.Instance);
}

[HideFromIl2Cpp]
private Vector2 GetMapPosition(ref bool set, ref Vector2 mapPosition)
{
if (set) return mapPosition;
set = true;

if (Parent == null) return default;

Vector2 offset = ShipStatus.Instance.Type switch
{
ShipStatus.MapType.Ship => new Vector2(-2.3f, -5.4f),
Expand All @@ -121,27 +121,27 @@ private Vector2 GetMapPosition(ref bool set, ref Vector2 mapPosition)
(ShipStatus.MapType) 4 => new Vector2(7.3f, 0.2f),
_ => Vector2.zero
};

Vector2 mousePos = Camera.main!.ScreenToWorldPoint(Input.mousePosition);
Vector2 pointOnMap = Parent.transform.InverseTransformPoint(mousePos);
pointOnMap.x /= Mathf.Sign(ShipStatus.Instance.transform.localScale.x);
pointOnMap *= ShipStatus.Instance.MapScale;
return mapPosition = pointOnMap + offset;
}

private void Awake()
{
Parent = GetComponent<MapBehaviour>();
}

private void FixedUpdate()
{
if (!ShipStatus.Instance)
{
return;
}

foreach ((GameData.PlayerInfo data, SpriteRenderer rend) in HerePoints)
foreach ((NetworkedPlayerInfo data, SpriteRenderer rend) in HerePoints)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (data == null || !data.Object || data.IsDead || data.Disconnected)
Expand All @@ -157,14 +157,14 @@ private void FixedUpdate()
rend.transform.localPosition = vector;
}
}

private void Update()
{
var mapPosition = Vector2.zero;
var mapPositionSet = false;

if (MouseDownEvent != null) InvokeEvent(MouseDownEvent);
if (MouseHeldEvent != null) InvokeEvent(MouseHeldEvent);
if (MouseHeldEvent != null) InvokeEvent(MouseHeldEvent);
if (MouseUpEvent != null) InvokeEvent(MouseUpEvent);
return;

Expand All @@ -176,7 +176,7 @@ void InvokeEvent(MouseClickEvent mouseEvent)
if (Input.GetMouseButtonDown(2)) mouseEvent(this, 2, GetMapPosition(ref mapPositionSet, ref mapPosition));
}
}

private void OnDisable()
{
DisableEvent?.Invoke();
Expand All @@ -186,4 +186,4 @@ private void OnDisable()
}
HerePoints.Clear();
}
}
}
14 changes: 5 additions & 9 deletions Laboratory/Laboratory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<LangVersion>10</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>embedded</DebugType>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
Expand All @@ -23,20 +23,16 @@
<None Update="**\Resources\**\*.manifest">
<DependentUpon>%(Filename)</DependentUpon>
</None>

<None Update="packages.lock.json" Visible="false" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2023.11.28" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.6.18" />
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.679" />
<PackageReference Include="Reactor" Version="2.2.0-ci.238" />
</ItemGroup>

<ItemGroup>
<Folder Include="Effects\EffectBuilder\" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.688" />
<PackageReference Include="Reactor" Version="2.2.0-ci.271" />
</ItemGroup>

<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
Expand Down
1 change: 0 additions & 1 deletion Laboratory/LaboratoryPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
global using static Reactor.Utilities.Logger<Laboratory.LaboratoryPlugin>;
using System.Collections.Generic;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
Expand Down
10 changes: 6 additions & 4 deletions Laboratory/Patches/DebugKeybinds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public static void NoEffect(PlayerControl player)
{
GlobalEffectManager.Instance.PrimaryEffect = null;
}
catch (Exception e)
catch
{
// ignored
}

GlobalEffectManager.Instance._primaryEffect = null;
Expand All @@ -35,14 +36,15 @@ public static void NoEffect(PlayerControl player)
{
effectManager.PrimaryEffect = null;
}
catch (Exception e)
catch
{
// ignored
}

effectManager._primaryEffect = null;
}
}

[MethodRpc((uint)CustomRPCs.HardReset)]
public static void HardReset(PlayerControl player)
{
Expand Down Expand Up @@ -106,7 +108,7 @@ public static void Postfix(KeyboardJoystick __instance)
{
HardReset(PlayerControl.LocalPlayer);
}

if (Input.GetKey(KeyCode.F2) && Input.GetKeyDown(KeyCode.F4) || Input.GetKey(KeyCode.F4) && Input.GetKeyDown(KeyCode.F2))
{
HardReset(PlayerControl.LocalPlayer);
Expand Down
13 changes: 2 additions & 11 deletions Laboratory/Patches/GameSettingsPatches.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using UnityEngine;

namespace Laboratory.Patches;

Expand All @@ -15,18 +13,11 @@ public static bool DisableOptionsWhenNotHostPatch(OptionBehaviour __instance)
__instance.GetComponentsInChildren<PassiveButton>().Do(t => t.enabled = false);
return false;
}

[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.OnEnable))]
[HarmonyPrefix]
public static void ShowAdditionalOptionsPatch(GameSettingMenu __instance)
{
__instance.HideForOnline = new Il2CppReferenceArray<Transform>(0);
}


[HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))]
[HarmonyPrefix]
public static void ChatMessagesRatePatch(ChatController __instance)
{
__instance.timeSinceLastMessage = 5;
}
}
}
Loading

0 comments on commit 30ea314

Please sign in to comment.