Skip to content

Commit

Permalink
Fixed weapon charging being able to shoot projectiles (#198).
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirsario committed Sep 7, 2023
1 parent 1f0d9e6 commit 228c478
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Common/Charging/ItemPowerAttacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public override void Load()
*/
});
};

On_Player.ItemCheck_OwnerOnlyCode += PlayertemCheckOwnerOnlyCodeDetour;
}

public override void HoldItem(Item item, Player player)
Expand Down Expand Up @@ -201,4 +203,13 @@ bool ICanDoMeleeDamage.CanDoMeleeDamage(Item item, Player player)

bool? ICanTurnDuringItemUse.CanTurnDuringItemUse(Item item, Player player)
=> IsCharging ? true : null;

private static void PlayertemCheckOwnerOnlyCodeDetour(On_Player.orig_ItemCheck_OwnerOnlyCode orig, Player player, ref Player.ItemCheckContext context, Item sItem, int weaponDamage, Microsoft.Xna.Framework.Rectangle heldItemFrame)
{
if (player.HeldItem is { IsAir: false } item && item.TryGetGlobalItem(out ItemPowerAttacks powerAttacks) && powerAttacks.IsCharging) {
return;
}

orig(player, ref context, sItem, weaponDamage, heldItemFrame);
}
}

0 comments on commit 228c478

Please sign in to comment.