WinterTales Tweens/More
This commit is contained in:
parent
282b66eadf
commit
fe606c6e39
|
|
@ -17,7 +17,7 @@ namespace Rokojori
|
|||
{
|
||||
if ( stopSiblingPlayers )
|
||||
{
|
||||
GetParent().ForEachDirectChild<AudioStreamPlayer>(
|
||||
music.GetParent().ForEachDirectChild<AudioStreamPlayer>(
|
||||
( p )=>
|
||||
{
|
||||
if ( p == music )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Tween.svg")]
|
||||
public partial class TweenMusicVolume:SequenceAction
|
||||
{
|
||||
[Export]
|
||||
public AudioStreamPlayer target;
|
||||
|
||||
[Export]
|
||||
public float endVolume = 0;
|
||||
|
||||
public enum VolumeUnit
|
||||
{
|
||||
Linear,
|
||||
Decibel
|
||||
}
|
||||
|
||||
[Export]
|
||||
public VolumeUnit volumeUnit = VolumeUnit.Linear;
|
||||
|
||||
[Export]
|
||||
public TweenType tweenType = new TweenTimeCurve();
|
||||
|
||||
[Export]
|
||||
public bool cacheEndPositionOnStart = true;
|
||||
|
||||
[Export]
|
||||
public TimeLine timeLine;
|
||||
|
||||
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
if ( target == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tl = TimeLineManager.Ensure( timeLine );
|
||||
|
||||
var start = tl.position;
|
||||
|
||||
var fromVolume = target.VolumeDb;
|
||||
var toVolume = volumeUnit == VolumeUnit.Linear ? MathAudio.AmplitudeToDecibels( endVolume ) : endVolume;
|
||||
|
||||
var sequenceID = DispatchStart();
|
||||
|
||||
var tweenType = this.tweenType;
|
||||
|
||||
if ( tweenType == null )
|
||||
{
|
||||
tweenType = TweenTimeCurve.defaultCurve;
|
||||
}
|
||||
|
||||
TimeLineManager.ScheduleSpanIn( tl, 0, tweenType.GetTweenDuration(),
|
||||
( span, type )=>
|
||||
{
|
||||
if ( ! GodotObject.IsInstanceValid( target ) )
|
||||
{
|
||||
DispatchEnd( sequenceID );
|
||||
return;
|
||||
}
|
||||
|
||||
var timeNow = tl.position;
|
||||
var elapsed = timeNow - start;
|
||||
|
||||
var state = tweenType.GetTweenPhaseForPhase( span.phase );
|
||||
|
||||
if ( ! cacheEndPositionOnStart )
|
||||
{
|
||||
var toScale = volumeUnit == VolumeUnit.Linear ? MathAudio.AmplitudeToDecibels( endVolume ) : endVolume;;
|
||||
}
|
||||
|
||||
var lerpedVolume = Mathf.Lerp( fromVolume, toVolume, state );
|
||||
|
||||
target.VolumeDb = lerpedVolume;
|
||||
|
||||
if ( type == TimeLineSpanUpdateType.End )
|
||||
{
|
||||
DispatchEnd( sequenceID );
|
||||
}
|
||||
},
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d3w20fwa8jek0
|
||||
|
|
@ -20,15 +20,27 @@ namespace Rokojori
|
|||
[Export]
|
||||
public int index = 0;
|
||||
|
||||
|
||||
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
if ( target == null || material == null )
|
||||
if ( target == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var msc = MaterialSurfaceContainer.From( target, index );
|
||||
msc.SetMaterialInSlot( slot, material );
|
||||
|
||||
if ( material == null )
|
||||
{
|
||||
msc.RemoveMaterialInSlot( slot );
|
||||
}
|
||||
else
|
||||
{
|
||||
msc.SetMaterialInSlot( slot, material );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,8 @@ namespace Rokojori
|
|||
|
||||
DispatchEnd( sequenceID );
|
||||
}
|
||||
}
|
||||
},
|
||||
this
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,24 +46,12 @@ namespace Rokojori
|
|||
{
|
||||
var toPosition = endOffset;
|
||||
|
||||
if ( Mode.Global == positionSpace )
|
||||
{
|
||||
if ( endPosition != null )
|
||||
{
|
||||
toPosition += endPosition.GlobalPosition;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( endPosition == null )
|
||||
{
|
||||
|
||||
if ( endPosition != null )
|
||||
{
|
||||
toPosition += endPosition.Position;
|
||||
}
|
||||
|
||||
return toPosition;
|
||||
}
|
||||
|
||||
return toPosition;
|
||||
return endPosition.GetPosition( Mode.Global == positionSpace );
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -125,7 +113,8 @@ namespace Rokojori
|
|||
{
|
||||
DispatchEnd( sequenceID );
|
||||
}
|
||||
}
|
||||
},
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Tween.svg")]
|
||||
public partial class TweenPostProcessVolume:SequenceAction
|
||||
{
|
||||
[Export]
|
||||
public PostProcessVolume activeVolume;
|
||||
|
||||
[Export]
|
||||
public float endWeight;
|
||||
|
||||
[Export]
|
||||
public TweenType tweenType = new TweenTimeCurve();
|
||||
|
||||
[Export]
|
||||
public bool cacheEndPositionOnStart = true;
|
||||
|
||||
[Export]
|
||||
public TimeLine timeLine;
|
||||
|
||||
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
if ( activeVolume == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tl = TimeLineManager.Ensure( timeLine );
|
||||
|
||||
var start = tl.position;
|
||||
|
||||
var fromWeight = activeVolume.weight;
|
||||
var toWeight = endWeight;
|
||||
|
||||
var sequenceID = DispatchStart();
|
||||
|
||||
var tweenType = this.tweenType;
|
||||
|
||||
if ( tweenType == null )
|
||||
{
|
||||
tweenType = TweenTimeCurve.defaultCurve;
|
||||
}
|
||||
|
||||
TimeLineManager.ScheduleSpanIn( tl, 0, tweenType.GetTweenDuration(),
|
||||
( span, type )=>
|
||||
{
|
||||
if ( ! GodotObject.IsInstanceValid( activeVolume ) )
|
||||
{
|
||||
DispatchEnd( sequenceID );
|
||||
return;
|
||||
}
|
||||
|
||||
var timeNow = tl.position;
|
||||
var elapsed = timeNow - start;
|
||||
|
||||
var state = tweenType.GetTweenPhaseForPhase( span.phase );
|
||||
|
||||
if ( ! cacheEndPositionOnStart )
|
||||
{
|
||||
var toScale = endWeight;
|
||||
}
|
||||
|
||||
var lerpedWeight = Mathf.Lerp( fromWeight, toWeight, state );
|
||||
|
||||
activeVolume.weight = lerpedWeight;
|
||||
|
||||
if ( type == TimeLineSpanUpdateType.End )
|
||||
{
|
||||
DispatchEnd( sequenceID );
|
||||
}
|
||||
},
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://lvr8dcb01lwx
|
||||
|
|
@ -184,6 +184,11 @@ namespace Rokojori
|
|||
|
||||
void StartHighlight( Node3D[] targets )
|
||||
{
|
||||
if ( targets == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var animation = _active.Find( a => Arrays.AreEntriesEqual( a.targets, targets ) );
|
||||
|
||||
targets.ForEach(
|
||||
|
|
@ -227,8 +232,11 @@ namespace Rokojori
|
|||
}
|
||||
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
|
||||
{
|
||||
material = (Material) outlineCustomMaterial.Duplicate();
|
||||
outlineCustomColorProperty.Set( material, colorTransparent );
|
||||
if ( outlineCustomMaterial != null )
|
||||
{
|
||||
material = (Material) outlineCustomMaterial.Duplicate();
|
||||
outlineCustomColorProperty.Set( material, colorTransparent );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -243,12 +251,27 @@ namespace Rokojori
|
|||
}
|
||||
else if ( OverlayMaterialMode.Custom_Material == overlayMaterialMode )
|
||||
{
|
||||
var overlay = (Material) overlayCustomMaterial.Duplicate();
|
||||
overlayCustomColorProperty.Set( overlay, colorTransparent );
|
||||
material.NextPass = overlay;
|
||||
if ( overlayCustomMaterial != null )
|
||||
{
|
||||
var overlay = (Material) overlayCustomMaterial.Duplicate();
|
||||
overlayCustomColorProperty.Set( overlay, colorTransparent );
|
||||
|
||||
if ( material != null )
|
||||
{
|
||||
material.NextPass = overlay;
|
||||
}
|
||||
else
|
||||
{
|
||||
material = overlay;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( material == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Arrays.ForEach( targets,
|
||||
t =>
|
||||
|
|
@ -320,7 +343,10 @@ namespace Rokojori
|
|||
}
|
||||
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
|
||||
{
|
||||
outlineCustomColorProperty.Set( m, tweenColor);
|
||||
if ( outlineCustomMaterial != null )
|
||||
{
|
||||
outlineCustomColorProperty.Set( m, tweenColor);
|
||||
}
|
||||
}
|
||||
|
||||
if ( OverlayMaterialMode.Flat_Overlay == overlayMaterialMode )
|
||||
|
|
@ -331,8 +357,13 @@ namespace Rokojori
|
|||
}
|
||||
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
|
||||
{
|
||||
var material = (OverlayMaterial) m.NextPass;
|
||||
outlineCustomColorProperty.Set( m, tweenColor);
|
||||
if ( overlayCustomMaterial != null )
|
||||
{
|
||||
var material = (Material) (
|
||||
OutlineMaterialMode.Custom_Material == outlineMaterialMode &&
|
||||
outlineCustomMaterial == null ? m : m.NextPass
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -412,7 +443,10 @@ namespace Rokojori
|
|||
}
|
||||
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
|
||||
{
|
||||
outlineCustomColorProperty.Set( m, tweenColor );
|
||||
if ( outlineCustomMaterial != null )
|
||||
{
|
||||
outlineCustomColorProperty.Set( m, tweenColor );
|
||||
}
|
||||
}
|
||||
|
||||
if ( OverlayMaterialMode.Flat_Overlay == overlayMaterialMode )
|
||||
|
|
@ -423,8 +457,15 @@ namespace Rokojori
|
|||
}
|
||||
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
|
||||
{
|
||||
var material = (OverlayMaterial) m.NextPass;
|
||||
outlineCustomColorProperty.Set( m, tweenColor);
|
||||
if ( overlayCustomMaterial != null )
|
||||
{
|
||||
var material = (Material) (
|
||||
OutlineMaterialMode.Custom_Material == outlineMaterialMode &&
|
||||
outlineCustomMaterial == null ? m : m.NextPass
|
||||
);
|
||||
|
||||
outlineCustomColorProperty.Set( m, tweenColor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@
|
|||
[sub_resource type="Resource" id="Resource_27v41"]
|
||||
script = ExtResource("1_3edxo")
|
||||
color = Color(1, 0.9375, 0, 1)
|
||||
colorMultiply = 1.0
|
||||
rgbMultiply = 1.0
|
||||
alphaMultiply = 1.0
|
||||
|
||||
[sub_resource type="Curve" id="Curve_vqio6"]
|
||||
_data = [Vector2(0, 0), 0.0, 1.0, 0, 1, Vector2(1, 1), 1.0, 0.0, 1, 0]
|
||||
|
|
@ -28,8 +25,5 @@ outDuration = 0.167
|
|||
outCurve = SubResource("Curve_4o1t0")
|
||||
color = SubResource("Resource_27v41")
|
||||
opacityModulationStrength = 0.75
|
||||
opacityModulationDuration = 0.5
|
||||
opacityModulationTransition = 1.0
|
||||
outlineMaterialMode = 1
|
||||
overlayOpacity = 0.01
|
||||
overlayMaterialMode = 0
|
||||
|
|
|
|||
|
|
@ -11,13 +11,24 @@ namespace Rokojori
|
|||
public static int ConcertA_Pitch = 69;
|
||||
public static float ConcertA_Frequency = 440.0f;
|
||||
|
||||
public static float amplitudeTreshold = -96f;
|
||||
|
||||
public static float AmplitudeToDecibels( float amplitude )
|
||||
{
|
||||
if ( amplitude <= 0.0 )
|
||||
{
|
||||
return amplitudeTreshold;
|
||||
}
|
||||
|
||||
return Mathf.Log(amplitude) * 20.0f / Mathf.Log(10.0f);
|
||||
}
|
||||
|
||||
public static float DecibelsToAmplitude( float decibels )
|
||||
{
|
||||
if ( decibels < amplitudeTreshold )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return Mathf.Pow(10.0f, decibels / 20.0f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ namespace Rokojori
|
|||
[Export]
|
||||
public ThirdPersonCameraSettings settings;
|
||||
|
||||
// [Export]
|
||||
// public TimeLine timeLine;
|
||||
|
||||
[Export]
|
||||
public CharacterController.CharacterUpdateMode updateMode = CharacterController.CharacterUpdateMode.Physics_Process;
|
||||
|
|
@ -66,9 +64,14 @@ namespace Rokojori
|
|||
|
||||
var targetPosition = Smoothing.Apply( settings.targetFollowSmoothing, target.GlobalPosition, delta );
|
||||
|
||||
var yawAxis = 0f;
|
||||
var pitchAxis = 0f;
|
||||
|
||||
var yawAxis = Sensors.PolarPowerAxis( data.yawNegativeAxis, data.yawPositiveAxis, 1f, data.yawDeadZone, data.yawPower );
|
||||
var pitchAxis = Sensors.PolarPowerAxis( data.pitchNegativeAxis, data.pitchPositiveAxis, 1f, data.pitchDeadZone, data.pitchPower );
|
||||
if ( inputEnabled )
|
||||
{
|
||||
yawAxis = Sensors.PolarPowerAxis( data.yawNegativeAxis, data.yawPositiveAxis, 1f, data.yawDeadZone, data.yawPower );
|
||||
pitchAxis = Sensors.PolarPowerAxis( data.pitchNegativeAxis, data.pitchPositiveAxis, 1f, data.pitchDeadZone, data.pitchPower );
|
||||
}
|
||||
|
||||
// this.LogInfo( "YAW:", yawAxis, "PITCH:", pitchAxis );
|
||||
yaw += yawAxis * settings.yawSpeed * data.yawSpeed * delta;
|
||||
|
|
|
|||
|
|
@ -105,8 +105,10 @@ namespace Rokojori
|
|||
|
||||
var value = floatValues[ j ].GetFloatValue();
|
||||
|
||||
floatValues[ j ].SetFloatValue( value + otherValues[ j ].GetFloatValue() );
|
||||
valueWeights[ j ] += volumes[ i ].combinedWeight;
|
||||
var weight = volumes[ i ].combinedWeight;
|
||||
|
||||
floatValues[ j ].SetFloatValue( value + otherValues[ j ].GetFloatValue() * weight );
|
||||
valueWeights[ j ] += weight;
|
||||
|
||||
// this.LogInfo( "Lerping", j, otherValues[ j ].value, valueWeights[ j ] );
|
||||
|
||||
|
|
@ -210,9 +212,11 @@ namespace Rokojori
|
|||
}
|
||||
|
||||
priorities[ j ] = volumes[ i ].priority;
|
||||
|
||||
var weight = volumes[ i ].combinedWeight;
|
||||
|
||||
colorValues[ j ].value += otherValues[ j ].value;
|
||||
valueWeights[ j ] += volumes[ i ].combinedWeight;
|
||||
colorValues[ j ].value += otherValues[ j ].value * weight;
|
||||
valueWeights[ j ] += weight;
|
||||
|
||||
// this.LogInfo( "Lerping", j, otherValues[ j ].value, valueWeights[ j ] );
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
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/VirtualCamera3D.svg") ]
|
||||
public partial class SetVirtualCameraInput:Action
|
||||
{
|
||||
[Export]
|
||||
public VirtualCamera camera;
|
||||
|
||||
[Export]
|
||||
public bool inputEnabled = true;
|
||||
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
camera.inputEnabled = inputEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://725qwxb6e5rr
|
||||
|
|
@ -15,6 +15,9 @@ namespace Rokojori
|
|||
[Export]
|
||||
public float fov = 60;
|
||||
|
||||
[Export]
|
||||
public bool inputEnabled = true;
|
||||
|
||||
public Vector3 GetCameraPosition()
|
||||
{
|
||||
return GlobalPosition;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,137 @@
|
|||
using Godot;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class AreaCaster:Caster, iNodeState
|
||||
{
|
||||
[Export]
|
||||
public Area3D area;
|
||||
|
||||
[Export]
|
||||
public Action onCollisionsChanged;
|
||||
|
||||
[Export]
|
||||
public Action onCollisionEntered;
|
||||
|
||||
[Export]
|
||||
public Action onCollisionExited;
|
||||
|
||||
|
||||
[ExportGroup( "Debugging")]
|
||||
[Export]
|
||||
public Node collider;
|
||||
|
||||
[Export]
|
||||
public bool printColliderNames = false;
|
||||
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if ( area == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
area.AreaEntered += TriggerOnEnter;
|
||||
area.BodyEntered += TriggerOnEnter;
|
||||
|
||||
area.AreaExited += _TriggerOnExited;
|
||||
area.BodyExited += _TriggerOnExited;
|
||||
}
|
||||
|
||||
public void TriggerOnEnter( Node3D node3D )
|
||||
{
|
||||
this.LogInfo( HierarchyName.Of( node3D ) );
|
||||
_TriggerOnEnter( node3D );
|
||||
}
|
||||
|
||||
public void TriggerOnExited( Node3D node3D )
|
||||
{
|
||||
this.LogInfo( HierarchyName.Of( node3D ) );
|
||||
_TriggerOnExited( node3D );
|
||||
}
|
||||
|
||||
void _TriggerOnEnter( Node3D n )
|
||||
{
|
||||
if ( n == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( area != null && ! Math3D.IsValid( area.GlobalPosition ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = IsSelected( n );
|
||||
|
||||
if ( ! selected )
|
||||
{
|
||||
// this.LogInfo( "Not selected", HierarchyName.Of( n ) );
|
||||
return;
|
||||
}
|
||||
|
||||
var collisionData = new CollisionData();
|
||||
collisionData.hasCollision = true;
|
||||
collisionData.collider = n;
|
||||
|
||||
collisionData.position = ( area.GlobalPosition + n.GlobalPosition ) / 2f;
|
||||
collisionData.normal = ( n.GlobalPosition - area.GlobalPosition ).Normalized();
|
||||
|
||||
collisions.Add( collisionData );
|
||||
|
||||
numCollisions = collisions.Count;
|
||||
|
||||
// this.LogInfo( "Selected", HierarchyName.Of( n ) );
|
||||
|
||||
SortCollisions();
|
||||
|
||||
onCollisionEntered?.Trigger();
|
||||
onCollisionsChanged?.Trigger();
|
||||
|
||||
}
|
||||
|
||||
void _TriggerOnExited( Node n )
|
||||
{
|
||||
if ( n == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var insideIndex = collisions.FindIndex( c => c.collider == n );
|
||||
|
||||
if ( insideIndex == -1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
collisions.RemoveAt( insideIndex );
|
||||
|
||||
numCollisions = collisions.Count;
|
||||
|
||||
SortCollisions();
|
||||
|
||||
onCollisionExited?.Trigger();
|
||||
onCollisionsChanged?.Trigger();
|
||||
|
||||
}
|
||||
|
||||
public void OnNodeStateChanged()
|
||||
{
|
||||
if ( ! IsProcessing() || ! IsPhysicsProcessing() || Node.ProcessModeEnum.Disabled == this.ProcessMode )
|
||||
{
|
||||
// this.LogInfo( "Clearing nodes" );
|
||||
collisions.Clear();
|
||||
numCollisions = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dc6o1arf1t2ci
|
||||
|
|
@ -7,45 +7,110 @@ namespace Rokojori
|
|||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class Caster:Node3D
|
||||
public abstract partial class Caster:Node3D
|
||||
{
|
||||
[Export]
|
||||
public Action beforeProcess;
|
||||
|
||||
[Export]
|
||||
public Action afterProcess;
|
||||
|
||||
[Export]
|
||||
public Selector includeSelector;
|
||||
|
||||
[Export]
|
||||
public Selector excludeSelector;
|
||||
|
||||
[Export]
|
||||
public bool sortByPointerPriority;
|
||||
|
||||
|
||||
public virtual int NumColliders()
|
||||
|
||||
public int NumColliders()
|
||||
{
|
||||
return 0;
|
||||
return collisions == null ? 0 : numCollisions;
|
||||
}
|
||||
|
||||
|
||||
public virtual Node GetCollider( int index )
|
||||
public Node GetCollider( int index )
|
||||
{
|
||||
return null;
|
||||
return collisions[ index ].collider;
|
||||
}
|
||||
|
||||
public virtual Vector3 GetCollisionPosition( int index )
|
||||
|
||||
public Vector3 GetCollisionNormal( int index )
|
||||
{
|
||||
return Vector3.Zero;
|
||||
return collisions[ index ].normal;
|
||||
}
|
||||
|
||||
public virtual Vector3 GetCollisionNormal( int index )
|
||||
|
||||
public Vector3 GetCollisionPosition( int index )
|
||||
{
|
||||
return Vector3.Zero;
|
||||
return collisions[ index ].position;
|
||||
}
|
||||
|
||||
public virtual Shape3D GetCollisionShape( int index )
|
||||
|
||||
public Shape3D GetCollisionShape( int index )
|
||||
{
|
||||
return null;
|
||||
return collisions[ index ].shape;
|
||||
}
|
||||
|
||||
ValueSorter<CollisionData> singleSorter;
|
||||
MultiValueSorter<CollisionData> multiSorter;
|
||||
protected List<CollisionData> collisions = new List<CollisionData>();
|
||||
protected int numCollisions = 0;
|
||||
|
||||
protected bool IsSelected( Node node )
|
||||
{
|
||||
if ( includeSelector != null && ! includeSelector.Selects( node ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( excludeSelector != null && excludeSelector.Selects( node ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool IsSelected( CollisionData cd )
|
||||
{
|
||||
return IsSelected( cd.collider );
|
||||
}
|
||||
|
||||
protected void SortCollisions()
|
||||
{
|
||||
if ( ! sortByPointerPriority )
|
||||
{
|
||||
if ( singleSorter == null )
|
||||
{
|
||||
singleSorter = ValueSorter<CollisionData>.Create( cd => GetDistance( cd ) );
|
||||
}
|
||||
|
||||
singleSorter.Sort( 0, numCollisions, collisions );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( multiSorter == null )
|
||||
{
|
||||
multiSorter = MultiValueSorter<CollisionData>.Create(
|
||||
cd => GetPointablePriority( cd ),
|
||||
cd => GetDistance( cd )
|
||||
);
|
||||
}
|
||||
|
||||
multiSorter.Sort( 0, numCollisions, collisions );
|
||||
}
|
||||
}
|
||||
|
||||
protected float GetPointablePriority( CollisionData cd )
|
||||
{
|
||||
float priority = 0;
|
||||
|
||||
var pointable = Nodes.Find<Pointable>( cd.collider );
|
||||
|
||||
if ( pointable != null )
|
||||
{
|
||||
priority = pointable.pointingPriority;
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
protected float GetDistance( CollisionData cd )
|
||||
{
|
||||
return ( cd.position - GlobalPosition ).Length();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ namespace Rokojori
|
|||
area.AreaEntered += TriggerOnEnter;
|
||||
area.BodyEntered += TriggerOnEnter;
|
||||
|
||||
area.AreaExited += _TriggerOnExited;
|
||||
area.BodyExited += _TriggerOnExited;
|
||||
area.AreaExited += TriggerOnExited;
|
||||
area.BodyExited += TriggerOnExited;
|
||||
}
|
||||
|
||||
public void TriggerOnCollisionEnter( Projectile p, KinematicCollision3D collision )
|
||||
|
|
|
|||
|
|
@ -21,50 +21,37 @@ namespace Rokojori
|
|||
[Export]
|
||||
public int maxHits = 3;
|
||||
|
||||
[Export]
|
||||
public bool sortByPointerPriority;
|
||||
|
||||
List<CollisionData> collisions = new List<CollisionData>();
|
||||
int numCollisions = 0;
|
||||
|
||||
[Export]
|
||||
public Vector3 to;
|
||||
|
||||
[Export]
|
||||
public UpdateMode updateMode = UpdateMode.Physics_Process;
|
||||
|
||||
[Export]
|
||||
public Action beforeProcess;
|
||||
|
||||
[Export]
|
||||
public Action afterProcess;
|
||||
|
||||
|
||||
[ExportGroup( "Debugging")]
|
||||
[Export]
|
||||
public Node collider;
|
||||
|
||||
[Export]
|
||||
public UpdateMode updateMode = UpdateMode.Physics_Process;
|
||||
public bool printColliderNames = false;
|
||||
|
||||
|
||||
|
||||
public override int NumColliders()
|
||||
{
|
||||
return collisions == null ? 0 : numCollisions;
|
||||
}
|
||||
|
||||
public override Node GetCollider( int index )
|
||||
{
|
||||
return collisions[ index ].collider;
|
||||
}
|
||||
|
||||
public override Vector3 GetCollisionNormal( int index )
|
||||
{
|
||||
return collisions[ index ].normal;
|
||||
}
|
||||
|
||||
public override Vector3 GetCollisionPosition( int index )
|
||||
{
|
||||
return collisions[ index ].position;
|
||||
}
|
||||
|
||||
public override Shape3D GetCollisionShape( int index )
|
||||
{
|
||||
return collisions[ index ].shape;
|
||||
}
|
||||
|
||||
PhysicsRayQueryParameters3D rayParameters = new PhysicsRayQueryParameters3D();
|
||||
|
||||
public override void _PhysicsProcess (double delta )
|
||||
{
|
||||
public override void _PhysicsProcess( double delta )
|
||||
{
|
||||
if ( UpdateMode.Physics_Process != updateMode )
|
||||
{
|
||||
return;
|
||||
|
|
@ -106,15 +93,14 @@ namespace Rokojori
|
|||
{
|
||||
collider = nextCollider;
|
||||
|
||||
// this.LogInfo( "New Collider:", HierarchyName.Of( collider ) );
|
||||
if ( printColliderNames )
|
||||
{
|
||||
this.LogInfo( "New Collider:", HierarchyName.Of( collider ) );
|
||||
}
|
||||
}
|
||||
|
||||
Action.Trigger( afterProcess );
|
||||
}
|
||||
|
||||
ValueSorter<CollisionData> singleSorter;
|
||||
MultiValueSorter<CollisionData> multiSorter;
|
||||
|
||||
|
||||
|
||||
CollisionData GetCollisionData( int i )
|
||||
|
|
@ -165,64 +151,7 @@ namespace Rokojori
|
|||
}
|
||||
}
|
||||
|
||||
bool IsSelected( CollisionData cd )
|
||||
{
|
||||
if ( includeSelector != null && ! includeSelector.Selects( cd.collider ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( excludeSelector != null && excludeSelector.Selects( cd.collider ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SortCollisions()
|
||||
{
|
||||
if ( ! sortByPointerPriority )
|
||||
{
|
||||
if ( singleSorter == null )
|
||||
{
|
||||
singleSorter = ValueSorter<CollisionData>.Create( cd => GetDistance( cd ) );
|
||||
}
|
||||
|
||||
singleSorter.Sort( 0, numCollisions, collisions );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( multiSorter == null )
|
||||
{
|
||||
multiSorter = MultiValueSorter<CollisionData>.Create(
|
||||
cd => GetPointablePriority( cd ),
|
||||
cd => GetDistance( cd )
|
||||
);
|
||||
}
|
||||
|
||||
multiSorter.Sort( 0, numCollisions, collisions );
|
||||
}
|
||||
}
|
||||
|
||||
float GetPointablePriority( CollisionData cd )
|
||||
{
|
||||
float priority = 0;
|
||||
|
||||
var pointable = Nodes.Find<Pointable>( cd.collider );
|
||||
|
||||
if ( pointable != null )
|
||||
{
|
||||
priority = pointable.pointingPriority;
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
float GetDistance( CollisionData cd )
|
||||
{
|
||||
return ( cd.position - GlobalPosition ).Length();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Rokojori
|
|||
{
|
||||
[Tool]
|
||||
[GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Pointer.svg")]
|
||||
public partial class Pointer:Node3D
|
||||
public partial class Pointer:Action
|
||||
{
|
||||
[Export]
|
||||
public Caster caster;
|
||||
|
|
@ -27,7 +27,7 @@ namespace Rokojori
|
|||
[Export]
|
||||
public bool printPointables = false;
|
||||
|
||||
public override void _Process( double delta )
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
if ( caster == null )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,17 @@ namespace Rokojori
|
|||
[Export]
|
||||
public WindManagerData data;
|
||||
|
||||
[Export]
|
||||
public Action onWindChange;
|
||||
|
||||
[Export]
|
||||
public Action onWindDirectionChange;
|
||||
|
||||
[Export]
|
||||
public Action onWindSpeedChange;
|
||||
|
||||
float _currentKMH = 0;
|
||||
Vector2 _currentDirection = Vector2.Zero;
|
||||
|
||||
public override void _Process( double delta )
|
||||
{
|
||||
|
|
@ -25,6 +36,29 @@ namespace Rokojori
|
|||
UpdatePosition( rm, (float) delta, data.globalWindPositionFarPropertyName, data.farMultiplier );
|
||||
UpdateDirection( rm, (float) delta );
|
||||
UpdateSpeed( rm, (float) delta );
|
||||
|
||||
var changed = false;
|
||||
|
||||
if ( _currentKMH != data.windSpeed.GetKMH() )
|
||||
{
|
||||
changed = true;
|
||||
onWindSpeedChange?.Trigger();
|
||||
|
||||
_currentKMH = data.windSpeed.GetKMH();
|
||||
}
|
||||
|
||||
if ( _currentDirection != data.windDirection )
|
||||
{
|
||||
changed = true;
|
||||
onWindDirectionChange?.Trigger();
|
||||
|
||||
_currentDirection = data.windDirection;
|
||||
}
|
||||
|
||||
if ( changed )
|
||||
{
|
||||
onWindChange?.Trigger();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
using Godot;
|
||||
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/WindManager.svg") ]
|
||||
public partial class WindToGPUParticles:Action
|
||||
{
|
||||
[Export]
|
||||
public GpuParticles3D particles3D;
|
||||
|
||||
[Export]
|
||||
public float maxKMH = 100;
|
||||
|
||||
[Export]
|
||||
public float noWindRatio = 0.5f;
|
||||
|
||||
[Export]
|
||||
public Vector3 noWindDirection = Vector3.Zero;
|
||||
|
||||
[Export]
|
||||
public float windDirectionInfluence = 0.1f;
|
||||
|
||||
[Export]
|
||||
public float noWindSpread = 45;
|
||||
|
||||
[Export]
|
||||
public float windSpeedToSpread = 0.1f;
|
||||
|
||||
[Export]
|
||||
public Vector2 noWindInitialVelocity = new Vector2( 0,1 );
|
||||
|
||||
[Export]
|
||||
public Vector2 windSpeedToVelocity = new Vector2( 5, 50);
|
||||
|
||||
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
if ( particles3D == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var processMaterial = (ParticleProcessMaterial) particles3D.ProcessMaterial;
|
||||
|
||||
var wm = Unique<WindManager>.Get();
|
||||
|
||||
var speed = wm.data.windSpeed.GetKMH();
|
||||
var dir = wm.data.windDirection.To3DXZ();
|
||||
|
||||
particles3D.AmountRatio = Mathf.Lerp( noWindRatio, 1.0f, MathX.Clamp01( speed / maxKMH ) );
|
||||
|
||||
processMaterial.Direction = noWindDirection + speed * dir * windDirectionInfluence;
|
||||
processMaterial.Spread = noWindSpread + speed * windSpeedToSpread;
|
||||
|
||||
var velocity = noWindInitialVelocity + speed * windSpeedToVelocity;
|
||||
processMaterial.InitialVelocityMin = velocity.X;
|
||||
processMaterial.InitialVelocityMax = velocity.Y;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bs6kh8ey7kioq
|
||||
|
|
@ -33,6 +33,7 @@ namespace Rokojori
|
|||
public abstract MaterialSlot GetActiveMaterialSlot();
|
||||
public abstract T GetMaterialInSlot<T>( MaterialSlot slot ) where T:Material;
|
||||
public abstract void SetMaterialInSlot( MaterialSlot slot, Material material );
|
||||
public abstract void RemoveMaterialInSlot( MaterialSlot slot );
|
||||
|
||||
public static Material GetActiveFrom( Node3D owner, int surfaceIndex = 0 )
|
||||
{
|
||||
|
|
@ -191,6 +192,33 @@ namespace Rokojori
|
|||
return material == null ? MaterialSlot.None : MaterialSlot.MeshSurface;
|
||||
}
|
||||
|
||||
public override void RemoveMaterialInSlot( MaterialSlot slot )
|
||||
{
|
||||
if ( surfaceIndex == -1 || MaterialSlot.None == slot || node == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Material material = null;
|
||||
|
||||
if ( MaterialSlot.MeshSurface == slot )
|
||||
{
|
||||
node.Mesh.SurfaceSetMaterial( surfaceIndex, material );
|
||||
}
|
||||
else if ( MaterialSlot.MeshSurfaceOverride == slot )
|
||||
{
|
||||
node.SetSurfaceOverrideMaterial( surfaceIndex, material );
|
||||
}
|
||||
else if ( MaterialSlot.Override == slot )
|
||||
{
|
||||
node.MaterialOverride = material;
|
||||
}
|
||||
else if ( MaterialSlot.Overlay == slot )
|
||||
{
|
||||
node.MaterialOverlay = material;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMaterialInSlot( MaterialSlot slot, Material material )
|
||||
{
|
||||
if ( surfaceIndex == -1 || MaterialSlot.None == slot || material == null || node == null )
|
||||
|
|
@ -295,6 +323,29 @@ namespace Rokojori
|
|||
return material == null ? MaterialSlot.None : MaterialSlot.MeshSurface;
|
||||
}
|
||||
|
||||
public override void RemoveMaterialInSlot( MaterialSlot slot )
|
||||
{
|
||||
if ( surfaceIndex == -1 || MaterialSlot.None == slot )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Material material = null;
|
||||
|
||||
if ( MaterialSlot.MeshSurface == slot )
|
||||
{
|
||||
node.Multimesh.Mesh.SurfaceSetMaterial( surfaceIndex, material );
|
||||
}
|
||||
else if ( MaterialSlot.Override == slot )
|
||||
{
|
||||
node.MaterialOverride = material;
|
||||
}
|
||||
else if ( MaterialSlot.Overlay == slot )
|
||||
{
|
||||
node.MaterialOverlay = material;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMaterialInSlot( MaterialSlot slot, Material material )
|
||||
{
|
||||
if ( surfaceIndex == -1 || MaterialSlot.None == slot )
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ namespace Rokojori
|
|||
|
||||
void EnsureGlobalShaderProperties()
|
||||
{
|
||||
var globalProperties = RenderingServer.GlobalShaderParameterGetList();
|
||||
var map = new HashSet<string>();
|
||||
|
||||
foreach ( var g in globalProperties )
|
||||
{
|
||||
map.Add( g );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < data.numGlobalShaderProperties; i++ )
|
||||
{
|
||||
var p = data.GetGlobalShaderPropertyAt( i );
|
||||
|
|
@ -31,11 +39,12 @@ namespace Rokojori
|
|||
this.LogInfo( "Prop:", i );
|
||||
|
||||
|
||||
if ( p == null )
|
||||
if ( p == null || map.Contains( p.GetPropertyName().propertyName ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
this.LogInfo( i, ">>", p.GetPropertyName().propertyName );
|
||||
|
||||
p.AddAsGlobalUniform();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ namespace Rokojori
|
|||
public abstract RenderingServer.GlobalShaderParameterType GetParameterType();
|
||||
|
||||
public void AddAsGlobalUniform()
|
||||
{
|
||||
{
|
||||
|
||||
RenderingServer.GlobalShaderParameterAdd( name, GetParameterType(), GetValue() );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool,GlobalClass]
|
||||
public partial class SetUIText: Action
|
||||
{
|
||||
[Export]
|
||||
public UIText uiText;
|
||||
|
||||
[Export]
|
||||
public LocaleText locale;
|
||||
|
||||
protected override void _OnTrigger()
|
||||
{
|
||||
if ( uiText == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uiText.locale = locale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://csomp5h8v5ajn
|
||||
|
|
@ -118,7 +118,7 @@ void fragment()
|
|||
|
||||
float anglefillState = angleFill( UV - vec2( 0.5 ), fillStateAngle, fillStateOffset );
|
||||
|
||||
COLOR = vec4( outputColor.rgb * tex.rgb, outputColor.a * mask * opacity * tex.a * anglefillState);
|
||||
COLOR *= vec4( outputColor.rgb * tex.rgb, outputColor.a * mask * opacity * tex.a * anglefillState);
|
||||
|
||||
// Called for every pixel the material is visible on.
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue