Skip to content

Commit

Permalink
Merge branch 'coreclr'
Browse files Browse the repository at this point in the history
  • Loading branch information
Galster-dev committed Nov 28, 2022
2 parents 5a94455 + ea37c00 commit eb36235
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 54 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.x

Expand All @@ -21,7 +21,7 @@ jobs:
with:
verbosity: Diagnostic

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: CrowdedMod.dll
path: src/CrowdedMod/bin/Release/netstandard2.1/CrowdedMod.dll
path: src/CrowdedMod/bin/Release/net6.0/CrowdedMod.dll
4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Task("Build")
settings.VersionSuffix = "ci." + buildId;
}

foreach (var gamePlatform in new[] { "Steam", "Itch" })
foreach (var gamePlatform in new[] { "Steam" })
{
settings.MSBuildSettings.Properties["GamePlatform"] = new[] { gamePlatform };
DotNetCoreBuild("src", settings);
DotNetBuild("src", settings);
}
});

Expand Down
10 changes: 5 additions & 5 deletions src/CrowdedMod/Components/AbstractPagingBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace CrowdedMod.Components;
// Interface until unhollower implements generic il2cpp (if it's possible)
/// <summary>
/// This class is not actually abstract because unhollower does not support it <br/>
/// You need to implement <see cref="OnPageChanged"/> and <see cref="MaxPage"/>
/// You need to implement <see cref="OnPageChanged"/> and <see cref="MaxPageIndex"/>
/// </summary>
public class AbstractPagingBehaviour : MonoBehaviour
{
Expand All @@ -19,7 +19,7 @@ public AbstractPagingBehaviour(IntPtr ptr) : base(ptr)
public virtual int MaxPerPage => 15;
// public virtual IEnumerable<T> Targets { get; }

public virtual int Page
public virtual int PageIndex
{
get => _page;
set
Expand All @@ -29,7 +29,7 @@ public virtual int Page
}
}

public virtual int MaxPage => throw new NotImplementedException();
public virtual int MaxPageIndex => throw new NotImplementedException();
// public virtual int MaxPages => Targets.Count() / MaxPerPage;

public virtual void OnPageChanged() => throw new NotImplementedException();
Expand All @@ -43,11 +43,11 @@ public virtual void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow) || Input.mouseScrollDelta.y > 0f)
{
Page = Mathf.Clamp(Page - 1, 0, MaxPage);
PageIndex = Mathf.Clamp(PageIndex - 1, 0, MaxPageIndex);
}
else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.mouseScrollDelta.y < 0f)
{
Page = Mathf.Clamp(Page + 1, 0, MaxPage);
PageIndex = Mathf.Clamp(PageIndex + 1, 0, MaxPageIndex);
}
}
}
22 changes: 11 additions & 11 deletions src/CrowdedMod/Components/MeetingHudPagingBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Reactor;
using UnhollowerBaseLib.Attributes;
using Il2CppInterop.Runtime.Attributes;
using Reactor.Utilities.Attributes;
using UnityEngine;

namespace CrowdedMod.Components;
Expand All @@ -14,39 +14,39 @@ public MeetingHudPagingBehaviour(IntPtr ptr) : base(ptr)
{
}

public MeetingHud MeetingHud = null!;
internal MeetingHud meetingHud = null!;

[HideFromIl2Cpp]
public IEnumerable<PlayerVoteArea> Targets => MeetingHud.playerStates.OrderBy(p => p.AmDead);
public override int MaxPage => (Targets.Count() - 1) / MaxPerPage;
public IEnumerable<PlayerVoteArea> Targets => meetingHud.playerStates.OrderBy(p => p.AmDead);
public override int MaxPageIndex => (Targets.Count() - 1) / MaxPerPage;

