-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48c2880
commit 538933f
Showing
20 changed files
with
1,442 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections; | ||
using BepInEx.Unity.IL2CPP.Utils.Collections; | ||
using Il2CppInterop.Runtime.Attributes; | ||
using Jungle.Effects; | ||
using Reactor.Utilities.Attributes; | ||
using UnityEngine; | ||
|
||
namespace Jungle.Buttons; | ||
|
||
[RegisterInIl2Cpp] | ||
public class EffectButton : CooldownButton | ||
{ | ||
public EffectButton(IntPtr ptr) : base(ptr) { } | ||
|
||
public IEffect Effect; | ||
public Coroutine EffectRoutine; | ||
|
||
public override void PerformClick() | ||
{ | ||
if (!ShouldCooldown() || !ShouldBeVisible() || !CanUse()) return; | ||
|
||
CurrentTime = int.MaxValue; | ||
StopAllCoroutines(); | ||
Effect = null; | ||
EffectRoutine = StartCoroutine(ShowEffectDuration().WrapToIl2Cpp()); | ||
OnClickAction?.Invoke(); | ||
} | ||
|
||
public override bool CanUse() | ||
{ | ||
return EffectRoutine == null && base.CanUse(); | ||
} | ||
|
||
[HideFromIl2Cpp] | ||
public IEnumerator ShowEffectDuration() | ||
{ | ||
while (Effect == null) | ||
{ | ||
CurrentTime = int.MaxValue; | ||
yield return null; | ||
} | ||
|
||
float duration = Effect.Timer; | ||
|
||
while (Effect is { Timer: > 0 }) | ||
{ | ||
CurrentTime = int.MaxValue; | ||
TimerText!.text = Mathf.CeilToInt(Effect.Timer).ToString(); | ||
TimerText.color = Effect.Timer / duration < 0.5 | ||
? Color.Lerp(new Color32(255, 0, 0, 255), new Color32(255, 242, 0, 255), (Effect.Timer / duration) * 2) | ||
: Color.Lerp(new Color32(255, 242, 0, 255), new Color32(30, 150, 0, 255), ((Effect.Timer / duration) - 0.5f) * 2); | ||
|
||
yield return null; | ||
} | ||
|
||
CurrentTime = Cooldown; | ||
TimerText!.color = Color.white; | ||
EffectRoutine = null; | ||
Effect = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using AmongUs.GameOptions; | ||
using Reactor.Utilities.Attributes; | ||
using UnityEngine; | ||
|
||
namespace Jungle.Buttons; | ||
|
||
[RegisterInIl2Cpp] | ||
// ReSharper disable once ClassWithVirtualMembersNeverInherited.Global | ||
public class TargetButton : CooldownButton | ||
{ | ||
public TargetButton(IntPtr ptr) : base(ptr) { } | ||
|
||
public PlayerControl Target { get; set; } | ||
|
||
public virtual float TargetRange() => GameOptionsData.KillDistances[Mathf.Clamp(GameOptionsManager.Instance.currentNormalGameOptions.KillDistance, 0, 2)]; | ||
|
||
public virtual PlayerControl GetClosest() | ||
{ | ||
PlayerControl current = null; | ||
float maxDistance = TargetRange(); | ||
Vector2 myPosition = PlayerControl.LocalPlayer.GetTruePosition(); | ||
foreach (PlayerControl player in PlayerControl.AllPlayerControls) | ||
{ | ||
if (player.AmOwner || player.Data.IsDead) continue; | ||
float distance = Vector2.Distance(myPosition, player.GetTruePosition()); | ||
if (distance <= maxDistance) | ||
{ | ||
current = player; | ||
maxDistance = distance; | ||
} | ||
} | ||
|
||
return current; | ||
} | ||
|
||
public override void PerformClick() | ||
{ | ||
if (!Target) return; | ||
base.PerformClick(); | ||
} | ||
|
||
public override bool CanUse() | ||
{ | ||
if (!Target) return false; | ||
return base.CanUse(); | ||
} | ||
|
||
public override void Update() | ||
{ | ||
base.Update(); | ||
|
||
Target = GetClosest(); | ||
SetButtonSaturation(Target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using AmongUs.GameOptions; | ||
using Reactor.Utilities.Attributes; | ||
using UnityEngine; | ||
|
||
namespace Jungle.Buttons; | ||
|
||
[RegisterInIl2Cpp] | ||
// ReSharper disable once ClassWithVirtualMembersNeverInherited.Global | ||
public class TargetEffectButton : EffectButton | ||
{ | ||
public TargetEffectButton(IntPtr ptr) : base(ptr) { } | ||
|
||
public PlayerControl Target { get; set; } | ||
public virtual float TargetRange() => GameOptionsData.KillDistances[Mathf.Clamp(GameOptionsManager.Instance.currentNormalGameOptions.KillDistance, 0, 2)]; | ||
|
||
|
||
public virtual PlayerControl GetClosest() | ||
{ | ||
PlayerControl current = null; | ||
float maxDistance = TargetRange(); | ||
Vector2 myPosition = PlayerControl.LocalPlayer.GetTruePosition(); | ||
foreach (PlayerControl player in PlayerControl.AllPlayerControls) | ||
{ | ||
if (player.AmOwner || player.Data.IsDead) continue; | ||
float distance = Vector2.Distance(myPosition, player.GetTruePosition()); | ||
if (distance <= maxDistance) | ||
{ | ||
current = player; | ||
maxDistance = distance; | ||
} | ||
} | ||
|
||
return current; | ||
} | ||
|
||
public override void PerformClick() | ||
{ | ||
if (!Target) return; | ||
base.PerformClick(); | ||
} | ||
|
||
public override bool CanUse() | ||
{ | ||
if (!Target) return false; | ||
return base.CanUse(); | ||
} | ||
|
||
public override void Update() | ||
{ | ||
base.Update(); | ||
if (CurrentTime != int.MaxValue) | ||
{ | ||
Target = GetClosest(); | ||
SetButtonSaturation(Target); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.