feat: more combat tweaks

shuriken can now be thrown
jumping animtions
jumping animations timing
state machine changes
start of online integration
This commit is contained in:
Chris
2026-01-15 14:42:25 -05:00
parent a06784f7b6
commit 25b7fae339
45 changed files with 28662 additions and 250 deletions

View File

@@ -1,7 +1,75 @@
using Reset.Core;
using Reset.Items;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Profiling;
namespace Reset.Units{
public class PlayerCombat : UnitCombat{
public CombatType currentCombatType;
private IEquipable currentWeapon;
private GameObject currentWeaponItem;
public void OnDrawWeapon(){
if (Unit.UnitIsNetworked()) {
CreatePlayerWeaponRpc();
} else {
CreatePlayerWeapon();
}
}
[Rpc(SendTo.Everyone)]
public void CreatePlayerWeaponRpc(){
CreatePlayerWeapon();
}
public void CreatePlayerWeapon(){
// Remove a current weapon
DisposeCurrentWeapon();
// Reference inventory and inventory
PlayerInventory playerInventory = Unit.Inventory as PlayerInventory;
PlayerAnimation playerAnimation = Unit.Animation as PlayerAnimation;
// Add weapon to status and hand
currentWeapon = playerInventory.meleeWeapon;
currentWeaponItem = playerInventory.meleeWeapon.InstantiateItemObject();
// Move item to hand
currentWeaponItem.transform.SetParent(playerAnimation.rightHand);
currentWeaponItem.transform.localPosition = playerInventory.meleeWeapon.handPositionOffset;
currentWeaponItem.transform.rotation = playerAnimation.rightHand.rotation * Quaternion.Euler(playerInventory.meleeWeapon.handRotationOffset);
// Add related weapon's actor script
(currentWeapon as Weapon).AddActorScript();
}
public GameObject GetCurrentWeaponItem(){
return currentWeaponItem;
}
public void OnHolsterWeapon(){
DisposeCurrentWeapon();
}
public void DisposeCurrentWeapon(){
// Return if no weapon active
if (currentWeapon == null) {
return;
}
// Destroy physical mesh
Destroy(currentWeaponItem);
// Destroy weapon actor
if ((GetComponent<WeaponActor>()) != null) {
Destroy(GetComponent<WeaponActor>());
}
// Remove references
currentWeaponItem = null;
currentWeapon = null;
}
}
}