public override void Update()
{
base.Update();

if (MeetingHud.state is MeetingHud.VoteStates.Animating or MeetingHud.VoteStates.Proceeding)
if (meetingHud.state is MeetingHud.VoteStates.Animating or MeetingHud.VoteStates.Proceeding)
{
return; // TimerText does not update there
}

MeetingHud.TimerText.text += $" ({Page + 1}/{MaxPage + 1})";
meetingHud.TimerText.text += $" ({PageIndex + 1}/{MaxPageIndex + 1})";
}

public override void OnPageChanged()
{
var i = 0;

foreach (var button in Targets) {
if (i >= Page * MaxPerPage && i < (Page + 1) * MaxPerPage) {
if (i >= PageIndex * MaxPerPage && i < (PageIndex + 1) * MaxPerPage) {
button.gameObject.SetActive(true);

var relativeIndex = i % MaxPerPage;
var row = relativeIndex / 3;
var buttonTransform = button.transform;
buttonTransform.localPosition = MeetingHud.VoteOrigin +
buttonTransform.localPosition = meetingHud.VoteOrigin +
new Vector3(
MeetingHud.VoteButtonOffsets.x * (relativeIndex % 3),
MeetingHud.VoteButtonOffsets.y * row,
meetingHud.VoteButtonOffsets.x * (relativeIndex % 3),
meetingHud.VoteButtonOffsets.y * row,
buttonTransform.localPosition.z
);
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/CrowdedMod/Components/ShapeShifterPagingBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Reactor;
using UnhollowerBaseLib.Attributes;
using Il2CppInterop.Runtime.Attributes;
using Reactor.Utilities.Attributes;
using UnityEngine;

namespace CrowdedMod.Components;
Expand All @@ -14,27 +14,27 @@ public ShapeShifterPagingBehaviour(IntPtr ptr) : base(ptr)
{
}

public ShapeshifterMinigame ShapeshifterMinigame = null!;
public ShapeshifterMinigame shapeshifterMinigame = null!;
[HideFromIl2Cpp]
public IEnumerable<ShapeshifterPanel> Targets => ShapeshifterMinigame.potentialVictims.ToArray();
public IEnumerable<ShapeshifterPanel> Targets => shapeshifterMinigame.potentialVictims.ToArray();

public override int MaxPage => (Targets.Count() - 1) / MaxPerPage;
public override int MaxPageIndex => (Targets.Count() - 1) / MaxPerPage;

public override void OnPageChanged()
{
var i = 0;

foreach (var panel in Targets)
{
if (i >= Page * MaxPerPage && i < (Page + 1) * MaxPerPage) {
if (i >= PageIndex * MaxPerPage && i < (PageIndex + 1) * MaxPerPage) {
panel.gameObject.SetActive(true);

var relativeIndex = i % MaxPerPage;
var row = relativeIndex / 3;
var buttonTransform = panel.transform;
buttonTransform.localPosition = new Vector3(
ShapeshifterMinigame.XStart + ShapeshifterMinigame.XOffset * (relativeIndex % 3),
ShapeshifterMinigame.YStart + ShapeshifterMinigame.YOffset * row,
shapeshifterMinigame.XStart + shapeshifterMinigame.XOffset * (relativeIndex % 3),
shapeshifterMinigame.YStart + shapeshifterMinigame.YOffset * row,
buttonTransform.localPosition.z
);
} else {
Expand Down
15 changes: 7 additions & 8 deletions src/CrowdedMod/CrowdedMod.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>2.7.0</Version>
<TargetFramework>net6.0</TargetFramework>
<Version>2.7.0-corelcr</Version>
<Authors>CrowdedMods, andry08</Authors>

<LangVersion>latest</LangVersion>
<DebugType>embedded</DebugType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
<GameVersion>2022.6.21</GameVersion>
<GameVersion>2022.10.25</GameVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Reactor" Version="1.1.0" />
<PackageReference Include="BepInEx.IL2CPP" Version="6.0.0-be.540" />
<PackageReference Include="Reactor" Version="2.0.0" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.662" />
<PackageReference Include="AmongUs.GameLibs.$(GamePlatform)" Version="$(GameVersion)" PrivateAssets="all" />

<PackageReference Include="BepInEx.AutoPlugin" Version="1.0.1" PrivateAssets="all" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="1.0.2" PrivateAssets="all" />
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1" PrivateAssets="all" />
</ItemGroup>

<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
Expand Down
4 changes: 2 additions & 2 deletions src/CrowdedMod/CrowdedModPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Linq;
using BepInEx;
using BepInEx.IL2CPP;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Reactor;

namespace CrowdedMod {
[BepInAutoPlugin]
[BepInAutoPlugin("xyz.crowdedmods.crowdedmod")]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
[BepInDependency("gg.reactor.debugger", BepInDependency.DependencyFlags.SoftDependency)] // fix debugger overwriting MinPlayers
Expand Down
4 changes: 2 additions & 2 deletions src/CrowdedMod/Net/SetColorRpc.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Hazel;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Attributes;
using Reactor.Networking.Rpc;

namespace CrowdedMod.Net;

Expand Down
14 changes: 7 additions & 7 deletions src/CrowdedMod/Patches/CreateGameOptionsPatches.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using HarmonyLib;
using Reactor.Extensions;
using Reactor.Utilities.Extensions;
using TMPro;
using UnityEngine;

Expand Down Expand Up @@ -138,19 +138,19 @@ public static bool Prefix()
}
}

[HarmonyPatch(typeof(SaveManager), nameof(SaveManager.GameHostOptions), MethodType.Getter)]
[HarmonyPatch(typeof(GameOptionsData), nameof(GameOptionsData.GameHostOptions), MethodType.Getter)]
public static class SaveManager_get_GameHostOptions
{
public static bool Prefix(out GameOptionsData __result)
{
SaveManager.hostOptionsData ??= SaveManager.LoadGameOptions("gameHostOptions");
GameOptionsData.hostOptionsData ??= GameOptionsData.LoadGameHostOptions();

// patched because of impostor clamping
SaveManager.hostOptionsData.NumImpostors =
Mathf.Clamp(SaveManager.hostOptionsData.NumImpostors, 1, SaveManager.hostOptionsData.MaxPlayers - 1);
SaveManager.hostOptionsData.KillDistance = Mathf.Clamp(SaveManager.hostOptionsData.KillDistance, 0, 2);
GameOptionsData.hostOptionsData.NumImpostors =
Mathf.Clamp(GameOptionsData.hostOptionsData.NumImpostors, 1, GameOptionsData.hostOptionsData.MaxPlayers - 1);
GameOptionsData.hostOptionsData.KillDistance = Mathf.Clamp(GameOptionsData.hostOptionsData.KillDistance, 0, 2);

__result = SaveManager.hostOptionsData;
__result = GameOptionsData.hostOptionsData;
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/CrowdedMod/Patches/GenericPatches.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Linq;
using CrowdedMod.Net;
using HarmonyLib;
using Reactor.Networking;
using UnhollowerBaseLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Reactor.Networking.Rpc;
using UnityEngine;

namespace CrowdedMod.Patches {
Expand Down
4 changes: 2 additions & 2 deletions src/CrowdedMod/Patches/PagingPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class MeetingHudStartPatch
{
public static void Postfix(MeetingHud __instance)
{
__instance.gameObject.AddComponent<MeetingHudPagingBehaviour>().MeetingHud = __instance;
__instance.gameObject.AddComponent<MeetingHudPagingBehaviour>().meetingHud = __instance;
}
}

Expand All @@ -18,7 +18,7 @@ public static class ShapeshifterMinigameBeginPatch
{
public static void Postfix(ShapeshifterMinigame __instance)
{
__instance.gameObject.AddComponent<ShapeShifterPagingBehaviour>().ShapeshifterMinigame = __instance;
__instance.gameObject.AddComponent<ShapeShifterPagingBehaviour>().shapeshifterMinigame = __instance;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/nuget.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<packageSources>
Expand Down

0 comments on commit eb36235

Please sign in to comment.