From abc5ef0332b147a805d6eb9fbc7a9b84059b6227 Mon Sep 17 00:00:00 2001 From: marcin Date: Fri, 23 May 2025 09:54:57 +0200 Subject: [PATCH] improvements to magic attacks, full arena logic, improvements to NPCs fresnel rendering for targetting --- .../Beasiculus/Bascileus_BaseModel.prefab | 4 - Assets/Scenes/Fight_Arena/Fight_Arena.unity | 453 +++++++++++++++++- Assets/Scripts/Characters/AutoTargetting.cs | 128 +++-- .../Scripts/Characters/Skills/MagicAttacks.cs | 265 +++++----- Assets/Scripts/Respawner.cs | 2 +- .../Textures/Ghost_Demon.mat | 58 ++- 6 files changed, 673 insertions(+), 237 deletions(-) diff --git a/Assets/Prefabs/Characters/Beasiculus/Bascileus_BaseModel.prefab b/Assets/Prefabs/Characters/Beasiculus/Bascileus_BaseModel.prefab index 114a308d3..82813dd93 100644 --- a/Assets/Prefabs/Characters/Beasiculus/Bascileus_BaseModel.prefab +++ b/Assets/Prefabs/Characters/Beasiculus/Bascileus_BaseModel.prefab @@ -106505,10 +106505,6 @@ MonoBehaviour: animClipName: MagicPush m_selectedType: 1 currentSelectedSpellName: - enableAutoTargetIntegration: 1 - maxTurnTowardDistance: 10 - rotationSpeed: 500 - degreeThreshold: 100 actionInput: useInput: 1 isAxisInUse: 0 diff --git a/Assets/Scenes/Fight_Arena/Fight_Arena.unity b/Assets/Scenes/Fight_Arena/Fight_Arena.unity index f2e196bb8..d27088b27 100644 --- a/Assets/Scenes/Fight_Arena/Fight_Arena.unity +++ b/Assets/Scenes/Fight_Arena/Fight_Arena.unity @@ -626,6 +626,12 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 87289192} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &87992052 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 2631004785151738407, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + m_PrefabInstance: {fileID: 1905404674} + m_PrefabAsset: {fileID: 0} --- !u!4 &99479629 stripped Transform: m_CorrespondingSourceObject: {fileID: 8361884480791188460, guid: 851e8e61247888340bdec90fc8aa37f5, @@ -2210,8 +2216,10 @@ GameObject: - component: {fileID: 289966094} - component: {fileID: 289966093} - component: {fileID: 289966092} + - component: {fileID: 289966097} + - component: {fileID: 289966096} m_Layer: 0 - m_Name: Cube + m_Name: StartTrigger m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -2306,6 +2314,170 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: -39.5, z: 0} +--- !u!114 &289966096 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 289966091} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d3ee7654fb1dcff41b62c9ccb5f3111f, type: 3} + m_Name: + m_EditorClassIdentifier: + m_key: + m_appendSaverTypeToKey: 0 + m_saveAcrossSceneChanges: 1 + m_restoreStateOnStart: 0 + m_fireOnce: 0 + m_wasFired: 0 + m_objectsToEnable: [] + m_objectsToDisable: [] + m_fireOnStart: 0 + m_triggersToFire: [] + m_delay: -1 + m_actionResponse: + barkConversation: + audioClip: {fileID: 0} + responseEvent: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 289966091} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 6 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - m_Target: {fileID: 609186452} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 6 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 1 + m_CallState: 2 + - m_Target: {fileID: 796152177} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 6 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 1 + m_CallState: 2 + delay: 0 + m_materialsToChange: [] +--- !u!82 &289966097 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 289966091} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_Resource: {fileID: 0} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1 &293997863 GameObject: m_ObjectHideFlags: 0 @@ -12886,7 +13058,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &796152178 Transform: m_ObjectHideFlags: 0 @@ -12965,17 +13137,17 @@ MonoBehaviour: OnTrigger: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 796152179} - m_TargetAssemblyTypeName: Beyond.EnemySpawnerManager, Assembly-CSharp - m_MethodName: ResetAllManagedSpawners - m_Mode: 1 + - m_Target: {fileID: 87992052} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 6 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: - m_BoolArgument: 0 + m_BoolArgument: 1 m_CallState: 2 --- !u!1 &799294618 GameObject: @@ -19814,6 +19986,18 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 04fcf3aba7782a94e9ad337e474800d7, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &1516777702 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 7158301901963754683, guid: 851e8e61247888340bdec90fc8aa37f5, + type: 3} + m_PrefabInstance: {fileID: 1004473948} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1447701206} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 38b9f160099a9484b936b7192dd82968, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!21 &1523257492 Material: serializedVersion: 8 @@ -21577,6 +21761,261 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: selectedToolbar + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.size + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.size + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[1].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[2].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[3].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[4].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[1].m_Target + value: + objectReference: {fileID: 796152177} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[2].m_Target + value: + objectReference: {fileID: 1516777702} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[3].m_Target + value: + objectReference: {fileID: 609186452} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[4].m_Target + value: + objectReference: {fileID: 289966091} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[2].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[3].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[4].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[5].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[3].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[4].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName + value: SetActive + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[2].m_MethodName + value: Respawn + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[3].m_MethodName + value: SetActive + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[4].m_MethodName + value: SetActive + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[2].m_Target + value: + objectReference: {fileID: 796152177} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[3].m_Target + value: + objectReference: {fileID: 1516777702} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[4].m_Target + value: + objectReference: {fileID: 609186452} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[5].m_Target + value: + objectReference: {fileID: 289966091} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[3].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[4].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[5].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[2].m_MethodName + value: SetActive + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[3].m_MethodName + value: Respawn + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[4].m_MethodName + value: SetActive + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[5].m_MethodName + value: SetActive + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[1].m_TargetAssemblyTypeName + value: UnityEngine.GameObject, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[2].m_TargetAssemblyTypeName + value: Beyond.Respawner, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[3].m_TargetAssemblyTypeName + value: UnityEngine.GameObject, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[4].m_TargetAssemblyTypeName + value: UnityEngine.GameObject, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[1].m_Arguments.m_BoolArgument + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[4].m_Arguments.m_BoolArgument + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[2].m_TargetAssemblyTypeName + value: UnityEngine.GameObject, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[3].m_TargetAssemblyTypeName + value: Beyond.Respawner, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[4].m_TargetAssemblyTypeName + value: UnityEngine.GameObject, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[5].m_TargetAssemblyTypeName + value: UnityEngine.GameObject, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[2].m_Arguments.m_BoolArgument + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[5].m_Arguments.m_BoolArgument + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[3].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnEndAnimation.m_PersistentCalls.m_Calls.Array.data[4].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[2].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[3].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[4].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738405, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: OnPressActionInput.m_PersistentCalls.m_Calls.Array.data[5].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 2631004785151738407, guid: bdcc0504e0c523b4492037e978d716f4, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8404356872023224400, guid: bdcc0504e0c523b4492037e978d716f4, type: 3} propertyPath: m_Name diff --git a/Assets/Scripts/Characters/AutoTargetting.cs b/Assets/Scripts/Characters/AutoTargetting.cs index 82096e2c0..377a0ee49 100644 --- a/Assets/Scripts/Characters/AutoTargetting.cs +++ b/Assets/Scripts/Characters/AutoTargetting.cs @@ -1,6 +1,7 @@ using UnityEngine; using System.Collections; using System.Collections.Generic; +using System.Linq; // Required for List.AddRange and ToArray using Invector.vCharacterController.AI.FSMBehaviour; // For vFSMBehaviourController using Beyond; // For GameStateManager and Player (ensure Player.cs is in this namespace or adjust) using System; // For Action @@ -16,8 +17,8 @@ public class AutoTargetting : MonoBehaviour public float targetingAngleThreshold = 90f; [Header("Rotation Parameters")] - [Tooltip("Speed at which the player rotates towards the current target when rotation is explicitly called.")] - public float playerRotationSpeed = 10f; + [Tooltip("Speed at which the player rotates towards the current target when rotation is explicitly called (e.g., by MagicAttacks).")] + public float playerRotationSpeed = 10f; // This will be used by MagicAttacks [Header("Visuals")] [Tooltip("Name of the material color property to animate for Fresnel effect.")] @@ -30,8 +31,8 @@ public class AutoTargetting : MonoBehaviour public Color deselectHighlightColor = Color.black; [Tooltip("Duration of the fade in/out animation for the highlight.")] public float highlightFadeDuration = 0.3f; - [Tooltip("If true, will try to find a SkinnedMeshRenderer first, then MeshRenderer. If false, affects all renderers.")] - public bool preferSkinnedMeshRenderer = true; + [Tooltip("If true, was previously used to prefer SkinnedMeshRenderer. Now GetTargetRenderers collects both SkinnedMeshRenderers and MeshRenderers regardless of this flag. This flag might be repurposed or removed in the future.")] + public bool preferSkinnedMeshRenderer = true; // Note: Its effect on GetTargetRenderers is changed. public vFSMBehaviourController CurrentTarget { get; private set; } public event Action OnTargetSelected; @@ -45,7 +46,7 @@ public class AutoTargetting : MonoBehaviour void Start() { - if (Player.Instance == null) // Player.Instance should be set by its own Awake + if (Player.Instance == null) { Debug.LogError("AutoTargetting: Player.Instance is not available at Start! Ensure Player script with static Instance exists and runs before AutoTargetting."); enabled = false; @@ -57,7 +58,7 @@ public class AutoTargetting : MonoBehaviour if (_gameStateManager != null) { _gameStateManager.m_OnStateChanged.AddListener(HandleGameStateChanged); - HandleGameStateChanged(_gameStateManager.CurrentState); // Initialize based on current state + HandleGameStateChanged(_gameStateManager.CurrentState); } else { @@ -98,17 +99,16 @@ public class AutoTargetting : MonoBehaviour _targetingLoopCoroutine = StartCoroutine(TargetingLoop()); } } - else // State is NORMAL or other non-combat + else { if (_targetingLoopCoroutine != null) { StopCoroutine(_targetingLoopCoroutine); _targetingLoopCoroutine = null; } - if (CurrentTarget != null) // If there was a target, deselect it + if (CurrentTarget != null) { - vFSMBehaviourController oldTarget = CurrentTarget; - SetNewTarget(null); // This will handle fade out and event + SetNewTarget(null); } } } @@ -117,12 +117,12 @@ public class AutoTargetting : MonoBehaviour { while (true) { - if (_playerTransform == null && Player.Instance != null) // Defensive: re-cache if player was respawned or similar + if (_playerTransform == null && Player.Instance != null) { _playerTransform = Player.Instance.transform; } - if (_playerTransform != null) // Only proceed if we have a valid player transform + if (_playerTransform != null) { UpdateTarget(); } @@ -130,9 +130,6 @@ public class AutoTargetting : MonoBehaviour } } - /// - /// Checks if the given AI target is within the specified angle from the source transform's forward direction. - /// public bool IsTargetInAngle(Transform sourceTransform, vFSMBehaviourController targetAI, float angleThreshold) { if (targetAI == null || sourceTransform == null) @@ -141,9 +138,8 @@ public class AutoTargetting : MonoBehaviour } Vector3 directionToTarget = (targetAI.transform.position - sourceTransform.position); - directionToTarget.y = 0; // Consider only horizontal angle + directionToTarget.y = 0; - // If target is effectively at the same horizontal position, consider it in angle. if (directionToTarget.sqrMagnitude < 0.0001f) return true; directionToTarget.Normalize(); @@ -162,7 +158,7 @@ public class AutoTargetting : MonoBehaviour if (combatControllers == null || combatControllers.Count == 0) { - if (CurrentTarget != null) SetNewTarget(null); // No enemies, clear current + if (CurrentTarget != null) SetNewTarget(null); return; } @@ -173,20 +169,14 @@ public class AutoTargetting : MonoBehaviour continue; } - // Check 1: Is target within selection angle? if (!IsTargetInAngle(_playerTransform, controller, targetingAngleThreshold)) { continue; } - // Check 2: Is target within selection distance? float distSqr = (controller.transform.position - _playerTransform.position).sqrMagnitude; - if (distSqr <= minDistanceSqr) // distSqr must also be <= maxTargetingDistance^2 due to minDistanceSqr initialization + if (distSqr <= minDistanceSqr) { - // If multiple targets are at similar very close distances, this might pick the "last one" processed. - // For more refined "closest", ensure this is strictly '<' for new candidates, - // or add a secondary sort criterion if multiple are at exact same minDistanceSqr. - // Current logic is fine for most cases. minDistanceSqr = distSqr; bestCandidate = controller; } @@ -196,27 +186,22 @@ public class AutoTargetting : MonoBehaviour { SetNewTarget(bestCandidate); } - else if (CurrentTarget != null && !IsTargetValid(CurrentTarget)) // Current target became invalid (e.g. died, moved out of range/angle) + else if (CurrentTarget != null && !IsTargetValid(CurrentTarget)) { SetNewTarget(null); } } - /// - /// Checks if a given target is still valid according to AutoTargetting's rules. - /// private bool IsTargetValid(vFSMBehaviourController target) { if (target == null || !target.gameObject.activeInHierarchy || target.aiController.currentHealth <= 0) return false; - if (_playerTransform == null) return false; // Should not happen if script is active + if (_playerTransform == null) return false; - // Check 1: Angle (using AutoTargetting's own targetingAngleThreshold) if (!IsTargetInAngle(_playerTransform, target, targetingAngleThreshold)) return false; - // Check 2: Distance (using AutoTargetting's own maxTargetingDistance) float distSqr = (target.transform.position - _playerTransform.position).sqrMagnitude; return distSqr <= maxTargetingDistance * maxTargetingDistance; } @@ -225,26 +210,21 @@ public class AutoTargetting : MonoBehaviour { if (CurrentTarget == newTarget) return; - // Deselect previous target if (CurrentTarget != null) { - ApplyHighlight(CurrentTarget, false); // Fade out + ApplyHighlight(CurrentTarget, false); OnTargetDeselected?.Invoke(CurrentTarget); } CurrentTarget = newTarget; - // Select new target if (CurrentTarget != null) { - ApplyHighlight(CurrentTarget, true); // Fade in + ApplyHighlight(CurrentTarget, true); OnTargetSelected?.Invoke(CurrentTarget); } } - /// - /// Smoothly rotates the player character towards the CurrentTarget on the horizontal plane. - /// public void ExecuteRotationTowardsCurrentTarget(float deltaTime) { if (CurrentTarget == null || _playerTransform == null) @@ -255,17 +235,13 @@ public class AutoTargetting : MonoBehaviour Vector3 directionToTarget = CurrentTarget.transform.position - _playerTransform.position; directionToTarget.y = 0f; - if (directionToTarget.sqrMagnitude < 0.0001f) return; // Already at target or too close to get a direction + if (directionToTarget.sqrMagnitude < 0.0001f) return; directionToTarget.Normalize(); Quaternion targetRotation = Quaternion.LookRotation(directionToTarget); _playerTransform.rotation = Quaternion.Lerp(_playerTransform.rotation, targetRotation, deltaTime * playerRotationSpeed); } - /// - /// Gets the health of the CurrentTarget. - /// - /// The health of the CurrentTarget, or -1f if no target or target has no health component. public float GetCurrentTargetHealth() { if (CurrentTarget != null && CurrentTarget.aiController != null) @@ -280,26 +256,51 @@ public class AutoTargetting : MonoBehaviour SetNewTarget(null); if (findNewOneImmediately && _gameStateManager != null && _gameStateManager.CurrentState == GameStateManager.State.COMBAT) { - UpdateTarget(); // Attempt to find a new one if in combat + UpdateTarget(); } } + // *** MODIFIED GetTargetRenderers METHOD *** private Renderer[] GetTargetRenderers(vFSMBehaviourController targetController) { if (targetController == null) return new Renderer[0]; - if (preferSkinnedMeshRenderer) + List collectedRenderers = new List(); + + // Collect all SkinnedMeshRenderers + SkinnedMeshRenderer[] smrs = targetController.GetComponentsInChildren(true); + if (smrs != null && smrs.Length > 0) { - SkinnedMeshRenderer smr = targetController.GetComponentInChildren(); - if (smr != null) return new Renderer[] { smr }; - - MeshRenderer mr = targetController.GetComponentInChildren(); - if (mr != null) return new Renderer[] { mr }; + collectedRenderers.AddRange(smrs); + } + + // Collect all MeshRenderers + MeshRenderer[] mrs = targetController.GetComponentsInChildren(true); + if (mrs != null && mrs.Length > 0) + { + collectedRenderers.AddRange(mrs); } - return targetController.GetComponentsInChildren(true); // Include inactive renderers if any + // If no specific SMRs or MRs were found, fall back to all Renderers (optional, but good for safety) + // Or, if the goal is *only* SMRs and MRs, this fallback can be removed. + // For now, let's assume we want to highlight *something* if possible. + // If you strictly want ONLY SMRs and MRs, and nothing else, remove this 'if' block. + if (collectedRenderers.Count == 0) + { + Renderer[] allRenderers = targetController.GetComponentsInChildren(true); + if (allRenderers != null && allRenderers.Length > 0) + { + collectedRenderers.AddRange(allRenderers); + } + } + + // The preferSkinnedMeshRenderer flag is not directly used here for filtering types anymore. + // It could potentially be used for ordering or other logic if needed in the future. + + return collectedRenderers.Distinct().ToArray(); // Distinct() to avoid duplicates if an object somehow has multiple relevant renderer types } + private void ApplyHighlight(vFSMBehaviourController targetController, bool fadeIn) { if (targetController == null || string.IsNullOrEmpty(materialHighlightPropertyName)) return; @@ -310,12 +311,10 @@ public class AutoTargetting : MonoBehaviour { if (rend == null) continue; - // Use rend.materials to get instances for modification foreach (Material mat in rend.materials) { if (mat == null || !mat.HasProperty(materialHighlightPropertyName)) continue; - // Stop any existing fade coroutine for this specific material if (_materialToFadeCoroutineMap.TryGetValue(mat, out Coroutine existingCoroutine) && existingCoroutine != null) { StopCoroutine(existingCoroutine); @@ -324,7 +323,6 @@ public class AutoTargetting : MonoBehaviour Color currentColor = mat.GetColor(materialHighlightPropertyName); Color targetColor = fadeIn ? highlightColor : deselectHighlightColor; - // Smartly store original color only if not already a highlight/deselect color. if (fadeIn) { if (!_originalMaterialColors.ContainsKey(mat) || @@ -333,15 +331,6 @@ public class AutoTargetting : MonoBehaviour _originalMaterialColors[mat] = currentColor; } } - // When fading out, if an original was stored, we could potentially use it instead of always deselectHighlightColor. - // However, for a consistent "off" state, deselectHighlightColor (e.g., black) is usually desired. - // If fading out and original exists and isn't black: - // else if (_originalMaterialColors.TryGetValue(mat, out Color original) && original != deselectHighlightColor) - // { - // targetColor = original; // Fade back to true original - // } - - Coroutine newFadeCoroutine = StartCoroutine(FadeMaterialPropertyCoroutine(mat, currentColor, targetColor, highlightFadeDuration)); _materialToFadeCoroutineMap[mat] = newFadeCoroutine; } @@ -351,11 +340,10 @@ public class AutoTargetting : MonoBehaviour private IEnumerator FadeMaterialPropertyCoroutine(Material material, Color fromValue, Color toValue, float duration) { float timer = 0f; - // yield return null; // Not strictly necessary here as StopCoroutine handles overlaps. while (timer < duration) { - if (material == null) yield break; // Material might have been destroyed + if (material == null) yield break; timer += Time.deltaTime; float progress = Mathf.Clamp01(timer / duration); @@ -363,15 +351,9 @@ public class AutoTargetting : MonoBehaviour yield return null; } - if (material != null) // Final set + if (material != null) { material.SetColor(materialHighlightPropertyName, toValue); } - - // Optional: Remove from map if coroutine completed naturally and is still the one in the map. - // if (_materialToFadeCoroutineMap.TryGetValue(material, out Coroutine currentMappedCoroutine) && currentMappedCoroutine == /*this specific instance, tricky to get*/) - // { - // _materialToFadeCoroutineMap.Remove(material); - // } } } \ No newline at end of file diff --git a/Assets/Scripts/Characters/Skills/MagicAttacks.cs b/Assets/Scripts/Characters/Skills/MagicAttacks.cs index b162a8669..de7232bb6 100644 --- a/Assets/Scripts/Characters/Skills/MagicAttacks.cs +++ b/Assets/Scripts/Characters/Skills/MagicAttacks.cs @@ -6,14 +6,14 @@ using Invector; using Invector.vCharacterController; using Invector.vCharacterController.vActions; using Sirenix.OdinInspector; -// using UnityEditor; // Best to remove if not strictly needed for runtime +// using UnityEditor; using UnityEngine; using UnityEngine.Events; using UnityEngine.VFX; -// using static Invector.vObjectDamage; // Not used directly, consider removing +// using static Invector.vObjectDamage; using DG.Tweening; using Invector.vCharacterController.AI.FSMBehaviour; -using Beyond; // For Player, GameStateManager, AutoTargetting (if Player.Instance.AutoTarget is of this type) +using Beyond; namespace Beyond { @@ -51,8 +51,8 @@ namespace Beyond private Coroutine lastPushRoutine = null; private ParticleSystem flame; private BoxCollider flameDamager; - private bLockOn lockOn; // Retained for fallback aiming or non-combat interactions if needed - private const float fireballAimerThreshold = -1.0f; // Used for fallback aiming if no auto-target + private bLockOn lockOn; + private const float fireballAimerThreshold = -1.0f; private const float fireballAimerHeightAdjuster = 0.1f; private const float fireballDamagerDuration = 0.3f; private const float fireballTargetYPositionOffset = 0.75f; @@ -64,21 +64,12 @@ namespace Beyond private bool canPlayNoFaithClip = true; private bool canPlayCantDoClip = true; - // NEW: AutoTargetting fields private AutoTargetting _autoTargettingInstance; + // REMOVED: public bool enableAutoTargetIntegration = true; + // REMOVED: public float maxTurnTowardDistance = 10f; + // REMOVED: public float rotationSpeed = 500f; + // REMOVED: public float degreeThreshold = 100f; (already removed in previous step) - [BoxGroup("Auto targetting")] - [Tooltip("Enable to use AutoTargetting for player rotation and spell aiming.")] - public bool enableAutoTargetIntegration = true; - [BoxGroup("Auto targetting")] - [Tooltip("Max distance for player to turn towards an auto-target during spell casting.")] - public float maxTurnTowardDistance = 10f; - [BoxGroup("Auto targetting")] - [Tooltip("Rotation speed when turning towards an auto-target.")] - public float rotationSpeed = 500f; - [BoxGroup("Auto targetting")] - [Tooltip("Angle threshold within which the player will rotate towards an auto-target.")] - public float degreeThreshold = 100f; public UnityAction onHitFireball; @@ -86,20 +77,19 @@ namespace Beyond { tpInput = GetComponent(); - // NEW: Initialize AutoTargetting instance if (Player.Instance != null) { - _autoTargettingInstance = Player.Instance.AutoTarget; // Assuming Player.Instance has an AutoTarget property of type AutoTargetting - if (_autoTargettingInstance == null && enableAutoTargetIntegration) + _autoTargettingInstance = Player.Instance.AutoTarget; + if (_autoTargettingInstance == null) // Simplified warning { - Debug.LogWarning("MagicAttacks: AutoTargetting component not found on Player.Instance.AutoTarget, but enableAutoTargetIntegration is true. Targeting features will be limited."); + Debug.LogWarning("MagicAttacks: AutoTargetting component not found on Player.Instance.AutoTarget. Auto-targeting features will not be available."); } } else { Debug.LogError("MagicAttacks: Player.Instance is null in Awake. Cannot get AutoTargetting component."); } - lockOn = GetComponent(); // Keep for potential fallback + lockOn = GetComponent(); EffectDesc mpush = m_effects[(int)EffectType.MAGIC_PUSH]; EffectDesc flameThrowe = m_effects[(int)EffectType.FLAME_THROWER]; @@ -165,8 +155,8 @@ namespace Beyond [Button] private void OnSilentPeek() { - StopCoroutine(SilentPeekCoroutine()); - StartCoroutine(SilentPeekCoroutine()); + StopCoroutine(nameof(SilentPeekCoroutine)); + StartCoroutine(nameof(SilentPeekCoroutine)); } private IEnumerator SilentPeekCoroutine() @@ -202,13 +192,12 @@ namespace Beyond private IEnumerator MagicPushCoroutine() { EffectDesc mpush = m_effects[(int)EffectType.MAGIC_PUSH]; - // MODIFIED: Use TurnTowardTargetCoroutine for potential rotation during wind-up yield return TurnTowardTargetCoroutine(mpush.startTime); mpush.effectObject.SetActive(false); mpush.effectObject.SetActive(true); yield return new WaitForSeconds(mpush.delay); - Debug.Log("Bum!"); // Consider replacing with actual effect logic - yield return new WaitForSeconds(mpush.endTime); // This is endTime after delay, might be confusing. + Debug.Log("Bum!"); + yield return new WaitForSeconds(mpush.endTime); mpush.effectObject.SetActive(false); yield return null; } @@ -221,13 +210,12 @@ namespace Beyond private IEnumerator FlameThrowerhCoroutine() { EffectDesc flameThrowe = m_effects[(int)EffectType.FLAME_THROWER]; - // MODIFIED: TurnTowardTargetCoroutine will handle rotation based on AutoTargetting yield return TurnTowardTargetCoroutine(flameThrowe.startTime); flameDamager.enabled = true; flame.Play(); - yield return new WaitForSeconds(flameThrowe.endTime); // Duration of flame + yield return new WaitForSeconds(flameThrowe.endTime); flame.Stop(); - yield return new WaitForSeconds(flameThrowe.delay); // Cooldown/after-effect + yield return new WaitForSeconds(flameThrowe.delay); flameDamager.enabled = false; yield return null; } @@ -241,11 +229,10 @@ namespace Beyond private IEnumerator ScanCoroutine() { EffectDesc scan = m_effects[(int)EffectType.SCAN]; - // Scan might not need rotation, but if it had a wind-up animation, TurnTowardTargetCoroutine could be used. yield return new WaitForSeconds(scan.startTime); - float time = scan.startTime - scan.delay; // This calculation seems off if delay is for after effect. Assuming startTime is actual start. + float time = scan.startTime - scan.delay; float maxRange = 50f; - float speed = maxRange / (scan.endTime - scan.startTime); // scan.endTime is duration here + float speed = maxRange / (scan.endTime - scan.startTime); int mask = 1 << LayerMask.NameToLayer("Triggers") | 1 << LayerMask.NameToLayer("HiddenObject"); if (scan.effectObject) { @@ -258,11 +245,11 @@ namespace Beyond while (waveEffectTimer < waveEffectDuration) { - Shader.SetGlobalFloat("_WaveTime", speed * waveEffectTimer); // Use timer relative to effect start + Shader.SetGlobalFloat("_WaveTime", speed * waveEffectTimer); waveEffectTimer += Time.deltaTime; yield return null; } - Shader.SetGlobalFloat("_WaveTime", 0f); // Reset shader global + Shader.SetGlobalFloat("_WaveTime", 0f); var colliders = Physics.OverlapSphere(transform.position, maxRange, mask); foreach (var c in colliders) { @@ -270,7 +257,7 @@ namespace Beyond if (h != null) h.OnScanned(); } - if (scan.effectObject) scan.effectObject.SetActive(false); // Deactivate after use + if (scan.effectObject) scan.effectObject.SetActive(false); yield return null; } @@ -279,12 +266,11 @@ namespace Beyond StartCoroutine(FireballCoroutine()); } - // MODIFIED: Centralized coroutine for turning towards target during spell animations private IEnumerator TurnTowardTargetCoroutine(float maxDuration) { - if (!enableAutoTargetIntegration || _autoTargettingInstance == null) + // *** MODIFIED: Condition relies only on _autoTargettingInstance and its CurrentTarget *** + if (_autoTargettingInstance == null || _autoTargettingInstance.CurrentTarget == null) { - // If auto-targeting is off or unavailable, just wait for the duration without rotation. if (maxDuration > 0) yield return new WaitForSeconds(maxDuration); yield break; } @@ -292,31 +278,34 @@ namespace Beyond float timeElapsed = 0; while (timeElapsed < maxDuration) { + // Re-check CurrentTarget in loop in case it becomes null (e.g., target dies mid-turn) if (_autoTargettingInstance.CurrentTarget != null) { vFSMBehaviourController currentTarget = _autoTargettingInstance.CurrentTarget; - Transform playerTransform = transform; // Character's transform + Transform playerTransform = transform; float distSqr = (currentTarget.transform.position - playerTransform.position).sqrMagnitude; - // Check distance using MagicAttacks.maxTurnTowardDistance - if (distSqr <= maxTurnTowardDistance * maxTurnTowardDistance) + if (distSqr <= _autoTargettingInstance.maxTargetingDistance * _autoTargettingInstance.maxTargetingDistance) { - // Check angle using MagicAttacks.degreeThreshold and AutoTargetting's utility - if (_autoTargettingInstance.IsTargetInAngle(playerTransform, currentTarget, degreeThreshold)) + if (_autoTargettingInstance.IsTargetInAngle(playerTransform, currentTarget, _autoTargettingInstance.targetingAngleThreshold)) { Vector3 directionToTarget = currentTarget.transform.position - playerTransform.position; - directionToTarget.y = 0f; // Horizontal rotation only + directionToTarget.y = 0f; - if (directionToTarget.sqrMagnitude > 0.0001f) // Ensure there's a direction + if (directionToTarget.sqrMagnitude > 0.0001f) { Quaternion targetRotation = Quaternion.LookRotation(directionToTarget.normalized); - // Use MagicAttacks.rotationSpeed for the rotation - playerTransform.rotation = Quaternion.RotateTowards(playerTransform.rotation, targetRotation, Time.deltaTime * rotationSpeed); + // *** MODIFIED: Use playerRotationSpeed from AutoTargetting *** + playerTransform.rotation = Quaternion.RotateTowards(playerTransform.rotation, targetRotation, Time.deltaTime * _autoTargettingInstance.playerRotationSpeed); } } } } + else // Target became null during the loop + { + yield break; // Exit if no target + } timeElapsed += Time.deltaTime; yield return null; } @@ -324,11 +313,10 @@ namespace Beyond private IEnumerator FireballCoroutine() { - EffectDesc fireball = m_effects[(int)EffectType.FIREBALL]; - // MODIFIED: Use new TurnTowardTargetCoroutine - yield return TurnTowardTargetCoroutine(fireball.startTime); + EffectDesc fireballDesc = m_effects[(int)EffectType.FIREBALL]; // Renamed to avoid conflict + yield return TurnTowardTargetCoroutine(fireballDesc.startTime); - var fireballClone = Instantiate(fireball.effectObject, fireball.effectObject.transform.position, fireball.effectObject.transform.rotation); + var fireballClone = Instantiate(fireballDesc.effectObject, fireballDesc.effectObject.transform.position, fireballDesc.effectObject.transform.rotation); fireballClone.SetActive(true); RFX4_PhysicsMotion fireballMotionController = fireballClone.GetComponentInChildren(); if (fireballMotionController != null) @@ -341,66 +329,81 @@ namespace Beyond fireballDamageComponent.onHit.AddListener(onHitFireball); } - // MODIFIED: Use new AimFireball method AimFireball(fireballClone); - Destroy(fireballClone, 10f); // Self-destruct after time + Destroy(fireballClone, 10f); yield return null; } private void EnableBrieflyFireballDamager(object sender, RFX4_PhysicsMotion.RFX4_CollisionInfo e) { RFX4_PhysicsMotion rFX4_PhysicsMotion = (RFX4_PhysicsMotion)sender; - CapsuleCollider collider = rFX4_PhysicsMotion.GetComponentInChildren(); // Assuming damager is a CapsuleCollider + CapsuleCollider collider = rFX4_PhysicsMotion.GetComponentInChildren(); if(collider != null) StartCoroutine(EnableBrieflyFireballDamagerCoroutine(collider)); } - // NEW: Refactored fireball aiming logic private void AimFireball(GameObject fireballClone) { - Vector3 aimDirection = transform.forward; // Default aim is player's forward + Vector3 aimDirection = transform.forward; - if (enableAutoTargetIntegration && _autoTargettingInstance != null && _autoTargettingInstance.CurrentTarget != null) + // *** MODIFIED: Condition relies only on _autoTargettingInstance and its CurrentTarget *** + if (_autoTargettingInstance != null && _autoTargettingInstance.CurrentTarget != null) { vFSMBehaviourController autoTarget = _autoTargettingInstance.CurrentTarget; - Vector3 targetPosition = autoTarget.transform.position; - targetPosition.y += fireballTargetYPositionOffset; // Adjust height for aiming - aimDirection = (targetPosition - fireballClone.transform.position).normalized; + Transform playerTransform = transform; + + float distSqrToAutoTarget = (autoTarget.transform.position - playerTransform.position).sqrMagnitude; + + if (distSqrToAutoTarget <= _autoTargettingInstance.maxTargetingDistance * _autoTargettingInstance.maxTargetingDistance && + _autoTargettingInstance.IsTargetInAngle(playerTransform, autoTarget, _autoTargettingInstance.targetingAngleThreshold)) + { + Vector3 targetPosition = autoTarget.transform.position; + targetPosition.y += fireballTargetYPositionOffset; + aimDirection = (targetPosition - fireballClone.transform.position).normalized; + } } - else if (lockOn != null && lockOn.isLockingOn && lockOn.currentTarget != null) // Fallback to bLockOn target + + if (aimDirection == transform.forward && lockOn != null && lockOn.isLockingOn && lockOn.currentTarget != null) { Vector3 targetPosition = lockOn.currentTarget.position; targetPosition.y += fireballTargetYPositionOffset; aimDirection = (targetPosition - fireballClone.transform.position).normalized; } - else if (lockOn != null) // Fallback to nearest enemy in front (from bLockOn) + else if (aimDirection == transform.forward && lockOn != null) { - List closeEnemies = lockOn.GetNearbyTargets(); + List closeEnemies = lockOn.GetNearbyTargets(); if (closeEnemies.Count > 0) { - foreach (var enemyTransform in closeEnemies) // Find first suitable enemy in front + Transform bestFallbackTarget = null; + float minAngle = float.MaxValue; + + foreach (var enemyTransform in closeEnemies) { - Vector3 targetPosition = enemyTransform.position; - targetPosition.y += fireballTargetYPositionOffset; - Vector3 directionToEnemy = (targetPosition - fireballClone.transform.position).normalized; - - // Check if enemy is generally in front of the player (fireball origin) - if (Vector3.Dot(transform.forward, directionToEnemy) > fireballAimerThreshold) + Vector3 directionToEnemyFromPlayer = (enemyTransform.position - transform.position).normalized; + float angleToEnemy = Vector3.Angle(transform.forward, directionToEnemyFromPlayer); + + if (Vector3.Dot(transform.forward, directionToEnemyFromPlayer) > fireballAimerThreshold) { - aimDirection = directionToEnemy; - break; + if (angleToEnemy < minAngle) { + minAngle = angleToEnemy; + bestFallbackTarget = enemyTransform; + } } } + if (bestFallbackTarget != null) + { + Vector3 targetPosition = bestFallbackTarget.position; + targetPosition.y += fireballTargetYPositionOffset; + aimDirection = (targetPosition - fireballClone.transform.position).normalized; + } } } - // Apply calculated aim direction to the fireball, adding vertical adjustment Vector3 finalAimDirection = new Vector3(aimDirection.x, aimDirection.y + fireballAimerHeightAdjuster, aimDirection.z); if (finalAimDirection.sqrMagnitude > 0.001f) { fireballClone.transform.rotation = Quaternion.LookRotation(finalAimDirection.normalized); } - // If aimDirection is zero (shouldn't happen with defaults), it will use its instantiated rotation. } @@ -413,26 +416,24 @@ namespace Beyond public void Shield() { - StopCoroutine(ShieldCoroutine()); // Ensure only one shield coroutine runs - StartCoroutine(ShieldCoroutine()); + StopCoroutine(nameof(ShieldCoroutine)); + StartCoroutine(nameof(ShieldCoroutine)); } private IEnumerator ShieldCoroutine() { shieldAnimationIsActive = true; - // Shield typically doesn't need offensive targeting/rotation. - // If there was a wind-up animation where player *should* face an enemy, TurnTowardTargetCoroutine could be used. yield return new WaitForSeconds(shield.startTime); shieldEffectIsActive = true; shieldEffectController.InitializeEffect(); shield.effectObject.SetActive(true); shieldCollisionController.shieldCollider.enabled = true; - yield return new WaitForSeconds(shield.endTime); // Duration shield is active + yield return new WaitForSeconds(shield.endTime); shieldEffectController.DisableEffect(); - yield return new WaitForSeconds(shield.delay / 2f); // Fade out time part 1 + yield return new WaitForSeconds(shield.delay / 2f); shieldEffectIsActive = false; shieldCollisionController.shieldCollider.enabled = false; - yield return new WaitForSeconds(shield.delay / 2f); // Fade out time part 2 + yield return new WaitForSeconds(shield.delay / 2f); shield.effectObject.SetActive(false); shieldAnimationIsActive = false; } @@ -450,21 +451,21 @@ namespace Beyond [Tooltip("Input to trigger the custom animation")] public GenericInput actionInput = new GenericInput("L", "L", "L"); [Tooltip("Name of the animation clip")] - public string animationClip; // This will be set by selectedEffect.animClipName + public string animationClip; [Tooltip("Where in the end of the animation will trigger the event OnEndAnimation")] public float animationEnd = 0.8f; - public UnityEvent OnPlayAnimation; // Consider if this is still needed or how it fits + public UnityEvent OnPlayAnimation; public UnityEvent OnEndAnimation; - public bool isPlaying; // Tracks if the spell animation is currently playing - protected bool triggerOnce; // For OnEndAnimation event - protected vThirdPersonInput tpInput; // Renamed from tpInput to avoid conflict with Invector's tpInput if any confusion + public bool isPlaying; + protected bool triggerOnce; + protected bThirdPersonInput tpInput; internal bool shieldEffectIsActive; private bool shieldAnimationIsActive; private int equipAreaSelectedIndex = 0; - protected virtual void LateUpdate() // LateUpdate for animation state checks is common + protected virtual void LateUpdate() { TriggerSpellAnimation(); AnimationBehaviour(); @@ -481,7 +482,7 @@ namespace Beyond public void TryToPlaySpellAnimation() { - selectedEffect = GetCurrentlySelectedPower(); // Ensure current selected effect is fetched + selectedEffect = GetCurrentlySelectedPower(); if (selectedEffect == shield && shieldAnimationIsActive) { @@ -489,7 +490,7 @@ namespace Beyond return; } - if (Player.Instance == null) // Safeguard + if (Player.Instance == null) { Debug.LogError("Player.Instance is null. Cannot cast spell."); return; @@ -498,37 +499,33 @@ namespace Beyond if (selectedEffect != null && currentSpellFaithCost <= Player.Instance.GetCurrentFaithValue()) { Player.Instance.UpdateFaithCurrentValue(-currentSpellFaithCost); - animationClip = selectedEffect.animClipName; // Set animation clip for AnimationBehaviour + animationClip = selectedEffect.animClipName; - // NEW: Perform initial snap rotation if auto-targeting is enabled - if (enableAutoTargetIntegration) + // *** MODIFIED: Snap look if AutoTargetting is available and has a target *** + if (_autoTargettingInstance != null && _autoTargettingInstance.CurrentTarget != null) { - SnapLookTowardsAutoTarget(); + SnapLookTowardsAutoTarget(); } - // else // OLD logic for turning - can be removed or kept as fallback - // { - // TryToTurnTowordsEnemy(); - // } if (tpInput != null && tpInput.cc != null && tpInput.cc.animator != null) { tpInput.cc.animator.CrossFadeInFixedTime(animationClip, 0.1f); - OnPlayAnimation.Invoke(); // Invoke OnPlay event - triggerOnce = true; // Allow OnEndAnimation to be called + OnPlayAnimation.Invoke(); + triggerOnce = true; } else { Debug.LogError("Cannot play spell animation: tpInput or its components are null."); - return; // Don't proceed to call delegate if animation components are missing + return; } - selectedEffect.del?.Invoke(); // Call the spell's primary action delegate + selectedEffect.del?.Invoke(); if (powersArea.equipSlots[equipAreaSelectedIndex].item.destroyAfterUse) { if (selectedEffect == silentPeek) { - // Special handling for Silent Peek item destruction (likely in its controller) + // Special handling } else { @@ -536,39 +533,37 @@ namespace Beyond } } } - else if (selectedEffect != null) // Not enough faith + else if (selectedEffect != null) { TryToPlayNoEnoughFaithClip(); } - // If selectedEffect is null, nothing happens (no spell selected/valid) } - // NEW: Method for an immediate snap-look towards the auto-target private void SnapLookTowardsAutoTarget() { + // *** MODIFIED: Condition relies only on _autoTargettingInstance and its CurrentTarget *** + // This check is somewhat redundant due to call site, but good for safety if called elsewhere. if (_autoTargettingInstance == null || _autoTargettingInstance.CurrentTarget == null) { - return; // No auto-target system or no current target + return; } vFSMBehaviourController currentTarget = _autoTargettingInstance.CurrentTarget; Transform playerTransform = transform; - // Check distance condition from MagicAttacks settings float distSqr = (currentTarget.transform.position - playerTransform.position).sqrMagnitude; - if (distSqr > maxTurnTowardDistance * maxTurnTowardDistance) + if (distSqr > _autoTargettingInstance.maxTargetingDistance * _autoTargettingInstance.maxTargetingDistance) { - return; // Target is too far for this specific snap-look interaction + return; } - // Check angle condition from MagicAttacks settings - if (!_autoTargettingInstance.IsTargetInAngle(playerTransform, currentTarget, degreeThreshold)) + if (!_autoTargettingInstance.IsTargetInAngle(playerTransform, currentTarget, _autoTargettingInstance.targetingAngleThreshold)) { - return; // Target is not within the desired cone for snap-look + return; } Vector3 directionToTarget = currentTarget.transform.position - playerTransform.position; - directionToTarget.y = 0f; // Horizontal rotation only + directionToTarget.y = 0f; if (directionToTarget.sqrMagnitude > 0.0001f) { @@ -580,26 +575,26 @@ namespace Beyond { if (!canPlayCantDoClip) return; canPlayCantDoClip = false; - DOVirtual.DelayedCall(1f, () => canPlayCantDoClip = true); // Reset flag + DOVirtual.DelayedCall(1f, () => canPlayCantDoClip = true); - var text = "Spell is already active"; // Example message + var text = "Spell is already active"; if (bItemCollectionDisplay.Instance != null) bItemCollectionDisplay.Instance.FadeText(text, 4, 0.25f); if (Player.Instance != null) - Player.Instance.PlayICantDoThatYet(); // Assuming this method exists on Player + Player.Instance.PlayICantDoThatYet(); } private void TryToPlayNoEnoughFaithClip() { if (!canPlayNoFaithClip) return; canPlayNoFaithClip = false; - DOVirtual.DelayedCall(1.5f, () => canPlayNoFaithClip = true); // Reset flag + DOVirtual.DelayedCall(1.5f, () => canPlayNoFaithClip = true); var text = "Not enough Faith"; if (bItemCollectionDisplay.Instance != null) bItemCollectionDisplay.Instance.FadeText(text, 4, 0.25f); if (Player.Instance != null) - Player.Instance.PlayNoFaithClip(); // Assuming this method exists on Player + Player.Instance.PlayNoFaithClip(); } public EffectDesc GetCurrentlySelectedPower() @@ -613,7 +608,7 @@ namespace Beyond } bItem selectedSpellItem = powersArea.equipSlots[equipAreaSelectedIndex].item; - currentSelectedSpellName = selectedSpellItem.name; // Store for display or debugging + currentSelectedSpellName = selectedSpellItem.name; currentSpellFaithCost = selectedSpellItem.GetItemAttribute(bItemAttributes.Faith).value; return m_effects.Find(effect => effect.name == selectedSpellItem.name || effect.secondaryName == selectedSpellItem.name); @@ -622,30 +617,9 @@ namespace Beyond public void SelectPowerBasedOnArea(int newIndex) { equipAreaSelectedIndex = newIndex; - selectedEffect = GetCurrentlySelectedPower(); // Update current effect based on selection + selectedEffect = GetCurrentlySelectedPower(); } - // OLD rotation methods - can be removed or commented out if new system is preferred - /* - private void LerpRotation() - { - // ... original LerpRotation code using GetNearestEnemy ... - } - - private bool IsEnemyInAngleRange(vFSMBehaviourController ai) - { - // ... original IsEnemyInAngleRange code ... - } - private vFSMBehaviourController GetNearestEnemy(ref float minDist) - { - // ... original GetNearestEnemy code ... - } - private void TryToTurnTowordsEnemy() // Replaced by SnapLookTowardsAutoTarget - { - // ... original TryToTurnTowordsEnemy code ... - } - */ - protected virtual void AnimationBehaviour() { if (tpInput == null || tpInput.cc == null || tpInput.cc.animator == null || string.IsNullOrEmpty(animationClip)) @@ -654,7 +628,6 @@ namespace Beyond return; } - // isPlaying should reflect if the *specific spell animation* is active. isPlaying = tpInput.cc.animator.GetCurrentAnimatorStateInfo(spellLayerIndex).IsName(animationClip) || tpInput.cc.animator.GetNextAnimatorStateInfo(spellLayerIndex).IsName(animationClip); @@ -673,13 +646,9 @@ namespace Beyond } else { - // If not playing the specific animation clip, ensure triggerOnce is reset - // This handles cases where animation might be interrupted before reaching animationEnd if (triggerOnce) { triggerOnce = false; - // Optionally, invoke OnEndAnimation if it should always fire on exiting the state, - // but current logic only fires it if normalizedTime >= animationEnd. } } } diff --git a/Assets/Scripts/Respawner.cs b/Assets/Scripts/Respawner.cs index 432bdaf72..93722b261 100644 --- a/Assets/Scripts/Respawner.cs +++ b/Assets/Scripts/Respawner.cs @@ -126,7 +126,7 @@ namespace Beyond } [Button] - private void Respawn() + public void Respawn() { transform.position = respawnPos; if (m_player) diff --git a/Assets/ThirdParty/CHARACTERS/Creature Bone Monster 3/Textures/Ghost_Demon.mat b/Assets/ThirdParty/CHARACTERS/Creature Bone Monster 3/Textures/Ghost_Demon.mat index ad34f2fc7..50553cb05 100644 --- a/Assets/ThirdParty/CHARACTERS/Creature Bone Monster 3/Textures/Ghost_Demon.mat +++ b/Assets/ThirdParty/CHARACTERS/Creature Bone Monster 3/Textures/Ghost_Demon.mat @@ -21,18 +21,20 @@ Material: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: Ghost_Demon - m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Shader: {fileID: -6465566751694194690, guid: 00a0b3897399f8b42a61a0333dd40ced, + type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 m_ValidKeywords: + - BASETEXTYPE_ALBEDO_ALPHA + - USEDISSOLVE_DONT_USE + - USEFRESNEL - _ALPHATEST_ON - - _EMISSION - - _METALLICSPECGLOSSMAP m_InvalidKeywords: [] m_LightmapFlags: 2 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 1 - m_CustomRenderQueue: 2450 + m_CustomRenderQueue: -1 stringTagMap: RenderType: TransparentCutout disabledShaderPasses: @@ -41,6 +43,18 @@ Material: m_SavedProperties: serializedVersion: 3 m_TexEnvs: + - BaseTex: + m_Texture: {fileID: 2800000, guid: 7f4f98acdd83f7e4dafa8acf1a77389d, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - DissolveMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - NOSMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _BaseMap: m_Texture: {fileID: 2800000, guid: 7f4f98acdd83f7e4dafa8acf1a77389d, type: 3} m_Scale: {x: 1, y: 1} @@ -99,12 +113,31 @@ Material: m_Offset: {x: 0, y: 0} m_Ints: [] m_Floats: + - AOStrength: 1 + - AlphaClipThreshold: 0.5 + - BASETEXTYPE: 2 + - DissolveNoiseScale: 25 + - EffectStrenght: 1 + - FresnelPower: 4 + - Metalness: 1 + - NormalStrength: 1 + - Smoothness: 1 + - USEDISSOLVE: 0 + - USEDISSOLVEMASK: 0 + - USEFRESNEL: 1 + - Vector1_473704f964214ae2bc68475022d1524b: 0.05 - _AddPrecomputedVelocity: 0 - _AlphaClip: 1 - _AlphaToMask: 1 + - _BendEffect: 0 + - _BendMaxDistance: 1 + - _BendMaxHeight: 0 + - _BendMinDistance: 0.2 + - _BendMinHeight: 1 - _Blend: 0 - _BlendModePreserveSpecular: 1 - _BumpScale: 1 + - _CastShadows: 1 - _ClearCoatMask: 0 - _ClearCoatSmoothness: 0 - _Cull: 0 @@ -113,13 +146,19 @@ Material: - _DetailNormalMapScale: 1 - _DstBlend: 0 - _DstBlendAlpha: 0 + - _EffectThreshold: 0 - _EnvironmentReflections: 1 + - _FadeDistance: 0 + - _FarFadeDistance: 500 - _GlossMapScale: 0 - _Glossiness: 0 - _GlossyReflections: 0 + - _InverseFadeRange: 1 + - _InverseFarFadeRange: 0.5 - _Metallic: 0 - _OcclusionStrength: 1 - _Parallax: 0.005 + - _QueueControl: 0 - _QueueOffset: 0 - _ReceiveShadows: 1 - _Smoothness: 0.5 @@ -128,12 +167,23 @@ Material: - _SrcBlend: 1 - _SrcBlendAlpha: 1 - _Surface: 0 + - _Threshold: 0 + - _USEDISTANCEFADE: 0 + - _USESCANWAVE: 0 + - _WaveTrail: 4 - _WorkflowMode: 1 + - _ZTest: 4 - _ZWrite: 1 + - _ZWriteControl: 0 m_Colors: + - Color_613d1588816440ec9b17710effb7528b: {r: 0, g: 13.98681, b: 714.8679, a: 0} + - EmissiveColor: {r: 0, g: 0, b: 0, a: 0} - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _BendVector: {r: 0, g: -1, b: 0, a: 0} - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 13.766361, g: 13.766361, b: 13.766361, a: 1} + - _FresnelColor: {r: 0, g: 0, b: 0, a: 0} + - _ScanWaveColor: {r: 0, g: 0.5949242, b: 1, a: 0} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} m_BuildTextureStacks: [] m_AllowLocking: 1