Skip to content

Commit

Permalink
Fixes and features
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkellly committed Dec 30, 2023
1 parent 063940e commit 417eab5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Laboratory/Buttons/CooldownButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void SetButtonSaturation(bool saturated)
public virtual bool ShouldBeVisible()
{
if (!ShipStatus.Instance) return false;
if (!HudManager.Instance.UseButton.gameObject.active) return false;
if (!HudManager.Instance.UseButton.gameObject.active && !HudManager.Instance.PetButton.gameObject.active) return false;
PlayerControl localPlayer = PlayerControl.LocalPlayer;
if (!localPlayer || localPlayer.Data == null) return false;
if (localPlayer.Data.IsDead) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public static bool AdjustOffsets(PlayerPhysics __instance)
Vector3 position = transform.position;
position.z = (position.y - anim.RendererOffset.y) / 1000f + anim.ZOffset;
transform.position = position;

foreach (var spriteAnimNodeSync in __instance.GetComponentsInChildren<SpriteAnimNodeSync>())
{
spriteAnimNodeSync.LateUpdate();
}

return false;
}
Expand Down
21 changes: 20 additions & 1 deletion Laboratory/Player/Extensions/PlayerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections;
using BepInEx.Unity.IL2CPP.Utils;
using Laboratory.Effects.Managers;
using Laboratory.Extensions;
using Laboratory.Player.Managers;
Expand All @@ -19,4 +21,21 @@ public static PlayerEffectManager GetEffectManager(this GameObject player)
return player.GetCachedComponent<PlayerEffectManager>();
}

public static PlayerEffectManager GetEffectManager(this Component player) => player.gameObject.GetEffectManager(); }
public static PlayerEffectManager GetEffectManager(this Component player) => player.gameObject.GetEffectManager();

public static Coroutine AnimateCustom(this PlayerControl player, AnimationClip clip)
{
return player.StartCoroutine(player.CoAnimateCustom(clip));
}

private static IEnumerator CoAnimateCustom(this PlayerControl player, AnimationClip clip)
{
player.MyPhysics.DoingCustomAnimation = true;

yield return player.MyPhysics.Animations.CoPlayCustomAnimation(clip);
player.cosmetics.AnimateSkinIdle();
player.MyPhysics.Animations.PlayIdleAnimation();
player.cosmetics.SetBodyCosmeticsVisible(b: true);
player.MyPhysics.DoingCustomAnimation = false;
}
}
8 changes: 5 additions & 3 deletions Laboratory/Player/SizeModifier.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using HarmonyLib;
Expand All @@ -20,7 +21,7 @@ public static class SizeModifer
public static void SetSizeModifier(this PlayerPhysics player, float value, object key)
{
Dictionary<object, float> set = sizeModifiers[player];
if (value == 1)
if (Math.Abs(value - 1) < 0.001)
{
set.Remove(key);
}
Expand All @@ -39,13 +40,14 @@ public static void SetSizeModifier<T>(this PlayerPhysics player, float value)

public static void Update(PlayerPhysics player)
{
Vector3 size = DefaultSize;
var size = DefaultSize;

foreach ((object _, float v) in sizeModifiers[player])
foreach (var (_, v) in sizeModifiers[player])
{
size *= v;
}

player.myPlayer.Collider.Cast<CircleCollider2D>().radius = 0.2233912f / (size.x / DefaultSize.x);
player.transform.localScale = size;
}

Expand Down

0 comments on commit 417eab5

Please sign in to comment.