Update Sensors
This commit is contained in:
parent
3f2570b03d
commit
5c4afd2dfe
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 194 KiB |
|
@ -0,0 +1,37 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://jibidlqj3w6f"
|
||||||
|
path="res://.godot/imported/rokojori-base-floor-4x4m.svg-e9ac60d16f594c8a2ca62672cb8fe722.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://addons/rokojori_action_library/Assets/Research/rokojori-base-floor-4x4m.svg"
|
||||||
|
dest_files=["res://.godot/imported/rokojori-base-floor-4x4m.svg-e9ac60d16f594c8a2ca62672cb8fe722.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=true
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=true
|
||||||
|
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=0
|
||||||
|
svg/scale=1.0
|
||||||
|
editor/scale_with_editor_scale=false
|
||||||
|
editor/convert_colors_with_editor_theme=false
|
|
@ -7,10 +7,11 @@ namespace Rokojori
|
||||||
public partial class LookAt : Action
|
public partial class LookAt : Action
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public Node3D lookTarget;
|
public Node3D lookFrom;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Node3D lookFrom;
|
public Node3D lookTarget;
|
||||||
|
|
||||||
|
|
||||||
public override void _Process( double delta )
|
public override void _Process( double delta )
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Rokojori
|
||||||
|
|
||||||
var networkSeed = random.GetSeed();
|
var networkSeed = random.GetSeed();
|
||||||
|
|
||||||
RJLog.Log( "Setting actionID id", actionID, GetLastSequenceActionID() );
|
// RJLog.Log( "Setting actionID id", actionID, GetLastSequenceActionID() );
|
||||||
|
|
||||||
var flashCurve = flashEffect.flashCurve;
|
var flashCurve = flashEffect.flashCurve;
|
||||||
var color = flashEffect.color.GetHDRColor();
|
var color = flashEffect.color.GetHDRColor();
|
||||||
|
@ -143,6 +143,7 @@ namespace Rokojori
|
||||||
var start = TimeLineManager.GetPosition( timeline );
|
var start = TimeLineManager.GetPosition( timeline );
|
||||||
var end = start + duration;
|
var end = start + duration;
|
||||||
|
|
||||||
|
|
||||||
animationID = TimeLineScheduler.ScheduleSpanIn( timeline, 0, duration,
|
animationID = TimeLineScheduler.ScheduleSpanIn( timeline, 0, duration,
|
||||||
( int id, TimeLineSpanUpdateType type )=>
|
( int id, TimeLineSpanUpdateType type )=>
|
||||||
{
|
{
|
||||||
|
@ -152,8 +153,6 @@ namespace Rokojori
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var phase = TimeLineManager.GetRangePhase( timeline, start, end );
|
var phase = TimeLineManager.GetRangePhase( timeline, start, end );
|
||||||
var value = flashCurve.Sample( phase );
|
var value = flashCurve.Sample( phase );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Text;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class Highlight:Action
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public HighlightActionType type;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Highlighter highlighter;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Node3D[] targets;
|
||||||
|
|
||||||
|
protected override void _OnTrigger()
|
||||||
|
{
|
||||||
|
highlighter.Highlight( type, targets );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Text;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class HighlightEffect:Resource
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class HighlightFlag:SelectorFlag
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Text;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum HighlightActionType
|
||||||
|
{
|
||||||
|
Start,
|
||||||
|
End
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HighlightTargets
|
||||||
|
{
|
||||||
|
public Node3D[] targets;
|
||||||
|
public int activeAnimationTarget = -1;
|
||||||
|
|
||||||
|
public List<Material> originalMaterial;
|
||||||
|
public List<Material> animationMaterial;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class Highlighter:Node
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public HighlightFlag flag;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Material material;
|
||||||
|
|
||||||
|
List<HighlightTargets> _activeTargets = new List<HighlightTargets>();
|
||||||
|
|
||||||
|
public void Highlight( HighlightActionType type, Node3D[] targets )
|
||||||
|
{
|
||||||
|
if ( HighlightActionType.End == type )
|
||||||
|
{
|
||||||
|
var t = _activeTargets.Find( a => a.targets == targets );
|
||||||
|
|
||||||
|
if ( t == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get materials
|
||||||
|
// Animate
|
||||||
|
// Swap Original Material;
|
||||||
|
// Remove Materials;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ( HighlightActionType.Start == type )
|
||||||
|
{
|
||||||
|
// Create target
|
||||||
|
// Create materials
|
||||||
|
// Swap animation materials
|
||||||
|
// Animate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using Godot;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Godot.Collections;
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class Interactable:Node3D
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public Action onInteraction;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
using Godot;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Godot.Collections;
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class Interactor:Node3D, SensorInputHandler
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public Pointer pointer;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Sensor button;
|
||||||
|
|
||||||
|
public void _OnSensor( SensorEvent se )
|
||||||
|
{
|
||||||
|
if ( pointer == null || pointer.pointable == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var interactable = Nodes.Find<Interactable>( pointer.pointable.GetParent() );
|
||||||
|
|
||||||
|
if ( interactable == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Action.Trigger( interactable.onInteraction );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,16 @@ namespace Rokojori
|
||||||
[Export]
|
[Export]
|
||||||
public Action onPointerRemoved;
|
public Action onPointerRemoved;
|
||||||
|
|
||||||
|
[ExportGroup("Highlighting")]
|
||||||
|
[Export]
|
||||||
|
public HighlightFlag highlightFlag;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Node3D[] highlightTargets;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<Pointer> _pointers = new List<Pointer>();
|
List<Pointer> _pointers = new List<Pointer>();
|
||||||
|
|
||||||
public int numPointing => _pointers.Count;
|
public int numPointing => _pointers.Count;
|
||||||
|
|
|
@ -15,6 +15,9 @@ namespace Rokojori
|
||||||
[Export]
|
[Export]
|
||||||
public Caster caster;
|
public Caster caster;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Highlighter[] highlighters;
|
||||||
|
|
||||||
public override void _Process( double delta )
|
public override void _Process( double delta )
|
||||||
{
|
{
|
||||||
if ( caster == null )
|
if ( caster == null )
|
||||||
|
@ -37,6 +40,7 @@ namespace Rokojori
|
||||||
|
|
||||||
if ( pointable != null )
|
if ( pointable != null )
|
||||||
{
|
{
|
||||||
|
Highlight( HighlightActionType.End, pointable );
|
||||||
pointable.UpdatePointerState( this, false );
|
pointable.UpdatePointerState( this, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +49,28 @@ namespace Rokojori
|
||||||
if ( pointable != null )
|
if ( pointable != null )
|
||||||
{
|
{
|
||||||
pointable.UpdatePointerState( this, true );
|
pointable.UpdatePointerState( this, true );
|
||||||
}
|
Highlight( HighlightActionType.Start, pointable );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Highlight( HighlightActionType type, Pointable p )
|
||||||
|
{
|
||||||
|
if ( p.highlightFlag == null || p.highlightTargets == null || p.highlightTargets.Length == 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var highlighterIndex = Arrays.FindIndex( highlighters, ( h )=> h.flag == pointable.highlightFlag );
|
||||||
|
|
||||||
|
if ( highlighterIndex == -1 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var highlighter = highlighters[ highlighterIndex ];
|
||||||
|
|
||||||
|
highlighter.Highlight( type, p.highlightTargets );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class SelectorFlag:Resource
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="SensorGroup" load_steps=11 format=3 uid="uid://c5rvf5v86ybks"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/SensorGroup.cs" id="1_eh8lb"]
|
||||||
|
[ext_resource type="Resource" uid="uid://ci42d04kv03yx" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Button Left.tres" id="2_7ixeu"]
|
||||||
|
[ext_resource type="Resource" uid="uid://b8u374emi528p" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Button Middle.tres" id="3_03o43"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cbqyav0cnehoq" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Button Right.tres" id="4_v0fjp"]
|
||||||
|
[ext_resource type="Resource" uid="uid://chwstub7bnlpp" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Wheel Down.tres" id="5_dks5x"]
|
||||||
|
[ext_resource type="Resource" uid="uid://b52horrdbgyaa" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Wheel Up.tres" id="6_l4cqu"]
|
||||||
|
[ext_resource type="Resource" uid="uid://c73afpa00tr65" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Editor Camera/Move Forward.tres" id="7_0kr2e"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cwoisyc1in6ew" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Editor Camera/Move Back.tres" id="8_iju1w"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dfrnedeefk0qk" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Editor Camera/Move Left.tres" id="9_d7wj5"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cbsltqawsp4yy" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Editor Camera/Move Right.tres" id="10_3fc02"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_eh8lb")
|
||||||
|
sensors = [ExtResource("2_7ixeu"), ExtResource("3_03o43"), ExtResource("4_v0fjp"), ExtResource("5_dks5x"), ExtResource("6_l4cqu"), ExtResource("7_0kr2e"), ExtResource("8_iju1w"), ExtResource("9_d7wj5"), ExtResource("10_3fc02")]
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="MouseButtonSensor" load_steps=2 format=3 uid="uid://ci42d04kv03yx"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/MouseButtonSensor.cs" id="1_45faa"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_45faa")
|
||||||
|
button = 1
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="MouseButtonSensor" load_steps=2 format=3 uid="uid://b8u374emi528p"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/MouseButtonSensor.cs" id="1_baalg"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_baalg")
|
||||||
|
button = 3
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="MouseButtonSensor" load_steps=2 format=3 uid="uid://cbqyav0cnehoq"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/MouseButtonSensor.cs" id="1_4clle"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_4clle")
|
||||||
|
button = 2
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="KeySensor" load_steps=2 format=3 uid="uid://cwoisyc1in6ew"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_iw8mv"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_iw8mv")
|
||||||
|
key = 83
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="KeySensor" load_steps=2 format=3 uid="uid://c73afpa00tr65"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_jess7"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_jess7")
|
||||||
|
key = 68
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="KeySensor" load_steps=2 format=3 uid="uid://dfrnedeefk0qk"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_1s7kb"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_1s7kb")
|
||||||
|
key = 0
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="KeySensor" load_steps=2 format=3 uid="uid://cbsltqawsp4yy"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_41mmi"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_41mmi")
|
||||||
|
key = 68
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="MouseButtonSensor" load_steps=2 format=3 uid="uid://chwstub7bnlpp"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/MouseButtonSensor.cs" id="1_uh7gk"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_uh7gk")
|
||||||
|
button = 5
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_resource type="Resource" script_class="MouseButtonSensor" load_steps=2 format=3 uid="uid://b52horrdbgyaa"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/MouseButtonSensor.cs" id="1_0v7by"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_0v7by")
|
||||||
|
button = 4
|
||||||
|
ctrlHold = 2
|
||||||
|
altHold = 2
|
||||||
|
shiftHold = 2
|
||||||
|
modifiersMode = 0
|
||||||
|
continous = false
|
||||||
|
_value = 0.0
|
||||||
|
_wasActive = false
|
||||||
|
_active = false
|
||||||
|
_activeTreshold = 0.5
|
|
@ -0,0 +1,114 @@
|
||||||
|
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass,Icon("res://addons/rokojori_action_library/Icons/RJSensor.svg")]
|
||||||
|
public partial class MouseButtonSensor : Sensor, iOnInputSensor
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public MouseButton button;
|
||||||
|
|
||||||
|
[ExportGroup( "Modifiers")]
|
||||||
|
[Export]
|
||||||
|
public Trillean ctrlHold = Trillean.Any;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Trillean altHold = Trillean.Any;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Trillean shiftHold = Trillean.Any;
|
||||||
|
|
||||||
|
public bool modifiersEnabled => ! TrilleanLogic.AllAny( ctrlHold, altHold, shiftHold );
|
||||||
|
|
||||||
|
public enum ModifiersMode
|
||||||
|
{
|
||||||
|
Hold_Modifiers_Only_On_Down,
|
||||||
|
Hold_Modifiers_All_The_Time
|
||||||
|
}
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public ModifiersMode modifiersMode;
|
||||||
|
|
||||||
|
float _lastInput = 0;
|
||||||
|
|
||||||
|
|
||||||
|
bool IsWheel()
|
||||||
|
{
|
||||||
|
return button == MouseButton.WheelUp || button == MouseButton.WheelDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateValue()
|
||||||
|
{
|
||||||
|
|
||||||
|
SetFloatValue( _lastInput );
|
||||||
|
|
||||||
|
if ( IsWheel() )
|
||||||
|
{
|
||||||
|
_lastInput = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void _Input( InputEvent ev )
|
||||||
|
{
|
||||||
|
|
||||||
|
var mouseEvent = ev as InputEventMouseButton;
|
||||||
|
|
||||||
|
if ( mouseEvent == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mouseEvent.ButtonIndex != button )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkModifiers = modifiersEnabled &&
|
||||||
|
(
|
||||||
|
ModifiersMode.Hold_Modifiers_All_The_Time == modifiersMode ||
|
||||||
|
_lastInput == 0 && ModifiersMode.Hold_Modifiers_Only_On_Down == modifiersMode
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( checkModifiers )
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( ! TrilleanLogic.Matches( ctrlHold, mouseEvent.CtrlPressed ) )
|
||||||
|
{
|
||||||
|
_lastInput = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! TrilleanLogic.Matches( altHold, mouseEvent.AltPressed ) )
|
||||||
|
{
|
||||||
|
_lastInput = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! TrilleanLogic.Matches( shiftHold, mouseEvent.ShiftPressed ) )
|
||||||
|
{
|
||||||
|
_lastInput = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var isActive = mouseEvent.IsPressed();
|
||||||
|
|
||||||
|
if ( IsWheel() && ! isActive )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastInput = isActive ? 1 : 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ namespace Rokojori
|
||||||
|
|
||||||
public void Update( float delta )
|
public void Update( float delta )
|
||||||
{
|
{
|
||||||
|
|
||||||
sensor.ProcessSensor( this, delta );
|
sensor.ProcessSensor( this, delta );
|
||||||
|
|
||||||
if ( ! sensor.continous && sensor.value == _lastValue )
|
if ( ! sensor.continous && sensor.value == _lastValue )
|
||||||
|
|
|
@ -146,7 +146,6 @@ namespace Rokojori
|
||||||
|
|
||||||
public static void RemoveOverlay( Node node, Material material, bool forceTop = true )
|
public static void RemoveOverlay( Node node, Material material, bool forceTop = true )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( node is GeometryInstance3D gi )
|
if ( node is GeometryInstance3D gi )
|
||||||
{
|
{
|
||||||
if ( forceTop )
|
if ( forceTop )
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
[gd_resource type="Shader" format=3 uid="uid://bmgpmbthlfon3"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
code = "// NOTE: Shader automatically converted from Godot Engine 4.3.stable.mono's StandardMaterial3D.
|
||||||
|
|
||||||
|
shader_type spatial;
|
||||||
|
render_mode blend_mix, world_vertex_coords, depth_draw_opaque, cull_front, diffuse_burley, specular_schlick_ggx, unshaded;
|
||||||
|
|
||||||
|
#include \"res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc\"
|
||||||
|
#include \"res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc\"
|
||||||
|
#include \"res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc\"
|
||||||
|
|
||||||
|
uniform vec4 albedo : source_color;
|
||||||
|
uniform float sizeClose : hint_range(0,100) = 1;
|
||||||
|
uniform float sizeFar : hint_range(0,100) =1;
|
||||||
|
uniform float closeDistance = 5;
|
||||||
|
uniform float farDistance = 100;
|
||||||
|
|
||||||
|
|
||||||
|
void vertex()
|
||||||
|
{
|
||||||
|
float cameraDistance = distance( VERTEX, CAMERA_POSITION_WORLD );
|
||||||
|
float size = mapClamped( cameraDistance, closeDistance, farDistance, sizeClose, sizeFar );
|
||||||
|
VERTEX += NORMAL * size/500.0 * cameraDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment()
|
||||||
|
{
|
||||||
|
ALBEDO = albedo.rgb;
|
||||||
|
}
|
||||||
|
"
|
Binary file not shown.
|
@ -74,7 +74,6 @@ namespace Rokojori
|
||||||
|
|
||||||
void UpdateRealTime( double engineDelta )
|
void UpdateRealTime( double engineDelta )
|
||||||
{
|
{
|
||||||
|
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
var unscaled = (float) ( ( now - lastUpdated ).TotalSeconds );
|
var unscaled = (float) ( ( now - lastUpdated ).TotalSeconds );
|
||||||
lastUpdated = now;
|
lastUpdated = now;
|
||||||
|
|
Loading…
Reference in New Issue