new: damage can now be dealt to units using DamageSources

This commit is contained in:
Chris
2025-10-03 20:44:48 -04:00
parent 06cfd582c8
commit 7068d39b5b
11 changed files with 188 additions and 16 deletions

View File

@@ -15,21 +15,22 @@ MonoBehaviour:
_serializedGraph: '{"type":"NodeCanvas.BehaviourTrees.BehaviourTree","nodes":[{"_position":{"x":-215.9104,"y":-492.4742},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"0"},{"_action":{"actions":[{"facingDirection":{"label":"Facing
Direction","value":{"_value":{"$content":3,"$type":"Reset.Units.PlayerFacingDirection"}},"changeValue":{"_value":1}},"rotationSpeed":{"label":"Rotation
Speed","changeValue":{"_value":1},"value":{"_value":0.5},"_changeSmoothing":{},"_smoothing":{},"_changeEasing":{},"_easing":{}},"$type":"Reset.Units.ChangeRotationSettings"},{"moveSpeed":{"label":"Move
Speed","changeValue":{"_value":1},"value":{},"_changeSmoothing":{"_value":1},"_smoothing":{"_value":10.0},"_changeEasing":{},"_easing":{}},"acceleration":{"label":"Acceleration","changeValue":{},"value":{},"_changeSmoothing":{},"_smoothing":{},"_changeEasing":{},"_easing":{}},"deacceleration":{"label":"Deacceleration","changeValue":{},"value":{},"_changeSmoothing":{},"_smoothing":{},"_changeEasing":{},"_easing":{}},"$type":"Reset.Units.ChangeMoveSpeedSettings"},{"parameter":{"_value":"Attack"},"parameterHashID":{},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":-790.4761,"y":-277.9589},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"1"},{"_action":{"waitTime":{"_value":0.1},"$type":"NodeCanvas.Tasks.Actions.Wait"},"_position":{"x":-536.0,"y":-273.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"2"},{"conditionFailReturn":1,"_condition":{"castType":{"_value":1},"length":{"_value":1.0},"direction":{"_value":{"z":1.0}},"offset":{"_value":{"z":1.0}},"ignoreLayers":{"_value":{"value":1}},"width":{},"size":{"_value":{"x":2.5,"y":2.5,"z":2.5}},"rotation":{},"drawGizmos":true,"drawGizmosOnlyWhenActive":true,"outputHit":{"_name":"_hit"},"outputHitArray":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":-396.0,"y":-207.0},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"3"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"current":{"_type":"UnityEngine.Collider","_name":"_hitCurrentElement"},"storeIndex":{"_name":"_index"},"maxIteration":{"_value":-1},"_position":{"x":-360.0,"y":-87.0},"$type":"NodeCanvas.BehaviourTrees.Iterator","$id":"4"},{"_action":{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"targetElement":{"_name":"_hitCurrentElement"},"$type":"NodeCanvas.Tasks.Actions.AddElementToList`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"_position":{"x":-498.0,"y":39.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"},{"_action":{"actions":[{"parameter":{"_value":"Melee"},"parameterHashID":{},"overrideAgent":{"_type":"UnityEngine.Animator","_name":"modelAnimator","_targetVariableID":"9de2ef67-d7a9-49dc-936e-63ede27a131b"},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"},{"waitTime":{"_value":0.3},"$type":"NodeCanvas.Tasks.Actions.Wait"},{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"$type":"NodeCanvas.Tasks.Actions.ClearList"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":-178.0,"y":-273.0003},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"6"},{"conditionFailReturn":1,"_condition":{"castType":{"_value":1},"length":{"_value":1.0},"direction":{"_value":{"z":1.0}},"offset":{"_value":{"z":1.0}},"ignoreLayers":{"_value":{"value":1}},"width":{},"size":{"_value":{"x":2.5,"y":2.5,"z":2.5}},"rotation":{},"drawGizmos":true,"drawGizmosOnlyWhenActive":true,"outputHit":{"_name":"_hit"},"outputHitArray":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":58.01416,"y":-181.0443},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"7"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"current":{"_type":"UnityEngine.Collider","_name":"_hitCurrentElement"},"storeIndex":{"_name":"_index"},"maxIteration":{"_value":-1},"_position":{"x":94.01416,"y":-61.04428},"$type":"NodeCanvas.BehaviourTrees.Iterator","$id":"8"},{"_action":{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"targetElement":{"_name":"_hitCurrentElement"},"$type":"NodeCanvas.Tasks.Actions.AddElementToList`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"_position":{"x":-43.98584,"y":64.95572},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"9"},{"_action":{"actions":[{"parameter":{"_value":"Melee"},"parameterHashID":{},"overrideAgent":{"_type":"UnityEngine.Animator","_name":"modelAnimator","_targetVariableID":"9de2ef67-d7a9-49dc-936e-63ede27a131b"},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"},{"waitTime":{"_value":0.3},"$type":"NodeCanvas.Tasks.Actions.Wait"},{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"$type":"NodeCanvas.Tasks.Actions.ClearList"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":254.0,"y":-279.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"10"},{"conditionFailReturn":1,"_condition":{"castType":{"_value":1},"length":{"_value":1.0},"direction":{"_value":{"z":1.0}},"offset":{"_value":{"z":1.0}},"ignoreLayers":{"_value":{"value":1}},"width":{},"size":{"_value":{"x":2.5,"y":2.5,"z":2.5}},"rotation":{},"drawGizmos":true,"drawGizmosOnlyWhenActive":true,"outputHit":{"_name":"_hit"},"outputHitArray":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":490.1199,"y":-162.0396},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"11"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"current":{"_type":"UnityEngine.Collider","_name":"_hitCurrentElement"},"storeIndex":{"_name":"_index"},"maxIteration":{"_value":-1},"_position":{"x":526.1199,"y":-42.03958},"$type":"NodeCanvas.BehaviourTrees.Iterator","$id":"12"},{"_action":{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"targetElement":{"_name":"_hitCurrentElement"},"$type":"NodeCanvas.Tasks.Actions.AddElementToList`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"_position":{"x":388.1199,"y":83.96042},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"13"},{"_action":{"actions":[{"parameter":{"_value":"Melee"},"parameterHashID":{},"overrideAgent":{"_type":"UnityEngine.Animator","_name":"modelAnimator","_targetVariableID":"9de2ef67-d7a9-49dc-936e-63ede27a131b"},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"},{"waitTime":{"_value":0.2},"$type":"NodeCanvas.Tasks.Actions.Wait"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"NodeCanvas.Tasks.Actions.ClearList"},{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"$type":"NodeCanvas.Tasks.Actions.ClearList"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":710.0,"y":-292.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"14"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"6"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"7"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"10"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"11"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"14"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"7"},"_targetNode":{"$ref":"8"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"8"},"_targetNode":{"$ref":"9"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"11"},"_targetNode":{"$ref":"12"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"12"},"_targetNode":{"$ref":"13"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"draggedEnemies":{"_propertyPath":"UnitCombat.draggedUnits","_name":"draggedEnemies","_id":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f","$type":"NodeCanvas.Framework.Variable`1[[System.Collections.Generic.List`1[[UnityEngine.Collider,
Speed","changeValue":{"_value":1},"value":{},"_changeSmoothing":{"_value":1},"_smoothing":{"_value":10.0},"_changeEasing":{},"_easing":{}},"acceleration":{"label":"Acceleration","changeValue":{},"value":{},"_changeSmoothing":{},"_smoothing":{},"_changeEasing":{},"_easing":{}},"deacceleration":{"label":"Deacceleration","changeValue":{},"value":{},"_changeSmoothing":{},"_smoothing":{},"_changeEasing":{},"_easing":{}},"$type":"Reset.Units.ChangeMoveSpeedSettings"},{"parameter":{"_value":"Attack"},"parameterHashID":{},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"},{"saveAs":{"_name":"_self"},"$type":"NodeCanvas.Tasks.Actions.GetSelf"},{"damage":{"_value":10.0},"source":{"_name":"_self"},"outputDamageSource":{"_name":"attackDamageSource","_targetVariableID":"93af52d4-3d5f-41a9-aadb-fbeb60d44b08"},"$type":"Reset.Core.CreateDamageSource"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":-791.4764,"y":-277.9589},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"1"},{"_action":{"waitTime":{"_value":0.1},"$type":"NodeCanvas.Tasks.Actions.Wait"},"_position":{"x":-536.0,"y":-273.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"2"},{"conditionFailReturn":1,"_condition":{"castType":{"_value":1},"length":{"_value":1.0},"direction":{"_value":{"z":1.0}},"offset":{"_value":{"z":1.0}},"ignoreLayers":{"_value":{"value":1}},"width":{},"size":{"_value":{"x":2.5,"y":2.5,"z":2.5}},"rotation":{},"drawGizmos":true,"drawGizmosOnlyWhenActive":true,"outputHit":{"_name":"_hit"},"outputHitArray":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":-396.0,"y":-207.0},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"3"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"current":{"_type":"UnityEngine.Collider","_name":"_hitCurrentElement"},"storeIndex":{"_name":"_index"},"maxIteration":{"_value":-1},"_position":{"x":-360.0,"y":-87.0},"$type":"NodeCanvas.BehaviourTrees.Iterator","$id":"4"},{"_action":{"actions":[{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"targetElement":{"_name":"_hitCurrentElement"},"$type":"NodeCanvas.Tasks.Actions.AddElementToList`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},{"targets":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"damageSource":{"_name":"attackDamageSource","_targetVariableID":"93af52d4-3d5f-41a9-aadb-fbeb60d44b08"},"$type":"Reset.Core.DealDamage"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":-488.0039,"y":39.00002},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"},{"_action":{"actions":[{"parameter":{"_value":"Melee"},"parameterHashID":{},"overrideAgent":{"_type":"UnityEngine.Animator","_name":"modelAnimator","_targetVariableID":"9de2ef67-d7a9-49dc-936e-63ede27a131b"},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"},{"waitTime":{"_value":0.3},"$type":"NodeCanvas.Tasks.Actions.Wait"},{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"$type":"NodeCanvas.Tasks.Actions.ClearList"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"NodeCanvas.Tasks.Actions.ClearList"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":-178.0,"y":-273.0003},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"6"},{"conditionFailReturn":1,"_condition":{"castType":{"_value":1},"length":{"_value":1.0},"direction":{"_value":{"z":1.0}},"offset":{"_value":{"z":1.0}},"ignoreLayers":{"_value":{"value":1}},"width":{},"size":{"_value":{"x":2.5,"y":2.5,"z":2.5}},"rotation":{},"drawGizmos":true,"drawGizmosOnlyWhenActive":true,"outputHit":{"_name":"_hit"},"outputHitArray":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":58.01416,"y":-181.0443},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"7"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"current":{"_type":"UnityEngine.Collider","_name":"_hitCurrentElement"},"storeIndex":{"_name":"_index"},"maxIteration":{"_value":-1},"_position":{"x":94.01416,"y":-61.04428},"$type":"NodeCanvas.BehaviourTrees.Iterator","$id":"8"},{"_action":{"actions":[{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"targetElement":{"_name":"_hitCurrentElement"},"$type":"NodeCanvas.Tasks.Actions.AddElementToList`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},{"targets":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"damageSource":{"_name":"attackDamageSource","_targetVariableID":"93af52d4-3d5f-41a9-aadb-fbeb60d44b08"},"$type":"Reset.Core.DealDamage"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":-43.98584,"y":63.95232},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"9"},{"_action":{"actions":[{"parameter":{"_value":"Melee"},"parameterHashID":{},"overrideAgent":{"_type":"UnityEngine.Animator","_name":"modelAnimator","_targetVariableID":"9de2ef67-d7a9-49dc-936e-63ede27a131b"},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"},{"waitTime":{"_value":0.3},"$type":"NodeCanvas.Tasks.Actions.Wait"},{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"$type":"NodeCanvas.Tasks.Actions.ClearList"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"NodeCanvas.Tasks.Actions.ClearList"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":254.0,"y":-279.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"10"},{"conditionFailReturn":1,"_condition":{"castType":{"_value":1},"length":{"_value":1.0},"direction":{"_value":{"z":1.0}},"offset":{"_value":{"z":1.0}},"ignoreLayers":{"_value":{"value":1}},"width":{},"size":{"_value":{"x":2.5,"y":2.5,"z":2.5}},"rotation":{},"drawGizmos":true,"drawGizmosOnlyWhenActive":true,"outputHit":{"_name":"_hit"},"outputHitArray":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":490.1199,"y":-162.0396},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"11"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"current":{"_type":"UnityEngine.Collider","_name":"_hitCurrentElement"},"storeIndex":{"_name":"_index"},"maxIteration":{"_value":-1},"_position":{"x":526.1199,"y":-42.03958},"$type":"NodeCanvas.BehaviourTrees.Iterator","$id":"12"},{"_action":{"actions":[{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"targetElement":{"_name":"_hitCurrentElement"},"$type":"NodeCanvas.Tasks.Actions.AddElementToList`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},{"targets":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"damageSource":{"_name":"attackDamageSource","_targetVariableID":"93af52d4-3d5f-41a9-aadb-fbeb60d44b08"},"$type":"Reset.Core.DealDamage"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":388.1199,"y":83.96042},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"13"},{"_action":{"actions":[{"parameter":{"_value":"Melee"},"parameterHashID":{},"overrideAgent":{"_type":"UnityEngine.Animator","_name":"modelAnimator","_targetVariableID":"9de2ef67-d7a9-49dc-936e-63ede27a131b"},"$type":"NodeCanvas.Tasks.Actions.MecanimSetTrigger"},{"waitTime":{"_value":0.2},"$type":"NodeCanvas.Tasks.Actions.Wait"},{"targetList":{"_name":"hitTargets","_targetVariableID":"0e35b4ec-628d-4911-9e92-0c05d0b928ec"},"$type":"NodeCanvas.Tasks.Actions.ClearList"},{"targetList":{"_name":"draggedEnemies","_targetVariableID":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f"},"$type":"NodeCanvas.Tasks.Actions.ClearList"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":710.0,"y":-292.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"14"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"6"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"7"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"10"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"11"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"14"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"7"},"_targetNode":{"$ref":"8"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"8"},"_targetNode":{"$ref":"9"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"11"},"_targetNode":{"$ref":"12"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"12"},"_targetNode":{"$ref":"13"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"draggedEnemies":{"_propertyPath":"UnitCombat.draggedUnits","_name":"draggedEnemies","_id":"efe1a2b3-c11f-47b5-a1de-99e42e65be5f","$type":"NodeCanvas.Framework.Variable`1[[System.Collections.Generic.List`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]],
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"modelAnimator":{"_name":"modelAnimator","_id":"9de2ef67-d7a9-49dc-936e-63ede27a131b","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Animator,
UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"hitTargets":{"_value":[],"_name":"hitTargets","_id":"0e35b4ec-628d-4911-9e92-0c05d0b928ec","$type":"NodeCanvas.Framework.Variable`1[[System.Collections.Generic.List`1[[UnityEngine.Collider,
UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]],
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}'
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"attackDamageSource":{"_name":"attackDamageSource","_id":"93af52d4-3d5f-41a9-aadb-fbeb60d44b08","$type":"NodeCanvas.Framework.Variable`1[[Reset.Core.DamageSource,
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}'
_objectReferences: []
_graphSource:
_version: 3.31
_category:
_comments:
_translation: {x: 667, y: 681}
_zoomFactor: 0.9997554
_translation: {x: 744, y: 736}
_zoomFactor: 0.99660593
_haltSerialization: 0
_externalSerializationFile: {fileID: 0}

View File

@@ -0,0 +1,7 @@
namespace Reset.Core{
public struct DamageSource{
public object source;
public float damageDealt;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ef4bf859ed4a4432a67812d87101fe5e
timeCreated: 1759536327

View File

@@ -0,0 +1,49 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace Reset.Core {
[Category("Reset")]
[Description("Create a damage source and return it as a BBParameter")]
public class CreateDamageSource : ActionTask{
public BBParameter<float> damage;
public BBParameter<GameObject> source;
[Space(5)]
public BBParameter<DamageSource> outputDamageSource;
//Use for initialization. This is called only once in the lifetime of the task.
//Return null if init was successfull. Return an error string otherwise
protected override string OnInit() {
return null;
}
//This is called once each time the task is enabled.
//Call EndAction() to mark the action as finished, either in success or failure.
//EndAction can be called from anywhere.
protected override void OnExecute(){
outputDamageSource.value = new DamageSource(){
damageDealt = damage.value,
source = source.value,
};
EndAction(true);
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1cacb344bd58efa489200a89d8bd84c1

View File

@@ -0,0 +1,56 @@
using System.Collections.Generic;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace Reset.Core {
[Category("Reset")]
[Description("Deal damage using a damage source to a target")]
public class DealDamage : ActionTask{
public BBParameter<List<Collider>> targets;
public BBParameter<DamageSource> damageSource;
//Use for initialization. This is called only once in the lifetime of the task.
//Return null if init was successfull. Return an error string otherwise
protected override string OnInit() {
return null;
}
//This is called once each time the task is enabled.
//Call EndAction() to mark the action as finished, either in success or failure.
//EndAction can be called from anywhere.
protected override void OnExecute() {
foreach (Collider target in targets.value) {
if (target.GetComponent<IDamageable>() == null) {
if (damageSource.value.source != null) {
Debug.LogError($"Target {target.name} cannot be dealt damage as it does not implement the IDamageable interface. It was attempted an attack by {damageSource.value.source}");
} else {
Debug.LogError($"Target {target.name} cannot be dealt damage as it does not implement the IDamageable interface. This attack has no source.");
}
continue;
}
target.GetComponent<IDamageable>().TakeDamage(damageSource.value);
}
EndAction(true);
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 853d0d23d94a38a4590fcf7ba3a8a7aa

View File

@@ -1,5 +1,9 @@
using UnityEngine;
public interface IDamageable{
public void TakeDamage();
}
namespace Reset.Core{
public interface IDamageable{
public void TakeDamage(DamageSource source);
public void TakeDamage(DamageSource[] sources);
}
}

View File

@@ -0,0 +1,10 @@
using Reset.Core;
namespace Reset.Units{
public interface IKillable : IDamageable{
public void Kill();
public float maxHealth{ get; set; }
public float currentHealth{ get; set; }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a819219f1a77429aacb1aace2e346eab
timeCreated: 1759535007

View File

@@ -1,22 +1,36 @@
using System;
using System.Collections;
using Drawing;
using Reset;
using Reset.Core;
using Reset.Core.Tools;
using Reset.Units;
using UnityEngine;
using Sirenix.OdinInspector;
using Sirenix.Serialization;
using Unity.Netcode;
public class Player : NetworkBehaviour{
public class Player : NetworkBehaviour, IKillable{
[HideInInspector] public PlayerControls controls;
[HideInInspector] public new PlayerCamera camera;
float IKillable.maxHealth{ get; set; }
float IKillable.currentHealth{ get; set; }
void Awake(){
GameManager.Player = gameObject;
controls = GetComponent<PlayerControls>();
}
void Start()
{
void Start(){
if (((IKillable)this).maxHealth == 0f) {
Debug.LogError($"Max health is not set for type of <b>{name}</b>. Setting to 100.");
((IKillable)this).currentHealth = 100f;
} else {
((IKillable)this).currentHealth = ((IKillable)this).maxHealth;
}
if (!NetworkManager.Singleton.IsConnectedClient && !NetworkManager.Singleton.IsHost) {
Attach();
} else {
@@ -50,8 +64,29 @@ public class Player : NetworkBehaviour{
// Update is called once per frame
void Update()
{
void Update(){
using (Draw.WithColor(Color.blue)) {
Draw.ingame.Label2D(transform.position + Vector3.up * 2.2f, ((IKillable)this).currentHealth.ToString(),
Color.blue);
}
}
public void TakeDamage(DamageSource[] sources){
foreach (DamageSource source in sources) {
TakeDamage(source);
}
}
public void TakeDamage(DamageSource source){
((IKillable)this).currentHealth -= source.damageDealt;
if (((IKillable)this).currentHealth <= 0) {
Kill();
}
}
public void Kill(){
throw new NotImplementedException();
}
}