diff --git a/Icons/CCGravity.svg b/Icons/CCGravity.svg new file mode 100644 index 0000000..d1afba2 --- /dev/null +++ b/Icons/CCGravity.svg @@ -0,0 +1,269 @@ + + diff --git a/Icons/CCGravity.svg.import b/Icons/CCGravity.svg.import new file mode 100644 index 0000000..f3ee92a --- /dev/null +++ b/Icons/CCGravity.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cms6crlofrmw6" +path="res://.godot/imported/CCGravity.svg-9cb591af352b26110ddc1d7ca25182f7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/CCGravity.svg" +dest_files=["res://.godot/imported/CCGravity.svg-9cb591af352b26110ddc1d7ca25182f7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/CCGroundReset.svg b/Icons/CCGroundReset.svg new file mode 100644 index 0000000..8549c42 --- /dev/null +++ b/Icons/CCGroundReset.svg @@ -0,0 +1,260 @@ + + diff --git a/Icons/CCGroundReset.svg.import b/Icons/CCGroundReset.svg.import new file mode 100644 index 0000000..aa4cfa5 --- /dev/null +++ b/Icons/CCGroundReset.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://coo8ygwnlacyl" +path="res://.godot/imported/CCGroundReset.svg-6d47bcba42901d6735ba773506057592.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/CCGroundReset.svg" +dest_files=["res://.godot/imported/CCGroundReset.svg-6d47bcba42901d6735ba773506057592.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/CCJump.svg b/Icons/CCJump.svg new file mode 100644 index 0000000..704e8c9 --- /dev/null +++ b/Icons/CCJump.svg @@ -0,0 +1,269 @@ + + diff --git a/Icons/CCJump.svg.import b/Icons/CCJump.svg.import new file mode 100644 index 0000000..f858323 --- /dev/null +++ b/Icons/CCJump.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://yspl0ly2f3od" +path="res://.godot/imported/CCJump.svg-b429c49be4900431b553e8c232dfef1e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/CCJump.svg" +dest_files=["res://.godot/imported/CCJump.svg-b429c49be4900431b553e8c232dfef1e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/CCMoveAndSlide.svg b/Icons/CCMoveAndSlide.svg new file mode 100644 index 0000000..23e4207 --- /dev/null +++ b/Icons/CCMoveAndSlide.svg @@ -0,0 +1,258 @@ + + diff --git a/Icons/CCMoveAndSlide.svg.import b/Icons/CCMoveAndSlide.svg.import new file mode 100644 index 0000000..9532966 --- /dev/null +++ b/Icons/CCMoveAndSlide.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dssab16ystcnn" +path="res://.godot/imported/CCMoveAndSlide.svg-021bc0e44172455e1156ae90bb85be01.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/CCMoveAndSlide.svg" +dest_files=["res://.godot/imported/CCMoveAndSlide.svg-021bc0e44172455e1156ae90bb85be01.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/CharacterController.svg b/Icons/CharacterController.svg new file mode 100644 index 0000000..a2a13e1 --- /dev/null +++ b/Icons/CharacterController.svg @@ -0,0 +1,241 @@ + + diff --git a/Icons/CharacterController.svg.import b/Icons/CharacterController.svg.import new file mode 100644 index 0000000..27d0cee --- /dev/null +++ b/Icons/CharacterController.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://67tillq7nac4" +path="res://.godot/imported/CharacterController.svg-5ae94b07988eaca9593c87b283a3b22e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/CharacterController.svg" +dest_files=["res://.godot/imported/CharacterController.svg-5ae94b07988eaca9593c87b283a3b22e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/CharacterControllerAction.svg b/Icons/CharacterControllerAction.svg new file mode 100644 index 0000000..81ef86d --- /dev/null +++ b/Icons/CharacterControllerAction.svg @@ -0,0 +1,253 @@ + + diff --git a/Icons/CharacterControllerAction.svg.import b/Icons/CharacterControllerAction.svg.import new file mode 100644 index 0000000..2b1b627 --- /dev/null +++ b/Icons/CharacterControllerAction.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c42ahv2i1ljv7" +path="res://.godot/imported/CharacterControllerAction.svg-d55c6bb5da46c8b8a4a899ef5b981b9b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/CharacterControllerAction.svg" +dest_files=["res://.godot/imported/CharacterControllerAction.svg-d55c6bb5da46c8b8a4a899ef5b981b9b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/Condition.svg b/Icons/Condition.svg new file mode 100644 index 0000000..530f85d --- /dev/null +++ b/Icons/Condition.svg @@ -0,0 +1,43 @@ + + + + + + + diff --git a/Icons/Condition.svg.import b/Icons/Condition.svg.import new file mode 100644 index 0000000..f587c39 --- /dev/null +++ b/Icons/Condition.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b1yylqvad686q" +path="res://.godot/imported/Condition.svg-6dd416703043dcbb435a8398bb0c00cc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/Condition.svg" +dest_files=["res://.godot/imported/Condition.svg-6dd416703043dcbb435a8398bb0c00cc.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/ConditionalAction.svg b/Icons/ConditionalAction.svg new file mode 100644 index 0000000..6f7c537 --- /dev/null +++ b/Icons/ConditionalAction.svg @@ -0,0 +1,44 @@ + + + + + + + diff --git a/Icons/ConditionalAction.svg.import b/Icons/ConditionalAction.svg.import new file mode 100644 index 0000000..2b5531a --- /dev/null +++ b/Icons/ConditionalAction.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://brlluh5xs7rh4" +path="res://.godot/imported/ConditionalAction.svg-7a2b32ad844d70cf4623367dfe7e2d84.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/ConditionalAction.svg" +dest_files=["res://.godot/imported/ConditionalAction.svg-7a2b32ad844d70cf4623367dfe7e2d84.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Actions/Action.cs b/Runtime/Actions/Action.cs index 29013dd..1f301e4 100644 --- a/Runtime/Actions/Action.cs +++ b/Runtime/Actions/Action.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; namespace Rokojori { + [Tool] [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Action.svg")] public partial class Action : NetworkNode { diff --git a/Runtime/Actions/Conditional/ConditionalAction.cs b/Runtime/Actions/Conditional/ConditionalAction.cs new file mode 100644 index 0000000..e54ac06 --- /dev/null +++ b/Runtime/Actions/Conditional/ConditionalAction.cs @@ -0,0 +1,44 @@ + +using Godot; +using System.Collections.Generic; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/ConditionalAction.svg")] + public partial class ConditionalAction : Action + { + [ExportGroup("Condition")] + [Export] + public Condition condition; + [Export] + public SceneCondition sceneCondition; + + [ExportGroup("Actions")] + [Export] + public Action ifAction; + + [Export] + public Action elseAction; + + protected override void _OnTrigger() + { + var conditionActive = Condition.Evaluate( condition ) && SceneCondition.Evaluate( sceneCondition ); + + this.LogInfo( "Condition is", conditionActive ); + + if ( conditionActive ) + { + Trigger( ifAction ); + } + else + { + Trigger( elseAction ); + } + } + + + } + +} \ No newline at end of file diff --git a/Runtime/Actions/Conditional/ConditionalAction.cs.uid b/Runtime/Actions/Conditional/ConditionalAction.cs.uid new file mode 100644 index 0000000..7780dee --- /dev/null +++ b/Runtime/Actions/Conditional/ConditionalAction.cs.uid @@ -0,0 +1 @@ +uid://dj6f8ie4bmaim diff --git a/Runtime/Actions/Visual/SetMaterial.cs b/Runtime/Actions/Visual/SetMaterial.cs new file mode 100644 index 0000000..4b474dc --- /dev/null +++ b/Runtime/Actions/Visual/SetMaterial.cs @@ -0,0 +1,35 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass ] + public partial class SetMaterial : Action + { + [Export] + public Node3D target; + + [Export] + public Material material; + + [Export] + public MaterialSlot slot = MaterialSlot.None; + + [Export] + public int index = 0; + + protected override void _OnTrigger() + { + if ( target == null || material == null ) + { + return; + } + + var msc = MaterialSurfaceContainer.From( target, index ); + msc.SetMaterialInSlot( slot, material ); + + } + } +} \ No newline at end of file diff --git a/Runtime/Actions/Visual/SetMaterial.cs.uid b/Runtime/Actions/Visual/SetMaterial.cs.uid new file mode 100644 index 0000000..88a8b51 --- /dev/null +++ b/Runtime/Actions/Visual/SetMaterial.cs.uid @@ -0,0 +1 @@ +uid://cftq6vpl6m7r5 diff --git a/Runtime/Actions/Visual/TweenMaterial.cs b/Runtime/Actions/Visual/TweenMaterial.cs new file mode 100644 index 0000000..669d112 --- /dev/null +++ b/Runtime/Actions/Visual/TweenMaterial.cs @@ -0,0 +1,179 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass ] + public partial class TweenMaterial : SequenceAction, Animator + { + public void OnAnimatorStart(){} + public void OnAnimatorEnd(){} + public void OnAnimatorCancel(){} + + [Export] + public Material material; + + [Export] + public float duration; + + + [Export] + public Curve tweenCurve = MathX.Curve( 0, 1 ); + + [Export] + public TimeLine timeLine; + + + + [Export] + public ColorProperty[] colors = []; + + [Export] + public FloatProperty[] floats = []; + + public enum MaterialAssignmentMode + { + No_Assignment, + Assignment, + Unique_Assignment + } + + [ExportGroup( "Target Assignment")] + [Export] + public MaterialAssignmentMode assignmentMode; + + [Export] + public Node3D target; + + [Export] + public MaterialSlot slot = MaterialSlot.None; + + [Export] + public int index = 0; + + Material _assignedMaterial = null; + + protected override void _OnTrigger() + { + if ( material == null && _assignedMaterial == null ) + { + return; + } + + SetAssignedMaterial(); + + var tl = TimeLineManager.Ensure( timeLine ); + + var start = tl.position; + + var startColors = new Color[ colors.Length ]; + var startFloats = new float[ floats.Length ]; + + var index = 0; + + var assignedMaterial = _assignedMaterial; + + foreach ( var c in colors ) + { + AnimationManager.StartAnimation( this, assignedMaterial, c.propertyName ); + startColors[ index ] = c.propertyName.Get( assignedMaterial ); + + index ++; + } + + index = 0; + foreach ( var f in floats ) + { + AnimationManager.StartAnimation( this, assignedMaterial, f.propertyName ); + startFloats[ index ] = f.propertyName.Get( assignedMaterial ); + index ++; + } + + + var sequenceID = DispatchStart(); + + TimeLineManager.ScheduleSpanIn( tl, 0, duration, + ( span, type )=> + { + var timeNow = tl.position; + var elapsed = timeNow - start; + + var index = 0; + var state = span.phase; + + if ( tweenCurve != null ) + { + state = tweenCurve.Sample( state ); + } + + foreach ( var c in colors ) + { + if ( AnimationManager.IsAnimating( this, assignedMaterial, c.propertyName ) ) + { + c.ApplyLerped( assignedMaterial, startColors[ index ], state ); + } + + index ++; + } + + index = 0; + + foreach ( var f in floats ) + { + if ( AnimationManager.IsAnimating( this, assignedMaterial, f.propertyName ) ) + { + f.ApplyLerped( assignedMaterial, startFloats[ index ], state ); + } + + index ++; + } + + if ( type == TimeLineSpanUpdateType.End ) + { + foreach ( var c in colors ) + { + AnimationManager.EndAnimation( this, assignedMaterial, c.propertyName ); + } + + foreach ( var f in floats ) + { + AnimationManager.EndAnimation( this, assignedMaterial, f.propertyName ); + } + + DispatchEnd( sequenceID ); + } + } + ); + + + } + + void SetAssignedMaterial() + { + if ( _assignedMaterial != null ) + { + return; + } + + if ( MaterialAssignmentMode.No_Assignment == assignmentMode ) + { + _assignedMaterial = material; + return; + } + + _assignedMaterial = material; + + if ( MaterialAssignmentMode.Unique_Assignment == assignmentMode ) + { + _assignedMaterial = (Material)material.Duplicate(); + } + + var msc = MaterialSurfaceContainer.From( target, index ); + + msc.SetMaterialInSlot( slot, _assignedMaterial ); + + } + } +} \ No newline at end of file diff --git a/Runtime/Actions/Visual/TweenMaterial.cs.uid b/Runtime/Actions/Visual/TweenMaterial.cs.uid new file mode 100644 index 0000000..ed17e46 --- /dev/null +++ b/Runtime/Actions/Visual/TweenMaterial.cs.uid @@ -0,0 +1 @@ +uid://0wcfunmv4j6d diff --git a/Runtime/Animation/AnimationManager.cs b/Runtime/Animation/AnimationManager.cs index 540b28a..00262e7 100644 --- a/Runtime/Animation/AnimationManager.cs +++ b/Runtime/Animation/AnimationManager.cs @@ -41,13 +41,18 @@ namespace Rokojori public class AnimationManager { - static MultiMap _animating = new MultiMap(); - + static MultiMap _animatingNodes = new MultiMap(); + static MultiMap _animatingResources = new MultiMap(); public static Animator GetAnimator( Node node, AnimationMember member ) { - return _animating.Get( node, member.name ); + return _animatingNodes.Get( node, member.name ); + } + + public static Animator GetAnimator( Material material, ShaderPropertyName propertyName ) + { + return _animatingResources.Get( material, propertyName.propertyName ); } public static bool IsAnimating( Animator animator, Node node, AnimationMember member ) @@ -55,6 +60,11 @@ namespace Rokojori return GetAnimator( node, member ) == animator; } + public static bool IsAnimating( Animator animator, Material material, ShaderPropertyName propertyName ) + { + return GetAnimator( material, propertyName ) == animator; + } + public static bool IsAnimating( Animator animator, Node node, params AnimationMember[] members ) { for ( int i = 0; i < members.Length; i++ ) @@ -90,10 +100,22 @@ namespace Rokojori activeAnimator.OnAnimatorCancel(); } - _animating.Set( node, member.name, animator ); + _animatingNodes.Set( node, member.name, animator ); } + public static void StartAnimation( Animator animator, Material material, ShaderPropertyName shaderPropertyName ) + { + var activeAnimator = GetAnimator( material, shaderPropertyName ); + + if ( activeAnimator != null ) + { + activeAnimator.OnAnimatorCancel(); + } + + _animatingResources.Set( material, shaderPropertyName.propertyName, animator ); + } + public static void StartAnimation( Animator animator, Node node, params AnimationMember[] members ) { for ( int i = 0; i < members.Length; i++ ) @@ -120,6 +142,16 @@ namespace Rokojori } } + public static void EndAnimation( Animator animator, Material material, ShaderPropertyName propertyName ) + { + var activeAnimator = GetAnimator( material, propertyName ); + + if ( activeAnimator != null ) + { + activeAnimator.OnAnimatorCancel(); + } + } + public static void EndAnimation( Animator animator, Node node, params AnimationMember[] members ) { for ( int i = 0; i < members.Length; i++ ) diff --git a/Runtime/Conditions/Condition.cs b/Runtime/Conditions/Condition.cs new file mode 100644 index 0000000..f6b9e47 --- /dev/null +++ b/Runtime/Conditions/Condition.cs @@ -0,0 +1,30 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; + + +namespace Rokojori +{ + interface iCondition + { + public bool Evaluate(); + } + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Condition.svg")] + public partial class Condition:Resource, iCondition + { + public virtual bool Evaluate() + { + return true; + } + + public static bool Evaluate( Condition condition ) + { + return condition == null ? true : condition.Evaluate(); + } + } +} \ No newline at end of file diff --git a/Runtime/Conditions/Condition.cs.uid b/Runtime/Conditions/Condition.cs.uid new file mode 100644 index 0000000..387e6c3 --- /dev/null +++ b/Runtime/Conditions/Condition.cs.uid @@ -0,0 +1 @@ +uid://stvq8x0ee8rg diff --git a/Runtime/Conditions/DistanceCondition.cs b/Runtime/Conditions/DistanceCondition.cs new file mode 100644 index 0000000..46f9fd2 --- /dev/null +++ b/Runtime/Conditions/DistanceCondition.cs @@ -0,0 +1,35 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Condition.svg")] + public partial class DistanceCondition: SceneCondition + { + [Export] + public Node3D from; + + [Export] + public Node3D to; + + [Export] + public float distance; + + public override bool Evaluate() + { + if ( from == null || to == null || distance < 0 ) + { + return false; + } + + return from.IsInRange( to, distance ); + } + + } +} \ No newline at end of file diff --git a/Runtime/Conditions/DistanceCondition.cs.uid b/Runtime/Conditions/DistanceCondition.cs.uid new file mode 100644 index 0000000..748d0c4 --- /dev/null +++ b/Runtime/Conditions/DistanceCondition.cs.uid @@ -0,0 +1 @@ +uid://41absp768akk diff --git a/Runtime/Conditions/SceneCondition.cs b/Runtime/Conditions/SceneCondition.cs new file mode 100644 index 0000000..acfbba8 --- /dev/null +++ b/Runtime/Conditions/SceneCondition.cs @@ -0,0 +1,25 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Condition.svg")] + public partial class SceneCondition:Node, iCondition + { + public virtual bool Evaluate() + { + return true; + } + + public static bool Evaluate( SceneCondition condition ) + { + return condition == null ? true : condition.Evaluate(); + } + } +} \ No newline at end of file diff --git a/Runtime/Conditions/SceneCondition.cs.uid b/Runtime/Conditions/SceneCondition.cs.uid new file mode 100644 index 0000000..0a6f659 --- /dev/null +++ b/Runtime/Conditions/SceneCondition.cs.uid @@ -0,0 +1 @@ +uid://xqrdv450ss5l diff --git a/Runtime/Interactions/CharacterController/Actions/SetCharacterMoveSpeed.cs b/Runtime/Interactions/CharacterController/Actions/SetCharacterMoveSpeed.cs new file mode 100644 index 0000000..c2dce35 --- /dev/null +++ b/Runtime/Interactions/CharacterController/Actions/SetCharacterMoveSpeed.cs @@ -0,0 +1,28 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class SetCharacterMoveSpeed:Action + { + [Export] + public CharacterMovement characterMovement; + + [Export] + public float characterMoveSpeed; + + protected override void _OnTrigger() + { + if ( characterMovement == null ) + { + return; + } + + characterMovement.moveSpeed = characterMoveSpeed; + } + } +} \ No newline at end of file diff --git a/Runtime/Interactions/CharacterController/Actions/SetCharacterMoveSpeed.cs.uid b/Runtime/Interactions/CharacterController/Actions/SetCharacterMoveSpeed.cs.uid new file mode 100644 index 0000000..63e2929 --- /dev/null +++ b/Runtime/Interactions/CharacterController/Actions/SetCharacterMoveSpeed.cs.uid @@ -0,0 +1 @@ +uid://1w7aawsfubq1 diff --git a/Runtime/Interactions/CharacterController/CharacterController.cs b/Runtime/Interactions/CharacterController/CharacterController.cs index 25a59f5..f359865 100644 --- a/Runtime/Interactions/CharacterController/CharacterController.cs +++ b/Runtime/Interactions/CharacterController/CharacterController.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/CharacterController.svg")] public partial class CharacterController:Node { [Export] @@ -46,8 +46,7 @@ namespace Rokojori if ( CharacterUpdateMode.Process == characterUpdateMode ) { - this.delta = (float) delta; - Nodes.ForEachDirectChild( actionsContainer, Action.Trigger ); + ProcessActions( (float) delta ); } // positionSmoother.CopyPosition( graphics, body, rotationSmoothingDuration, delta ); @@ -62,9 +61,15 @@ namespace Rokojori { if ( CharacterUpdateMode.Physics_Process == characterUpdateMode ) { - this.delta = (float) delta; - Nodes.ForEachDirectChild( actionsContainer, Action.Trigger ); + ProcessActions( (float) delta ); } } + + void ProcessActions( float delta ) + { + this.delta = (float) delta; + var container = actionsContainer == null ? this : actionsContainer; + Nodes.ForEachDirectChild( container, Action.Trigger ); + } } } \ No newline at end of file diff --git a/Runtime/Interactions/CharacterController/CharacterControllerAction.cs b/Runtime/Interactions/CharacterController/CharacterControllerAction.cs index 923ded7..7c46a30 100644 --- a/Runtime/Interactions/CharacterController/CharacterControllerAction.cs +++ b/Runtime/Interactions/CharacterController/CharacterControllerAction.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/CharacterControllerAction.svg")] public partial class CharacterControllerAction:Action { [Export] diff --git a/Runtime/Interactions/CharacterController/Gravity.cs b/Runtime/Interactions/CharacterController/Gravity.cs index 11bcb91..ad309fa 100644 --- a/Runtime/Interactions/CharacterController/Gravity.cs +++ b/Runtime/Interactions/CharacterController/Gravity.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/CCGravity.svg")] public partial class Gravity:CharacterControllerAction { [Export] diff --git a/Runtime/Interactions/CharacterController/GroundReset.cs b/Runtime/Interactions/CharacterController/GroundReset.cs index 782acdd..fb87fe4 100644 --- a/Runtime/Interactions/CharacterController/GroundReset.cs +++ b/Runtime/Interactions/CharacterController/GroundReset.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/CCGroundReset.svg")] public partial class GroundReset:CharacterControllerAction { protected override void _OnTrigger() diff --git a/Runtime/Interactions/CharacterController/Jump.cs b/Runtime/Interactions/CharacterController/Jump.cs index 47df17d..9779a5e 100644 --- a/Runtime/Interactions/CharacterController/Jump.cs +++ b/Runtime/Interactions/CharacterController/Jump.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/CCJump.svg")] public partial class Jump:CharacterControllerAction { [Export] diff --git a/Runtime/Interactions/CharacterController/MoveAndSlide.cs b/Runtime/Interactions/CharacterController/MoveAndSlide.cs index 9e45303..1d91529 100644 --- a/Runtime/Interactions/CharacterController/MoveAndSlide.cs +++ b/Runtime/Interactions/CharacterController/MoveAndSlide.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/CCMoveAndSlide.svg")] public partial class MoveAndSlide:CharacterControllerAction { protected override void _OnTrigger() diff --git a/Runtime/Interactions/Grabbable.cs b/Runtime/Interactions/Grabbable.cs index 824b282..9b89fa2 100644 --- a/Runtime/Interactions/Grabbable.cs +++ b/Runtime/Interactions/Grabbable.cs @@ -18,6 +18,9 @@ namespace Rokojori [Export] public Node3D grabTarget; + [Export] + public RigidBody3D rigidBody3D; + [ExportGroup("Read Only")] [Export] public Grabber grabber; diff --git a/Runtime/Interactions/Grabber.cs b/Runtime/Interactions/Grabber.cs index a662285..a570637 100644 --- a/Runtime/Interactions/Grabber.cs +++ b/Runtime/Interactions/Grabber.cs @@ -15,6 +15,12 @@ namespace Rokojori [Export] public Pointer pointer; + [Export] + public Action onGrab; + + [Export] + public Action onRelease; + [Export] public TimeLine timeLine; @@ -88,12 +94,22 @@ namespace Rokojori UpdateGrabbable(); } ); + + Action.Trigger( onGrab ); } void ReleaseGrabbing() { + if ( grabbable != null ) + { + grabbable.SetGrabber( null ); + grabbable = null; + } + _callback.done = true; _callback = null; + + Action.Trigger( onRelease ); } void UpdateGrabbable() @@ -101,6 +117,8 @@ namespace Rokojori // this.LogInfo( "Grabbing", HierarchyName.Of( grabbable ) ); grabbable.grabTarget.GlobalPosition = Smoothing.Apply( positionSmoothing, grabOffset.GlobalPosition, timeLine.delta ); grabbable.grabTarget.SetGlobalQuaternion( Smoothing.Apply( rotationSmoothing, grabOffset.GetGlobalQuaternion(), timeLine.delta ) ); + grabbable.rigidBody3D.LinearVelocity = Vector3.Zero; + grabbable.rigidBody3D.AngularVelocity = Vector3.Zero; } } diff --git a/Runtime/Math/Math3D.cs b/Runtime/Math/Math3D.cs index 0383af4..e04d704 100644 --- a/Runtime/Math/Math3D.cs +++ b/Runtime/Math/Math3D.cs @@ -481,6 +481,16 @@ namespace Rokojori return Mathf.RadToDeg( GlobalPitch( direction ) ); } + public static float GlobalDistanceTo( this Node3D a, Node3D other ) + { + return ( a.GlobalPosition - other.GlobalPosition ).Length(); + } + + public static bool IsInRange( this Node3D a, Node3D other, float distance ) + { + return a.GlobalDistanceTo( other ) <= distance; + } + public static void SetGlobalQuaternion( this Node3D node, Quaternion quaternion ) { var localScale = node.Scale; diff --git a/Runtime/Shading/Properties/Properties/ColorProperty.cs b/Runtime/Shading/Properties/Properties/ColorProperty.cs new file mode 100644 index 0000000..81be888 --- /dev/null +++ b/Runtime/Shading/Properties/Properties/ColorProperty.cs @@ -0,0 +1,28 @@ +using Godot; +using System.Reflection; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class ColorProperty : ShaderProperty + { + [Export] + public ColorPropertyName propertyName; + + [Export] + public Color color; + + public override void Apply( Material material ) + { + propertyName.Set( material, color ); + } + + public void ApplyLerped( Material material, Color from, float lerpState ) + { + var lerpedColor = from.Lerp( color, lerpState ); + propertyName.Set( material, lerpedColor ); + } + } +} \ No newline at end of file diff --git a/Runtime/Shading/Properties/Properties/ColorProperty.cs.uid b/Runtime/Shading/Properties/Properties/ColorProperty.cs.uid new file mode 100644 index 0000000..8e71e5a --- /dev/null +++ b/Runtime/Shading/Properties/Properties/ColorProperty.cs.uid @@ -0,0 +1 @@ +uid://d1j1uo25cs8cv diff --git a/Runtime/Shading/Properties/Properties/FloatProperty.cs b/Runtime/Shading/Properties/Properties/FloatProperty.cs new file mode 100644 index 0000000..410b528 --- /dev/null +++ b/Runtime/Shading/Properties/Properties/FloatProperty.cs @@ -0,0 +1,28 @@ +using Godot; +using System.Reflection; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FloatProperty : ShaderProperty + { + [Export] + public FloatPropertyName propertyName; + + [Export] + public float value; + + public override void Apply( Material material ) + { + propertyName.Set( material, value ); + } + + public void ApplyLerped( Material material, float from, float lerpState ) + { + var lerpedValue = Mathf.Lerp( from, value, lerpState ); + propertyName.Set( material, lerpedValue ); + } + } +} \ No newline at end of file diff --git a/Runtime/Shading/Properties/Properties/FloatProperty.cs.uid b/Runtime/Shading/Properties/Properties/FloatProperty.cs.uid new file mode 100644 index 0000000..23b3729 --- /dev/null +++ b/Runtime/Shading/Properties/Properties/FloatProperty.cs.uid @@ -0,0 +1 @@ +uid://cabo4a0q18w2o diff --git a/Runtime/Shading/Properties/Properties/ShaderProperty.cs b/Runtime/Shading/Properties/Properties/ShaderProperty.cs new file mode 100644 index 0000000..64172b9 --- /dev/null +++ b/Runtime/Shading/Properties/Properties/ShaderProperty.cs @@ -0,0 +1,15 @@ +using Godot; +using System.Reflection; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class ShaderProperty : Resource + { + public virtual void Apply( Material material ) + { + } + } +} \ No newline at end of file diff --git a/Runtime/Shading/Properties/Properties/ShaderProperty.cs.uid b/Runtime/Shading/Properties/Properties/ShaderProperty.cs.uid new file mode 100644 index 0000000..814ed99 --- /dev/null +++ b/Runtime/Shading/Properties/Properties/ShaderProperty.cs.uid @@ -0,0 +1 @@ +uid://di3jrpdh0c2no diff --git a/Runtime/Shading/Properties/Property Library/Color/Emission Color.tres b/Runtime/Shading/Properties/Property Library/Color/Emission Color.tres new file mode 100644 index 0000000..9c0a05d --- /dev/null +++ b/Runtime/Shading/Properties/Property Library/Color/Emission Color.tres @@ -0,0 +1,7 @@ +[gd_resource type="Resource" script_class="ColorPropertyName" load_steps=2 format=3 uid="uid://b5c4ci5xocowk"] + +[ext_resource type="Script" uid="uid://y2p0r8c5rs45" path="res://addons/rokojori_action_library/Runtime/Shading/Properties/ColorPropertyName.cs" id="1_xujmj"] + +[resource] +script = ExtResource("1_xujmj") +propertyName = "emission" diff --git a/Runtime/UI/Nodes/UIImage.cs b/Runtime/UI/Nodes/UIImage.cs index 7cdafab..81f336d 100644 --- a/Runtime/UI/Nodes/UIImage.cs +++ b/Runtime/UI/Nodes/UIImage.cs @@ -34,9 +34,7 @@ namespace Rokojori _imageType = value; - this.LogInfo( Material == null ? "null" : ( Material.GetType().Name ) ); UpdateImageType(); - this.LogInfo( Material == null ? "null" : ( Material.GetType().Name ) ); } }