Skip to content

Commit

Permalink
Fix ghost shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Mar 25, 2024
1 parent 17896fe commit 74652d0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The table below lists the most recent Submerged release for each Among Us versio

| Among Us Version | Submerged Version | Links |
|:---------------------------------------------------------------------------------------------:|:-----------------:|:-----------------------------------------------------------------------------------:|
| `v2024.3.5` | `v2024.3.24` | [Download](https://github.com/SubmergedAmongUs/Submerged/releases/tag/v2024.3.24/) |
| `v2024.3.5` | `v2024.3.25` | [Download](https://github.com/SubmergedAmongUs/Submerged/releases/tag/v2024.3.25/) |
| `v2023.11.28` | `v2023.11.29` | [Download](https://github.com/SubmergedAmongUs/Submerged/releases/tag/v2023.11.29/) |
| `v2023.10.24` | `v2023.11.2` | [Download](https://github.com/SubmergedAmongUs/Submerged/releases/tag/v2023.11.2/) |
| `v2023.7.12`<br>`v2023.7.11` | `v2023.8.2` | [Download](https://github.com/SubmergedAmongUs/Submerged/releases/tag/v2023.8.2/) |
Expand Down
2 changes: 2 additions & 0 deletions Submerged/Floors/Objects/GenericShadowBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public sealed class GenericShadowBehaviour(nint ptr) : MonoBehaviour(ptr)

static GenericShadowBehaviour()
{
// Overrides added earlier have higher priority (smaller index goes first)
ShadowTypeOverrides.Add(obj => obj.gameObject.GetComponentInParent<LongBoiPlayerBody>(true) ? typeof(LongPlayerShadowRenderer) : null);
ShadowTypeOverrides.Add(obj => obj.gameObject.GetComponentInParent<PlayerControl>() ? typeof(PlayerShadowRenderer) : null);
ShadowTypeOverrides.Add(obj => obj.gameObject.GetComponent<DeadBody>() ? typeof(DeadBodyShadowRenderer) : null);
}

Expand Down
2 changes: 1 addition & 1 deletion Submerged/Floors/Objects/LongPlayerShadowRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Submerged.Floors.Objects;

[RegisterInIl2Cpp]
public class LongPlayerShadowRenderer(nint ptr) : RelativeShadowRenderer(ptr)
public class LongPlayerShadowRenderer(nint ptr) : PlayerShadowRenderer(ptr)
{
public LongBoiPlayerBody body;

Expand Down
17 changes: 17 additions & 0 deletions Submerged/Floors/Objects/PlayerShadowRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Reactor.Utilities.Attributes;

namespace Submerged.Floors.Objects;

[RegisterInIl2Cpp]
public class PlayerShadowRenderer(nint ptr) : RelativeShadowRenderer(ptr)
{
public PlayerControl player;

protected override void Start()
{
base.Start();
player = GetComponentInParent<PlayerControl>();
}

public override bool EnableShadow => player.isDummy || (!player.Data.IsDead && !player.Data.Disconnected);
}
4 changes: 3 additions & 1 deletion Submerged/Floors/Objects/RelativeShadowRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class RelativeShadowRenderer(nint ptr) : MonoBehaviour(ptr)

private readonly Dictionary<Sprite, Sprite> _cachedSprites = [];

public virtual bool EnableShadow => true;

protected virtual void Awake()
{
gameObject.layer = 4;
Expand Down Expand Up @@ -48,7 +50,7 @@ protected virtual void LateUpdate()

if (targetRenderer)
{
shadowRenderer.enabled = targetRenderer.enabled && targetRenderer.gameObject.activeInHierarchy;
shadowRenderer.enabled = targetRenderer.enabled && targetRenderer.gameObject.activeInHierarchy && EnableShadow;
shadowRenderer.sprite = GetReplacementSprite(targetRenderer.sprite);
shadowRenderer.SetColorAlpha(targetRenderer.color.a);
shadowRenderer.flipX = targetRenderer.flipX;
Expand Down
2 changes: 1 addition & 1 deletion Submerged/Submerged.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>2024.3.24</Version>
<Version>2024.3.25</Version>
<Authors>Submerged Team</Authors>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/SubmergedAmongUs/Submerged</RepositoryUrl>
Expand Down

0 comments on commit 74652d0

Please sign in to comment.