Skip to content

Commit 10dc010

Browse files
authored
Merge pull request #4 from XtraCube/rewrite
scale player and hud instead of entire map
2 parents d67ac9e + 76b48c7 commit 10dc010

12 files changed

Lines changed: 95 additions & 266 deletions

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
build:
77
runs-on: ubuntu-20.04
88
steps:
9-
- uses: actions/checkout@v3
9+
- uses: actions/checkout@v4
1010
with:
1111
submodules: true
1212

1313
- name: Setup .NET
14-
uses: actions/setup-dotnet@v3
14+
uses: actions/setup-dotnet@v4
1515
with:
1616
dotnet-version: 6.x
1717

@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
verbosity: Diagnostic
2222

23-
- uses: actions/upload-artifact@v3
23+
- uses: actions/upload-artifact@v4
2424
with:
2525
name: SmolMod.dll
2626
path: SmolMod/bin/Release/net6.0/SmolMod.dll

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
.vs
66
.idea
77
bin
8-
obj
8+
obj
9+
*.user
10+
*.DotSettings

SmolMod/Extensions.cs

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

SmolMod/Patches/AirShipPatches.cs

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

SmolMod/Patches/HudStartPatch.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using HarmonyLib;
2+
using UnityEngine;
3+
4+
namespace SmolMod.Patches;
5+
6+
// adapted from https://github.com/Among-Us-Modding/Laboratory/blob/main/Laboratory/Utilities/CameraZoomController.cs
7+
[HarmonyPatch(typeof(HudManager),nameof(HudManager.Start))]
8+
public static class HudStartPatch
9+
{
10+
private static ShadowCollab _shadowCollab;
11+
private static Camera _cam;
12+
private static float _defaultOrthographicSize;
13+
14+
public static void Postfix(HudManager __instance)
15+
{
16+
_shadowCollab = Object.FindObjectOfType<ShadowCollab>();
17+
_shadowCollab.StopAllCoroutines();
18+
19+
HudManager.Instance.FullScreen.transform.localScale *= 50;
20+
21+
var mainCam = Camera.main!;
22+
23+
GameObject newCamObj = new("ZoomCamera");
24+
var newCamTransform = newCamObj.transform;
25+
newCamTransform.parent = mainCam.transform;
26+
newCamTransform.localPosition = new Vector3(0, 0, 0);
27+
newCamTransform.localScale = new Vector3(1, 1, 1);
28+
29+
_cam = newCamObj.AddComponent<Camera>();
30+
_cam.CopyFrom(mainCam);
31+
_cam.depth += 1;
32+
mainCam.ResetReplacementShader();
33+
34+
_defaultOrthographicSize = _cam.orthographicSize;
35+
36+
UpdateSize();
37+
}
38+
39+
public static void UpdateSize()
40+
{
41+
if (!_shadowCollab || !_cam)
42+
{
43+
return;
44+
}
45+
46+
_shadowCollab.ShadowCamera.aspect = _cam.aspect;
47+
var val = _shadowCollab.ShadowCamera.orthographicSize = _cam.orthographicSize = _defaultOrthographicSize / SmolModPlugin.ScaleMod;
48+
_shadowCollab.ShadowQuad.transform.localScale = new Vector3(val * _cam.aspect, val) * 2f;
49+
}
50+
}

SmolMod/Patches/LobbySizePatch.cs

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

SmolMod/Patches/NetworkPatches.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using HarmonyLib;
2+
using UnityEngine;
3+
4+
namespace SmolMod.Patches;
5+
6+
[HarmonyPatch(typeof(PlayerControl),nameof(PlayerControl.Start))]
7+
public static class PlayerControlPatch
8+
{
9+
// adapted from https://github.com/Among-Us-Modding/Laboratory/blob/main/Laboratory/Player/SizeModifier.cs
10+
private static readonly Vector3 DefaultSize = new (0.7f, 0.7f, 1f);
11+
12+
public static void Postfix(PlayerControl __instance)
13+
{
14+
__instance.UpdateSize();
15+
}
16+
17+
public static void UpdateSize(this PlayerControl player)
18+
{
19+
var size = DefaultSize / SmolModPlugin.ScaleMod;
20+
21+
player.Collider.Cast<CircleCollider2D>().radius = 0.2233912f / (size.x / DefaultSize.x);
22+
player.transform.localScale = size;
23+
}
24+
}

SmolMod/Patches/PlayerPatches.cs

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

SmolMod/Patches/ShipSizePatch.cs

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

0 commit comments

Comments
 (0)