Skip to content

Commit

Permalink
Fixed some swords using wrong positions for particle effects (#198).
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirsario committed Sep 7, 2023
1 parent ce3a9dc commit c6610a2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
- Heavily improved combat info tooltips. They now have far more information and feature formatting and color highlighting. They were also added to Hammers, Axes and Pickaxes.

### Fixes
- Fixed issue [#200](https://github.com/Mirsario/TerrariaOverhaul/issues/200) (Killing Blow Localizations are Outdated).
- Fixed issue [#200](https://github.com/Mirsario/TerrariaOverhaul/issues/200) (Killing Blow Localizations are Outdated).
- Fixed the Volcano, Blood Butcherer, and a few other melee weapons using incorrect rotations & locations for their particle effects.

# 5.0 BETA 13B

Expand Down
26 changes: 22 additions & 4 deletions Common/Melee/_Animations/MeleeAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using TerrariaOverhaul.Core.Configuration;
using TerrariaOverhaul.Core.Debugging;
using TerrariaOverhaul.Core.ItemComponents;
using TerrariaOverhaul.Utilities;

using TerrariaOverhaul.Core.Configuration;
using Terraria.ID;

namespace TerrariaOverhaul.Common.Melee;

public abstract class MeleeAnimation : ItemComponent
Expand All @@ -16,7 +15,7 @@ public abstract class MeleeAnimation : ItemComponent

public abstract float GetItemRotation(Player player, Item item);

public override void UseItemFrame(Item item, Player player)
protected virtual void ApplyAnimation(Item item, Player player)
{
if (!Enabled || !EnableImprovedMeleeAnimations) {
return;
Expand Down Expand Up @@ -68,4 +67,23 @@ public override void UseItemFrame(Item item, Player player)
DebugSystem.DrawCircle(player.itemLocation, 3f, Color.White);
}
}

public sealed override void UseStyle(Item item, Player player, Rectangle heldItemFrame)
{
TryApplyAnimation(player.HeldItem, player);
}

public sealed override void UseItemFrame(Item item, Player player)
{
TryApplyAnimation(player.HeldItem, player);
}

private void TryApplyAnimation(Item item, Player player)
{
var heldItem = player.HeldItem;

if (heldItem.TryGetGlobalItem(this, out var correctInstance)) {
correctInstance.ApplyAnimation(heldItem, player);
}
}
}
4 changes: 2 additions & 2 deletions Common/Melee/_Animations/QuickSlashMeleeAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public override void UseAnimation(Item item, Player player)
}

// Leg framing
public override void UseItemFrame(Item item, Player player)
protected override void ApplyAnimation(Item item, Player player)
{
base.UseItemFrame(item, player);
base.ApplyAnimation(item, player);

if (!Enabled || !AnimateLegs) {
return;
Expand Down
8 changes: 4 additions & 4 deletions Common/PlayerEffects/PlayerHoldOutAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class PlayerHoldOutAnimation : ModPlayer

public override void Load()
{
On_Player.ItemCheck_ApplyHoldStyle_Inner += (orig, player, mountOffset, sItem, heldItemFrame) => {
On_Player.ItemCheck_ApplyHoldStyle_Inner += static (orig, player, mountOffset, sItem, heldItemFrame) => {
if (ShouldForceUseAnim(player, sItem)) {
player.ItemCheck_ApplyUseStyle(mountOffset, sItem, heldItemFrame);

Expand All @@ -32,7 +32,7 @@ public override void Load()
orig(player, mountOffset, sItem, heldItemFrame);
};

On_Player.ItemCheck_ApplyUseStyle_Inner += (orig, player, mountOffset, sItem, heldItemFrame) => {
On_Player.ItemCheck_ApplyUseStyle_Inner += static (orig, player, mountOffset, sItem, heldItemFrame) => {
orig(player, mountOffset, sItem, heldItemFrame);

if (sItem.useStyle == ItemUseStyleID.Shoot) {
Expand All @@ -51,7 +51,7 @@ public override void Load()
}
};

On_Player.PlayerFrame += (orig, player) => {
On_Player.PlayerFrame += static (orig, player) => {
if (ShouldForceUseAnim(player, player.HeldItem) && player.itemAnimation <= 0 && AlwaysShowAimableWeapons) {
InvokeWithForcedAnimation(player, () => orig(player));
return;
Expand All @@ -60,7 +60,7 @@ public override void Load()
orig(player);
};

On_PlayerDrawLayers.DrawPlayer_27_HeldItem += (On_PlayerDrawLayers.orig_DrawPlayer_27_HeldItem orig, ref PlayerDrawSet drawInfo) => {
On_PlayerDrawLayers.DrawPlayer_27_HeldItem += static (On_PlayerDrawLayers.orig_DrawPlayer_27_HeldItem orig, ref PlayerDrawSet drawInfo) => {
var player = drawInfo.drawPlayer;

if (ShouldForceUseAnim(player, player.HeldItem) && player.itemAnimation <= 0 && AlwaysShowAimableWeapons) {
Expand Down

0 comments on commit c6610a2

Please sign in to comment.