Files
Cielonos/Assets/Scripts/MainGame/Items/MainWeapons/Chinamida.cs
SoulliesOfficial ef7b479712 initial
2025-11-25 08:19:33 -05:00

138 lines
5.5 KiB
C#

using Cielonos.MainGame.Characters;
using SLSUtilities.FunctionalAnimation;
using UnityEngine;
namespace Cielonos.MainGame.Inventory
{
public partial class Chinamida : MainWeaponBase
{
public override void OnEquipped()
{
RegisterFunctionsToAnimSc(LightAttack0, LightAttack1, LightAttack2, LightAttack3, HeavyAttack, StayBlocking);
}
public override void OnPrimaryPress()
{
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.NextCombo("L");
functionSm["LightAttack"].ResetCooldown();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName(), target, 0.8f);
}
}
public override void OnSecondaryPress()
{
if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.ResetCombo();
functionSm["HeavyAttack"].ResetCooldown();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("HeavyAttack", target, 2f);
}
}
public override void OnQuaternaryPress()
{
if (functionSm["Block"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability(DisruptionType.ForcedAction))
{
comboSm.ResetCombo();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("Block", target, 2f);
SetBlock();
player.movementSc.canMove.Modify(false);
player.movementSc.canRotate.Modify(false);
}
}
public override void OnQuaternaryRelease()
{
fullBodyFuncAnimSm.Stop(DisruptionType.ForcedAction);
RemoveBlock();
player.movementSc.canMove.Modify(true);
player.movementSc.canRotate.Modify(true);
}
}
public partial class Chinamida
{
private void LightAttack0() => GenerateSlash("LightAttack0", new Vector3(1f, 0.6f, 0).normalized * 0.2f);
private void LightAttack1() => GenerateSlash("LightAttack1", new Vector3(-1f, -0.6f, 0).normalized * 0.2f);
private void LightAttack2() => GenerateSlash("LightAttack2", new Vector3(-1f, 0.6f, 0).normalized * 0.2f);
private void LightAttack3() => GenerateSlash("LightAttack3", Vector3.right * 0.2f);
private void HeavyAttack() => GenerateTornado("Tornado", Vector3.forward * 0.4f);
}
public partial class Chinamida
{
private void GenerateSlash(string vfxName, Vector3 swingForce)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["LightAttack"])
.SetTimeSubmodule<NormalArea>(1f)
.SetHitSubmodule<NormalArea>()
.SetForceSubmodule<NormalArea>(3f, true);
slash.hitSm
.AddHitSound("LightAttackNormalHit")
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
Swing("LightAttackSwing", "Swing", swingForce);
}
private void GenerateTornado(string vfxName, Vector3 swingForce)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["Tornado"])
.SetTimeSubmodule<NormalArea>(1.5f, 1.2f, 0.1f)
.SetHitSubmodule<NormalArea>(0.08f, 15)
.SetForceSubmodule<NormalArea>(4f, false, 5f)
.SetLinearDirectionMoveModule<NormalArea>(slash.transform.forward, 5f, 5f);
slash.hitSm
.AddHitSound("LightAttackNormalHit")
.AddHitEvent((enemy, hitPosition) => feedbackSc["Hit"].Play());
Swing("LightAttackSwing", "Swing", swingForce);
}
private void SetBlock()
{
BlockSource blockSource = blockData.CreateBlockSource(player, this);
blockSource.onNormalBlock = () =>
{
PostProcessingManager.Instance.chromaticAberrationSm.ModifyIntensity(0.2f);
PostProcessingManager.Instance.radialBlurSm.ModifyBlurRadius(0.2f);
animationSc.fullBodyFuncAnimSm.Play("Parry");
};
blockSource.onPerfectBlock = () =>
{
PostProcessingManager.Instance.chromaticAberrationSm.ModifyIntensity(0.5f);
PostProcessingManager.Instance.radialBlurSm.ModifyBlurRadius(0.5f);
animationSc.fullBodyFuncAnimSm.Play("Parry");
};
player.reactionSc.blockSm.ApplyBlock(blockSource);
//blockDisposable?.Dispose();
}
private void StayBlocking()
{
if (player.inputSc.IsHoldingQuaternary)
{
player.movementSc.canMove.Modify(true);
player.movementSc.canRotate.Modify(true);
OnQuaternaryPress();
}
}
private void RemoveBlock()
{
player.reactionSc.blockSm.RemoveBlock(blockData.blockName);
}
}
}