Upload from upload_mods.ps1
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationAimRecoilResetState : StateMachineBehaviour
|
||||
{
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.GetComponent<AnimationAimRecoilReferences>()?.Rollback();
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.GetComponent<AnimationAimRecoilReferences>()?.Rollback();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 248236ebc388e4c4d8e3f700b7444ab6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
#if NotEditor
|
||||
using KFCommonUtilityLib.Scripts.StaticManagers;
|
||||
using KFCommonUtilityLib.Scripts.Utilities;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationAmmoUpdateState : StateMachineBehaviour
|
||||
{
|
||||
#if NotEditor
|
||||
private static int[] hash_states = new[]
|
||||
{
|
||||
Animator.StringToHash("ammoCount"),
|
||||
Animator.StringToHash("ammoCount1"),
|
||||
Animator.StringToHash("ammoCount2"),
|
||||
Animator.StringToHash("ammoCount3"),
|
||||
Animator.StringToHash("ammoCount4")
|
||||
};
|
||||
private InventorySlotGurad slotGuard = new InventorySlotGurad();
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
//var player = GameManager.Instance.World?.GetPrimaryPlayer();
|
||||
var player = animator.GetComponentInParent<EntityAlive>();
|
||||
if(slotGuard.IsValid(player))
|
||||
{
|
||||
SetAmmoCountForEntity(player, slotGuard.Slot);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetAmmoCountForEntity(EntityAlive entity, int slot)
|
||||
{
|
||||
if (entity)
|
||||
{
|
||||
var invData = entity.inventory?.slots?[slot];
|
||||
if (invData?.actionData != null)
|
||||
{
|
||||
var mapping = MultiActionManager.GetMappingForEntity(entity.entityId);
|
||||
if (mapping != null)
|
||||
{
|
||||
var metaIndices = mapping.indices;
|
||||
for (int i = 0; i < mapping.ModeCount; i++)
|
||||
{
|
||||
int metaIndex = metaIndices.GetMetaIndexForMode(i);
|
||||
int meta = invData.itemValue.GetMetaByMode(i);
|
||||
entity.emodel.avatarController.UpdateInt(hash_states[metaIndex], meta);
|
||||
if (ConsoleCmdReloadLog.LogInfo)
|
||||
{
|
||||
Log.Out($"Setting ammoCount{(metaIndex > 0 ? metaIndex.ToString() : "")} to {meta}, stack trace:\n{StackTraceUtility.ExtractStackTrace()}");
|
||||
}
|
||||
//animator.SetInteger(hash_states[metaIndex], meta);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.emodel.avatarController.UpdateInt(hash_states[0], invData.itemValue.Meta);
|
||||
if (ConsoleCmdReloadLog.LogInfo)
|
||||
{
|
||||
Log.Out($"Setting ammoCount to {invData.itemValue.Meta}, stack trace:\n{StackTraceUtility.ExtractStackTrace()}");
|
||||
}
|
||||
//animator.SetInteger(hash_states[0], entity.inventory.holdingItemItemValue.Meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87658b6a8bedcd14e83febff2157048c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,266 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
#endif
|
||||
|
||||
public class AnimationCustomMeleeAttackState : StateMachineBehaviour
|
||||
#if UNITY_EDITOR
|
||||
, ISerializationCallbackReceiver
|
||||
#endif
|
||||
{
|
||||
public float RaycastTime = 0.3f;
|
||||
public float CustomGrazeCastTime = 0.3f;
|
||||
public float CustomGrazeCastDuration = 0f;
|
||||
public float ImpactDuration = 0.01f;
|
||||
[Range(0.01f, 1f)]
|
||||
public float ImpactPlaybackSpeed = 1f;
|
||||
[Range(0.01f, 1f)]
|
||||
public float attackDurationNormalized = 1f;
|
||||
[Range(0f, 360f)]
|
||||
public float SwingAngle = 0f;
|
||||
[Range(-180f, 180f)]
|
||||
public float SwingDegrees = 0f;
|
||||
|
||||
[SerializeField]
|
||||
private float ClipLength = 0f;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
var context = AnimatorController.FindStateMachineBehaviourContext(this);
|
||||
if (context != null && context.Length > 0)
|
||||
{
|
||||
var state = context[0].animatorObject as AnimatorState;
|
||||
if (state != null)
|
||||
{
|
||||
var clip = state.motion as AnimationClip;
|
||||
if (clip != null)
|
||||
{
|
||||
ClipLength = clip.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NotEditor
|
||||
private readonly int AttackSpeedHash = Animator.StringToHash("MeleeAttackSpeed");
|
||||
private float calculatedRaycastTime;
|
||||
private float calculatedGrazeTime;
|
||||
private float calculatedGrazeDuration;
|
||||
private float calculatedImpactDuration;
|
||||
private float calculatedImpactPlaybackSpeed;
|
||||
private bool hasFired;
|
||||
private int actionIndex;
|
||||
private float originalMeleeAttackSpeed;
|
||||
//private bool playingImpact;
|
||||
private EntityAlive entity;
|
||||
private float attacksPerMinute;
|
||||
private float speedMultiplierToKeep = 1f;
|
||||
private InventorySlotGurad slotGurad = new InventorySlotGurad();
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
//if (playingImpact)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
hasFired = false;
|
||||
actionIndex = animator.GetWrappedInt(AvatarController.itemActionIndexHash);
|
||||
entity = animator.GetComponentInParent<EntityAlive>();
|
||||
if (!slotGurad.IsValid(entity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Log.Out("State entered!");
|
||||
//AnimatorClipInfo[] array = animator.GetNextAnimatorClipInfo(layerIndex);
|
||||
float length = ClipLength * attackDurationNormalized;
|
||||
////if (array.Length == 0)
|
||||
////{
|
||||
// var array = animator.GetCurrentAnimatorClipInfo(layerIndex);
|
||||
// if (array.Length == 0)
|
||||
// {
|
||||
// if (float.IsInfinity(stateInfo.length))
|
||||
// {
|
||||
// Log.Out($"Invalid clips!");
|
||||
// return;
|
||||
// }
|
||||
// length = stateInfo.length;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// length = array[0].clip.length;
|
||||
// }
|
||||
////}
|
||||
////else
|
||||
////{
|
||||
//// length = array[0].clip.length;
|
||||
////}
|
||||
//length *= attackDurationNormalized;
|
||||
attacksPerMinute = 60f / length;
|
||||
FastTags<TagGroup.Global> fastTags = ((actionIndex != 1) ? ItemActionAttack.PrimaryTag : ItemActionAttack.SecondaryTag);
|
||||
ItemValue holdingItemItemValue = entity.inventory.holdingItemItemValue;
|
||||
ItemClass itemClass = holdingItemItemValue.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
fastTags |= itemClass.ItemTags;
|
||||
}
|
||||
originalMeleeAttackSpeed = EffectManager.GetValue(PassiveEffects.AttacksPerMinute, holdingItemItemValue, attacksPerMinute, entity, null, fastTags) / 60f * length;
|
||||
animator.SetWrappedFloat(AttackSpeedHash, originalMeleeAttackSpeed);
|
||||
speedMultiplierToKeep = originalMeleeAttackSpeed;
|
||||
ItemClass holdingItem = entity.inventory.holdingItem;
|
||||
holdingItem.Properties.ParseFloat((actionIndex != 1) ? "Action0.RaycastTime" : "Action1.RaycastTime", ref RaycastTime);
|
||||
float impactDuration = -1f;
|
||||
holdingItem.Properties.ParseFloat((actionIndex != 1) ? "Action0.ImpactDuration" : "Action1.ImpactDuration", ref impactDuration);
|
||||
if (impactDuration >= 0f)
|
||||
{
|
||||
ImpactDuration = impactDuration * originalMeleeAttackSpeed;
|
||||
}
|
||||
holdingItem.Properties.ParseFloat((actionIndex != 1) ? "Action0.ImpactPlaybackSpeed" : "Action1.ImpactPlaybackSpeed", ref ImpactPlaybackSpeed);
|
||||
if (originalMeleeAttackSpeed != 0f)
|
||||
{
|
||||
calculatedRaycastTime = RaycastTime / originalMeleeAttackSpeed;
|
||||
calculatedGrazeTime = CustomGrazeCastTime / originalMeleeAttackSpeed;
|
||||
calculatedGrazeDuration = CustomGrazeCastDuration / originalMeleeAttackSpeed;
|
||||
calculatedImpactDuration = ImpactDuration / originalMeleeAttackSpeed;
|
||||
calculatedImpactPlaybackSpeed = ImpactPlaybackSpeed * originalMeleeAttackSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
calculatedRaycastTime = 0.001f;
|
||||
calculatedGrazeTime = 0.001f;
|
||||
calculatedGrazeDuration = 0.001f;
|
||||
calculatedImpactDuration = 0.001f;
|
||||
calculatedImpactPlaybackSpeed = 0.001f;
|
||||
}
|
||||
if (ConsoleCmdReloadLog.LogInfo)
|
||||
{
|
||||
Log.Out($"original: raycast time {RaycastTime} impact duration {ImpactDuration} impact playback speed {ImpactPlaybackSpeed} clip length {length}/{stateInfo.length}");
|
||||
Log.Out($"calculated: raycast time {calculatedRaycastTime} impact duration {calculatedImpactDuration} impact playback speed {calculatedImpactPlaybackSpeed} speed multiplier {originalMeleeAttackSpeed}");
|
||||
}
|
||||
GameManager.Instance.StartCoroutine(impactStart(animator, layerIndex, length));
|
||||
GameManager.Instance.StartCoroutine(customGrazeStart(length));
|
||||
}
|
||||
|
||||
private IEnumerator impactStart(Animator animator, int layer, float length)
|
||||
{
|
||||
yield return new WaitForSeconds(Mathf.Max(calculatedRaycastTime, 0));
|
||||
if (!hasFired)
|
||||
{
|
||||
hasFired = true;
|
||||
if (entity != null && !entity.isEntityRemote && actionIndex >= 0)
|
||||
{
|
||||
ItemActionDynamicMelee.ItemActionDynamicMeleeData itemActionDynamicMeleeData = entity.inventory.holdingItemData.actionData[actionIndex] as ItemActionDynamicMelee.ItemActionDynamicMeleeData;
|
||||
if (itemActionDynamicMeleeData != null)
|
||||
{
|
||||
if ((entity.inventory.holdingItem.Actions[actionIndex] as ItemActionDynamicMelee).Raycast(itemActionDynamicMeleeData))
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(impactStop(animator, layer, length));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
private IEnumerator impactStop(Animator animator, int layer, float length)
|
||||
{
|
||||
//playingImpact = true;
|
||||
//animator.Play(0, layer, Mathf.Min(1f, calculatedRaycastTime * attackDurationNormalized / length));
|
||||
if (animator)
|
||||
{
|
||||
//Log.Out("Impact start!");
|
||||
animator.SetWrappedFloat(AttackSpeedHash, calculatedImpactPlaybackSpeed);
|
||||
}
|
||||
speedMultiplierToKeep = calculatedImpactPlaybackSpeed;
|
||||
yield return new WaitForSeconds(calculatedImpactDuration);
|
||||
if (animator)
|
||||
{
|
||||
//Log.Out("Impact stop!");
|
||||
animator.SetWrappedFloat(AttackSpeedHash, originalMeleeAttackSpeed);
|
||||
}
|
||||
speedMultiplierToKeep = originalMeleeAttackSpeed;
|
||||
//playingImpact = false;
|
||||
yield break;
|
||||
}
|
||||
|
||||
private IEnumerator customGrazeStart(float length)
|
||||
{
|
||||
if (ConsoleCmdReloadLog.LogInfo)
|
||||
{
|
||||
Log.Out($"Custom graze time: {calculatedGrazeTime} original {CustomGrazeCastTime}");
|
||||
}
|
||||
yield return new WaitForSeconds(calculatedGrazeTime);
|
||||
if (entity != null && !entity.isEntityRemote && actionIndex >= 0)
|
||||
{
|
||||
ItemActionDynamicMelee.ItemActionDynamicMeleeData itemActionDynamicMeleeData = entity.inventory.holdingItemData.actionData[actionIndex] as ItemActionDynamicMelee.ItemActionDynamicMeleeData;
|
||||
if (itemActionDynamicMeleeData != null)
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(customGrazeUpdate(itemActionDynamicMeleeData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator customGrazeUpdate(ItemActionDynamicMelee.ItemActionDynamicMeleeData data)
|
||||
{
|
||||
if (ConsoleCmdReloadLog.LogInfo)
|
||||
{
|
||||
Log.Out($"Custom graze duration: {calculatedGrazeDuration} original {CustomGrazeCastDuration}");
|
||||
}
|
||||
if (calculatedGrazeDuration <= 0f)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
float grazeStart = Time.time;
|
||||
float normalizedTime = 0f;
|
||||
var action = entity.inventory.holdingItem.Actions[actionIndex] as ItemActionDynamicMelee;
|
||||
while (normalizedTime <= 1)
|
||||
{
|
||||
if (!slotGurad.IsValid(data.invData.holdingEntity))
|
||||
{
|
||||
Log.Out($"Invalid graze!");
|
||||
yield break;
|
||||
}
|
||||
float originalSwingAngle = action.SwingAngle;
|
||||
float originalSwingDegrees = action.SwingDegrees;
|
||||
action.SwingAngle = SwingAngle;
|
||||
action.SwingDegrees = SwingDegrees;
|
||||
bool grazeResult = action.GrazeCast(data, normalizedTime);
|
||||
if (ConsoleCmdReloadLog.LogInfo)
|
||||
{
|
||||
Log.Out($"GrazeCast {grazeResult}!");
|
||||
}
|
||||
action.SwingAngle = originalSwingAngle;
|
||||
action.SwingDegrees = originalSwingDegrees;
|
||||
yield return null;
|
||||
normalizedTime = (Time.time - grazeStart) / calculatedGrazeDuration;
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
//if (entity != null && !entity.isEntityRemote && actionIndex >= 0 && entity.inventory.holdingItemData.actionData[actionIndex] is ItemActionDynamicMelee.ItemActionDynamicMeleeData)
|
||||
//{
|
||||
// animator.SetFloat(AttackSpeedHash, originalMeleeAttackSpeed);
|
||||
//}
|
||||
animator.SetWrappedFloat(AttackSpeedHash, originalMeleeAttackSpeed);
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
//float normalizedTime = stateInfo.normalizedTime;
|
||||
//if (float.IsInfinity(normalizedTime) || float.IsNaN(normalizedTime))
|
||||
//{
|
||||
// animator.Play(animator.GetNextAnimatorStateInfo(layerIndex).shortNameHash, layerIndex);
|
||||
//}
|
||||
animator.SetWrappedFloat(AttackSpeedHash, speedMultiplierToKeep);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fef84a89943f52c418487a560eb789c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,94 @@
|
||||
#if NotEditor
|
||||
using KFCommonUtilityLib.Scripts.StaticManagers;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationCustomReloadState : StateMachineBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float ForceCancelReloadDelay = 1f;
|
||||
[SerializeField]
|
||||
private bool DoNotForceCancel = false;
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.speed = 1f;
|
||||
animator.SetWrappedBool(Animator.StringToHash("Reload"), false);
|
||||
animator.SetWrappedBool(Animator.StringToHash("IsReloading"), true);
|
||||
#if NotEditor
|
||||
if (player == null)
|
||||
{
|
||||
player = animator.GetComponentInParent<EntityAlive>();
|
||||
}
|
||||
int actionIndex = MultiActionManager.GetActionIndexForEntity(player);
|
||||
#if DEBUG
|
||||
Log.Out($"start reload {actionIndex}");
|
||||
#endif
|
||||
actionData = player.inventory.holdingItemData.actionData[actionIndex] as ItemActionRanged.ItemActionDataRanged;
|
||||
if (eventBridge == null)
|
||||
{
|
||||
eventBridge = animator.GetComponent<AnimationReloadEvents>();
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
Log.Out($"ANIMATOR STATE ENTER : {actionData.invData.item.Name}");
|
||||
#endif
|
||||
eventBridge.OnReloadStart(actionIndex);
|
||||
//eventBridge.OnReloadUpdate();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.speed = 1f;
|
||||
#if NotEditor
|
||||
//eventBridge.OnReloadUpdate();
|
||||
if (actionData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (actionData.isReloading)
|
||||
{
|
||||
eventBridge.OnReloadFinish();
|
||||
}
|
||||
#endif
|
||||
//actionData.isReloading = false;
|
||||
//actionData.isReloadCancelled = false;
|
||||
//actionData.isChangingAmmoType = false;
|
||||
#if DEBUG && NotEditor
|
||||
Log.Out($"ANIMATOR STATE EXIT : {actionData.invData.item.Name}");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NotEditor
|
||||
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
//eventBridge.OnReloadUpdate();
|
||||
if (actionData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (actionData.isReloadCancelled)
|
||||
{
|
||||
animator.speed = 30f;
|
||||
|
||||
if (!DoNotForceCancel)
|
||||
{
|
||||
eventBridge.DelayForceCancelReload(ForceCancelReloadDelay);
|
||||
}
|
||||
#if DEBUG
|
||||
Log.Out($"ANIMATOR UPDATE: RELOAD CANCELLED, ANIMATOR SPEED {animator.speed}");
|
||||
#endif
|
||||
}
|
||||
if (!actionData.isReloadCancelled && actionData.isReloading)
|
||||
{
|
||||
actionData.invData.holdingEntity.MinEventContext.ItemActionData = actionData;
|
||||
actionData.invData.holdingEntity.FireEvent(MinEventTypes.onReloadUpdate, true);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemActionRanged.ItemActionDataRanged actionData;
|
||||
private EntityAlive player;
|
||||
private AnimationReloadEvents eventBridge;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f156c87129f85044a3336ade4d1af2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations.Rigging;
|
||||
|
||||
public class AnimationInspectFix : MonoBehaviour, IPlayableGraphRelated
|
||||
{
|
||||
[SerializeField]
|
||||
private string inspectName = "Inspect";
|
||||
[SerializeField]
|
||||
private int layer = 0;
|
||||
[SerializeField, Range(0, 1)]
|
||||
private float finishTime = 1;
|
||||
[SerializeField]
|
||||
private bool useStateTag = false;
|
||||
private static int inspectHash = Animator.StringToHash("weaponInspect");
|
||||
private IAnimatorWrapper wrapper;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (wrapper == null || !wrapper.IsValid)
|
||||
{
|
||||
var animator = GetComponent<Animator>();
|
||||
if (!animator)
|
||||
{
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
wrapper = animator.GetItemAnimatorWrapper();
|
||||
}
|
||||
if (useStateTag)
|
||||
{
|
||||
var stateInfo = wrapper.GetCurrentAnimatorStateInfo(layer);
|
||||
if (stateInfo.IsTag(inspectName) && stateInfo.normalizedTime < finishTime)
|
||||
{
|
||||
wrapper.ResetTrigger(inspectHash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var transInfo = wrapper.GetAnimatorTransitionInfo(layer);
|
||||
if (transInfo.IsUserName(inspectName) && transInfo.normalizedTime < finishTime)
|
||||
{
|
||||
wrapper.ResetTrigger(inspectHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MonoBehaviour Init(Transform playerAnimatorTrans, bool isLocalPlayer)
|
||||
{
|
||||
enabled = false;
|
||||
var copy = isLocalPlayer ? playerAnimatorTrans.AddMissingComponent<AnimationInspectFix>() : null;
|
||||
if (copy)
|
||||
{
|
||||
copy.enabled = true;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
public void Disable(Transform playerAnimatorTrans)
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26c7436085cc1924a882f62d81f262a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
#if NotEditor
|
||||
using KFCommonUtilityLib;
|
||||
using KFCommonUtilityLib.Scripts.StaticManagers;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationLockAction : StateMachineBehaviour
|
||||
{
|
||||
public bool lockReload = false;
|
||||
#if NotEditor
|
||||
private InventorySlotGurad slotGuard = new InventorySlotGurad();
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
var player = animator.GetComponentInParent<EntityAlive>();
|
||||
if (slotGuard.IsValid(player))
|
||||
{
|
||||
if (player.inventory.holdingItemData.actionData[MultiActionManager.GetActionIndexForEntity(player)] is IModuleContainerFor<ActionModuleAnimationLocked.AnimationLockedData> lockData)
|
||||
{
|
||||
lockData.Instance.isLocked = true;
|
||||
if (lockReload)
|
||||
{
|
||||
lockData.Instance.isReloadLocked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
var player = animator.GetComponentInParent<EntityAlive>();
|
||||
if (slotGuard.IsValid(player))
|
||||
{
|
||||
if (player.inventory.holdingItemData.actionData[MultiActionManager.GetActionIndexForEntity(player)] is IModuleContainerFor<ActionModuleAnimationLocked.AnimationLockedData> lockData)
|
||||
{
|
||||
lockData.Instance.isLocked = false;
|
||||
lockData.Instance.isReloadLocked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41af3d052f5a46a4c86c3ffbaf4c7918
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
#if NotEditor
|
||||
using KFCommonUtilityLib.Scripts.StaticManagers;
|
||||
using UAI;
|
||||
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationMultiStageReloadState : StateMachineBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private bool speedUpOnCancel;
|
||||
[SerializeField]
|
||||
private bool immediateCancel;
|
||||
[SerializeField]
|
||||
private float ForceCancelReloadDelay = 1f;
|
||||
[SerializeField]
|
||||
private bool DoNotForceCancel = false;
|
||||
|
||||
private AnimationReloadEvents eventBridge;
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.SetWrappedBool(Animator.StringToHash("Reload"), false);
|
||||
if (eventBridge == null)
|
||||
{
|
||||
eventBridge = animator.GetComponent<AnimationReloadEvents>();
|
||||
}
|
||||
if (stateInfo.IsTag("ReloadStart"))
|
||||
{
|
||||
animator.speed = 1f;
|
||||
animator.SetWrappedBool(Animator.StringToHash("IsReloading"), true);
|
||||
#if NotEditor
|
||||
EntityAlive player = animator.GetComponentInParent<EntityAlive>();
|
||||
int actionIndex = MultiActionManager.GetActionIndexForEntity(player);
|
||||
eventBridge.OnReloadStart(actionIndex);
|
||||
#if DEBUG
|
||||
Log.Out($"start reload {actionIndex}");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if NotEditor
|
||||
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
var actionData = eventBridge.actionData;
|
||||
if (actionData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (actionData.isReloadCancelled)
|
||||
{
|
||||
if (speedUpOnCancel)
|
||||
{
|
||||
Log.Out("Speed up animation!");
|
||||
animator.speed = 30;
|
||||
}
|
||||
|
||||
if (immediateCancel)
|
||||
{
|
||||
animator.SetBool("IsReloading", false);
|
||||
}
|
||||
|
||||
if (!DoNotForceCancel)
|
||||
{
|
||||
eventBridge.DelayForceCancelReload(ForceCancelReloadDelay);
|
||||
}
|
||||
}
|
||||
|
||||
if (actionData.isReloading && animator.GetBool("IsReloading"))
|
||||
{
|
||||
actionData.invData.holdingEntity.MinEventContext.ItemActionData = actionData;
|
||||
actionData.invData.holdingEntity.FireEvent(MinEventTypes.onReloadUpdate, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.speed = 1f;
|
||||
if (stateInfo.IsTag("ReloadEnd"))
|
||||
eventBridge?.OnReloadFinish();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a36e127f3f92d4f4a8c3e3fdabe6e1d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationRandomRecoilState : StateMachineBehaviour
|
||||
{
|
||||
[SerializeField] private Vector3 positionMultiplier = Vector3.one;
|
||||
[SerializeField] private Vector3 rotationMultiplier = Vector3.one;
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.GetComponent<AnimationProceduralRecoildAbs>()?.AddRecoil(positionMultiplier, rotationMultiplier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a853564a7472fea44b9ba42cbf3ae654
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationResetRigWeightState : StateMachineBehaviour
|
||||
{
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.GetComponent<RigWeightOverTime>()?.SetWeight(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cfcbf05cdb32514bab41d81a761cd4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
using UnityEngine.Animations.Rigging;
|
||||
|
||||
public class AnimationRigLayerController : StateMachineBehaviour, ISerializationCallbackReceiver
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[Serializable]
|
||||
public struct State
|
||||
{
|
||||
public byte layer;
|
||||
public bool enable;
|
||||
}
|
||||
[SerializeField]
|
||||
public State[] layerStatesEditor;
|
||||
#endif
|
||||
[SerializeField, HideInInspector]
|
||||
private int[] layers;
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if(layerStatesEditor != null)
|
||||
{
|
||||
layers = new int[layerStatesEditor.Length];
|
||||
for (int i = 0; i < layerStatesEditor.Length; i++)
|
||||
{
|
||||
layers[i] = layerStatesEditor[i].layer | (layerStatesEditor[i].enable ? 0 : 0x8000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (layers == null)
|
||||
return;
|
||||
|
||||
RigBuilder rigBuilder = animator.GetComponent<RigBuilder>();
|
||||
if (rigBuilder && rigBuilder.layers != null)
|
||||
{
|
||||
foreach (var layer in layers)
|
||||
{
|
||||
int realLayer = layer & 0x7fff;
|
||||
if (realLayer >= rigBuilder.layers.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
rigBuilder.layers[realLayer].active = (layer & 0x8000) <= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbb26fa6f1fef8f45b8eaf5702207898
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Utils/Animator Random Switch")]
|
||||
public class AnimatorRandomSwitch : StateMachineBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string parameter;
|
||||
[SerializeField]
|
||||
private int stateCount;
|
||||
|
||||
private int[] stateHits;
|
||||
int totalHits;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
stateHits = new int[stateCount];
|
||||
for (int i = 0; i < stateCount; i++)
|
||||
{
|
||||
stateHits[i] = 1;
|
||||
}
|
||||
totalHits = stateCount;
|
||||
}
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
int rand = Random.Range(0, totalHits);
|
||||
int cur = 0;
|
||||
bool found = false;
|
||||
for (int i = 0; i < stateHits.Length; i++)
|
||||
{
|
||||
cur += stateHits[i];
|
||||
if (cur > rand && !found)
|
||||
{
|
||||
animator.SetInteger(parameter, i);
|
||||
found = true;
|
||||
stateHits[i] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
stateHits[i] = 2;
|
||||
}
|
||||
}
|
||||
totalHits = stateCount * 2 - 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c083a728c43231842a2e50a3c04b4a11
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user