109 lines
4.2 KiB
C#
109 lines
4.2 KiB
C#
using System;
|
|
using System.Linq;
|
|
using RootMotion.FinalIK;
|
|
using SLSFramework.General;
|
|
using SLSUtilities.FunctionalAnimation;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public partial class PlayerAnimationSubcontroller : AnimationSubcontrollerBase, IPlayerSubcontroller
|
|
{
|
|
public Player player => owner as Player;
|
|
public AnimatorOverrideController animatorOverride;
|
|
|
|
public FullBodyBipedIK fullBodyIK;
|
|
public GrounderFBBIK footIK;
|
|
public AimIK aimIK;
|
|
public LookAtIK lookAtIK;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
player.operationSc.OnDash += delegate { fullBodyFuncAnimSm.Play("Dash"); };
|
|
player.operationSc.OnDodge += delegate { fullBodyFuncAnimSm.Play("Dodge"); };
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
|
|
player.inputSc.preinputSubmodule.Update(isDuringPreinput, isAtActionDisruption);
|
|
}
|
|
|
|
protected override void LateUpdate()
|
|
{
|
|
base.LateUpdate();
|
|
}
|
|
|
|
public override void RegisterDefaultFunctions()
|
|
{
|
|
base.RegisterDefaultFunctions();
|
|
|
|
registeredFunctions.Add("DashStart", anim =>
|
|
{
|
|
player.landMovementSc.isDashing = true;
|
|
player.landMovementSc.dashMoveMultiplier = anim.funcAnimData.variableCollection.GetVariable<float>("DashMoveMultiplier");
|
|
PostProcessingManager.Instance.radialBlurSm.ModifyBlurRadius(0.5f);
|
|
player.audioSc.PlayDashSound();
|
|
player.renderSc.characterTrail.active = true;
|
|
player.renderSc.characterTrail.Restart();
|
|
|
|
DodgeSource defaultDodge = new DodgeSource(owner, null, "DefaultDodge", 0, "NormalDodge", "PerfectDodge", Mathf.Infinity, 0.2f);
|
|
defaultDodge.onPerfectDodge = () =>
|
|
{
|
|
PostProcessingManager.Instance.tonemappingSm.ModifyContrast(-0.4f);
|
|
};
|
|
player.reactionSc.dodgeSm.ApplyDodge(defaultDodge);
|
|
});
|
|
|
|
registeredFunctions.Add("DashEnd", anim =>
|
|
{
|
|
player.landMovementSc.isDashing = false;
|
|
player.landMovementSc.dashMoveMultiplier = 1;
|
|
player.landMovementSc.isSprinting = true;
|
|
player.renderSc.characterTrail.active = false;
|
|
|
|
player.reactionSc.dodgeSm.RemoveDodge("DefaultDodge");
|
|
});
|
|
|
|
registeredFunctions.Add("DodgeStart", anim =>
|
|
{
|
|
player.landMovementSc.isDashing = true;
|
|
player.landMovementSc.dashMoveMultiplier = anim.funcAnimData.variableCollection.GetVariable<float>("DashMoveMultiplier");
|
|
PostProcessingManager.Instance.radialBlurSm.ModifyBlurRadius(-0.5f);
|
|
player.audioSc.PlayDashSound();
|
|
|
|
DodgeSource defaultDodge = new DodgeSource(owner, null, "DefaultDodge", 0, "NormalDodge", "PerfectDodge", Mathf.Infinity, 0.2f);
|
|
defaultDodge.onPerfectDodge = () =>
|
|
{
|
|
PostProcessingManager.Instance.tonemappingSm.ModifyContrast(-0.4f);
|
|
};
|
|
player.reactionSc.dodgeSm.ApplyDodge(defaultDodge);
|
|
});
|
|
|
|
registeredFunctions.Add("DodgeEnd", anim =>
|
|
{
|
|
player.landMovementSc.isDashing = false;
|
|
player.landMovementSc.dashMoveMultiplier = 1;
|
|
|
|
player.reactionSc.dodgeSm.RemoveDodge("DefaultDodge");
|
|
});
|
|
}
|
|
}
|
|
|
|
public partial class PlayerAnimationSubcontroller
|
|
{
|
|
public bool isDuringPreinput;
|
|
public bool isAtActionDisruption;
|
|
|
|
protected override void UpdateIntervalInfo()
|
|
{
|
|
base.UpdateIntervalInfo();
|
|
|
|
isDuringPreinput = currentIntervals.Any(interval => interval.intervalType == IntervalType.Preinput);
|
|
isAtActionDisruption = lastFrameIntervals.SwitchOut(currentIntervals, (interval) => interval.intervalType == IntervalType.Preinput);
|
|
}
|
|
}
|
|
} |