Outlines&More

This commit is contained in:
Josef 2025-01-19 21:35:51 +01:00
parent b866c2ef9e
commit 7b3f4d8c5e
47 changed files with 870 additions and 505 deletions

View File

@ -21,7 +21,7 @@ namespace Rokojori
{ {
var sequenceID = DispatchStart(); var sequenceID = DispatchStart();
var eventID = TimeLineScheduler.ScheduleEventIn( timeLine, duration, var eventID = TimeLineManager.ScheduleEventIn( timeLine, duration,
( eventID ) => ( eventID ) =>
{ {
RJLog.Log( ">> delay ended", Time.GetTicksMsec(), sequenceID, eventID ); RJLog.Log( ">> delay ended", Time.GetTicksMsec(), sequenceID, eventID );

View File

@ -41,7 +41,7 @@ namespace Rokojori
for ( int i = 0; i < list.Count; i++ ) for ( int i = 0; i < list.Count; i++ )
{ {
TimeLineScheduler.ScheduleEventIn( timeLine, offset, TimeLineManager.ScheduleEventIn( timeLine, offset,
id => id =>
{ {
Action.Trigger( list[ i ] ); Action.Trigger( list[ i ] );

View File

@ -32,7 +32,7 @@ namespace Rokojori
{ {
for ( int i = 0; i < numRepeats; i++ ) for ( int i = 0; i < numRepeats; i++ )
{ {
TimeLineScheduler.ScheduleEventIn( timeLine, i * duration, TimeLineManager.ScheduleEventIn( timeLine, i * duration,
id => id =>
{ {
if ( i == 0 ) if ( i == 0 )

View File

@ -49,11 +49,13 @@ namespace Rokojori
{ {
if ( _eventID != -1 ) if ( _eventID != -1 )
{ {
TimeLineScheduler.RemoveEvent( timeLine, _eventID ); TimeLineManager.RemoveEvent( timeLine, _eventID );
return; return;
} }
_eventID = TimeLineScheduler.ScheduleLoopEvent( timeLine, duration, offset, id => Action.Trigger( action ) ); var tle = TimeLineManager.ScheduleLoopEvent( timeLine, duration, offset, tle => Action.Trigger( action ) );
_eventID = tle.id;
} }
else else
{ {
@ -62,7 +64,7 @@ namespace Rokojori
return; return;
} }
TimeLineScheduler.RemoveEvent( timeLine, _eventID ); TimeLineManager.RemoveEvent( timeLine, _eventID );
_eventID = -1; _eventID = -1;
} }

View File

@ -138,20 +138,20 @@ namespace Rokojori
} }
); );
var start = TimeLineManager.GetPosition( timeline ); var start = timeline.position;
var end = start + duration; var end = start + duration;
animationID = TimeLineScheduler.ScheduleSpanIn( timeline, 0, duration, animationID = TimeLineManager.ScheduleSpanIn( timeline, 0, duration,
( int id, TimeLineSpanUpdateType type )=> ( TimeLineSpan span, TimeLineSpanUpdateType type )=>
{ {
if ( animationID != id ) if ( animationID != span.id )
{ {
return; return;
} }
var phase = TimeLineManager.GetRangePhase( timeline, start, end ); var phase = span.phase;
var value = flashCurve.Sample( phase ); var value = flashCurve.Sample( phase );
@ -211,15 +211,13 @@ namespace Rokojori
} }
} }
); ).id;
// RJLog.Log( "Processing animationID", animationID );
} }
public override void CancelAction( int id ) public override void CancelAction( int id )
{ {
// RJLog.Log( "CancelAction", id );
if ( false && actionID != id ) if ( false && actionID != id )
{ {

View File

@ -61,7 +61,7 @@ namespace Rokojori
return; return;
} }
var tl = TimeLine.IfNull_ReplaceByGameTime( timeline ); var tl = TimeLineManager.Ensure( timeline );
target.GlobalPosition = Smoothing.Apply( positionSmoothing, source.GlobalPosition, tl.delta ); target.GlobalPosition = Smoothing.Apply( positionSmoothing, source.GlobalPosition, tl.delta );
} }
} }

View File

@ -31,6 +31,9 @@ namespace Rokojori
[Export] [Export]
public TimeLine timeline; public TimeLine timeline;
[ExportGroup( "Transition")]
[Export] [Export]
public float inDuration; public float inDuration;
@ -43,23 +46,54 @@ namespace Rokojori
[Export] [Export]
public Curve outCurve = MathX.Curve( 0, 1 ); public Curve outCurve = MathX.Curve( 0, 1 );
[ExportGroup( "Color")]
[Export] [Export]
public HDRColor color; public HDRColor color;
public enum MaterialMode [Export( PropertyHint.Range, "0,1")]
public float opacityModulationStrength = 0.5f;
[Export( PropertyHint.Range, "0,10")]
public float opacityModulationDuration = 0.5f;
[Export( PropertyHint.Range, "0,1")]
public float opacityModulationTransition = 1f;
public enum OutlineMaterialMode
{ {
Flat_Outline, Flat_Outline,
Scanner_FancyOutline,
Custom_Material Custom_Material
} }
[ExportGroup( "Outline")]
[Export] [Export]
public MaterialMode materialMode; public OutlineMaterialMode outlineMaterialMode;
[Export] [Export]
public Material customMaterial; public Material outlineCustomMaterial;
[Export] [Export]
public ColorPropertyName customColorProperty; public ColorPropertyName outlineCustomColorProperty;
public enum OverlayMaterialMode
{
Flat_Overlay,
Custom_Material
}
[ExportGroup( "Overlay")]
[Export( PropertyHint.Range, "0,1")]
public float overlayOpacity = 0.02f;
[Export]
public OverlayMaterialMode overlayMaterialMode;
[Export]
public Material overlayCustomMaterial;
[Export]
public ColorPropertyName overlayCustomColorProperty;
List<HighlightAnimation> _active = new List<HighlightAnimation>(); List<HighlightAnimation> _active = new List<HighlightAnimation>();
@ -92,17 +126,48 @@ namespace Rokojori
Material material = null; Material material = null;
if ( MaterialMode.Flat_Outline == materialMode ) if ( OutlineMaterialMode.Flat_Outline == outlineMaterialMode )
{ {
var outlineMaterial = new OutlineMaterial(); var outlineMaterial = new OutlineMaterial();
outlineMaterial.albedo.Set( colorTransparent ); outlineMaterial.albedo.Set( colorTransparent );
material = outlineMaterial; material = outlineMaterial;
outlineMaterial.opacityModulationDuration.Set( opacityModulationDuration );
outlineMaterial.opacityModulationStrength.Set( opacityModulationStrength );
} }
else if ( MaterialMode.Custom_Material == materialMode ) else if ( OutlineMaterialMode.Scanner_FancyOutline == outlineMaterialMode )
{ {
material = (Material) customMaterial.Duplicate(); var outlineMaterial = new FancyOutlineMaterial();
customColorProperty.Set( material, colorTransparent ); outlineMaterial.albedo.Set( colorTransparent );
material = outlineMaterial;
outlineMaterial.opacityModulationDuration.Set( opacityModulationDuration );
outlineMaterial.opacityModulationStrength.Set( opacityModulationStrength );
} }
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
{
material = (Material) outlineCustomMaterial.Duplicate();
outlineCustomColorProperty.Set( material, colorTransparent );
}
if ( OverlayMaterialMode.Flat_Overlay == overlayMaterialMode )
{
var overlay = new OverlayMaterial();
overlay.albedo.Set( ColorX.SetAlpha( hdrColor, 0 ) );
material.NextPass = overlay;
overlay.opacityModulationDuration.Set( opacityModulationDuration );
overlay.opacityModulationStrength.Set( opacityModulationStrength );
}
else if ( OverlayMaterialMode.Custom_Material == overlayMaterialMode )
{
var overlay = (Material) overlayCustomMaterial.Duplicate();
overlayCustomColorProperty.Set( overlay, colorTransparent );
material.NextPass = overlay;
}
Arrays.ForEach( targets, Arrays.ForEach( targets,
t => t =>
@ -118,15 +183,18 @@ namespace Rokojori
var startPhase = animation.phase; var startPhase = animation.phase;
animation.tweenID = TimeLineManager.Tween( timeline, inDuration, animation.tweenID = TimeLineManager.ScheduleSpanIn( timeline, 0, inDuration,
( id, type, phase )=> ( span, type )=>
{ {
// RJLog.Log( "Start Highlight: ", id, "Active:",animation.tweenID, "Phase:", phase );
if ( animation.tweenID != id ) if ( animation.tweenID != span.id )
{ {
return; return;
} }
var phase = span.phase;
animation.phase = MathX.Map( phase, 0, 1, startPhase, 1 ); animation.phase = MathX.Map( phase, 0, 1, startPhase, 1 );
var p = animation.phase; var p = animation.phase;
@ -136,6 +204,11 @@ namespace Rokojori
p = inCurve.Sample( p ); p = inCurve.Sample( p );
} }
var transitionModulationStrength = Mathf.Lerp(
opacityModulationStrength, opacityModulationStrength * p,
opacityModulationTransition );
var tweenColor = ColorX.Fade( hdrColor, p ); var tweenColor = ColorX.Fade( hdrColor, p );
if ( TimeLineSpanUpdateType.End == type ) if ( TimeLineSpanUpdateType.End == type )
@ -147,21 +220,41 @@ namespace Rokojori
animation.materials.ForEach( animation.materials.ForEach(
( m )=> ( m )=>
{ {
if ( MaterialMode.Flat_Outline == materialMode ) if ( OutlineMaterialMode.Flat_Outline == outlineMaterialMode )
{ {
var outlineMaterial = ( OutlineMaterial ) m; var outlineMaterial = ( OutlineMaterial ) m;
outlineMaterial.albedo.Set( tweenColor ); outlineMaterial.albedo.Set( tweenColor );
outlineMaterial.opacityModulationStrength.Set( transitionModulationStrength );
} }
else if ( MaterialMode.Custom_Material == materialMode ) else if ( OutlineMaterialMode.Scanner_FancyOutline == outlineMaterialMode )
{ {
customColorProperty.Set( m, tweenColor); var outlineMaterial = ( FancyOutlineMaterial ) m;
outlineMaterial.albedo.Set( tweenColor );
outlineMaterial.opacityModulationStrength.Set( transitionModulationStrength );
} }
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
{
outlineCustomColorProperty.Set( m, tweenColor);
}
if ( OverlayMaterialMode.Flat_Overlay == overlayMaterialMode )
{
var overlay = (OverlayMaterial) m.NextPass;
overlay.albedo.Set( ColorX.Fade( tweenColor, overlayOpacity ) );
overlay.opacityModulationStrength.Set( transitionModulationStrength );
}
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
{
var material = (OverlayMaterial) m.NextPass;
outlineCustomColorProperty.Set( m, tweenColor);
}
} }
); );
} }
); ).id;
} }
void EndHighlight( Node3D[] targets ) void EndHighlight( Node3D[] targets )
@ -170,7 +263,6 @@ namespace Rokojori
if ( animation == null ) if ( animation == null )
{ {
// RJLog.Log( "No animation found:", targets );
return; return;
} }
@ -178,17 +270,16 @@ namespace Rokojori
var hdrColor = ColorX.Fade( color.GetHDRColor(), startPhase ); var hdrColor = ColorX.Fade( color.GetHDRColor(), startPhase );
var colorTransparent = ColorX.Fade( hdrColor, 0 ); var colorTransparent = ColorX.Fade( hdrColor, 0 );
animation.tweenID = TimeLineManager.Tween( timeline, outDuration, animation.tweenID = TimeLineManager.ScheduleSpanIn( timeline, 0, outDuration,
( id, type, phase )=> ( span, type )=>
{ {
// RJLog.Log( "End Highlight: ", id, "Active:",animation.tweenID, "Phase:", phase );
if ( animation.tweenID != id ) if ( animation.tweenID != span.id )
{ {
return; return;
} }
animation.phase = MathX.Map( phase, 0, 1, startPhase, 0 ); animation.phase = MathX.Map( span.phase, 0, 1, startPhase, 0 );
var p = animation.phase; var p = animation.phase;
@ -197,6 +288,10 @@ namespace Rokojori
p = outCurve.Sample( p ); p = outCurve.Sample( p );
} }
var transitionModulationStrength = Mathf.Lerp(
opacityModulationStrength, opacityModulationStrength * p,
opacityModulationTransition );
var tweenColor = ColorX.Fade( hdrColor, p ); var tweenColor = ColorX.Fade( hdrColor, p );
if ( TimeLineSpanUpdateType.End == type ) if ( TimeLineSpanUpdateType.End == type )
@ -216,21 +311,41 @@ namespace Rokojori
animation.materials.ForEach( animation.materials.ForEach(
( m )=> ( m )=>
{ {
if ( MaterialMode.Flat_Outline == materialMode ) if ( OutlineMaterialMode.Flat_Outline == outlineMaterialMode )
{ {
var outlineMaterial = ( OutlineMaterial ) m; var outlineMaterial = ( OutlineMaterial ) m;
outlineMaterial.albedo.Set( tweenColor ); outlineMaterial.albedo.Set( tweenColor );
outlineMaterial.opacityModulationStrength.Set( transitionModulationStrength );
} }
else if ( MaterialMode.Custom_Material == materialMode ) else if ( OutlineMaterialMode.Scanner_FancyOutline == outlineMaterialMode )
{ {
customColorProperty.Set( m, tweenColor ); var outlineMaterial = ( FancyOutlineMaterial ) m;
outlineMaterial.albedo.Set( tweenColor );
outlineMaterial.opacityModulationStrength.Set( transitionModulationStrength );
} }
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
{
outlineCustomColorProperty.Set( m, tweenColor );
}
if ( OverlayMaterialMode.Flat_Overlay == overlayMaterialMode )
{
var overlay = (OverlayMaterial) m.NextPass;
overlay.albedo.Set( ColorX.Fade( tweenColor, overlayOpacity ) );
overlay.opacityModulationStrength.Set( transitionModulationStrength );
}
else if ( OutlineMaterialMode.Custom_Material == outlineMaterialMode )
{
var material = (OverlayMaterial) m.NextPass;
outlineCustomColorProperty.Set( m, tweenColor);
}
} }
); );
} }
} }
); ).id;
} }

View File

@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="HighlightEffect" load_steps=5 format=3 uid="uid://dadr1kd14m7g3"] [gd_resource type="Resource" script_class="HighlightEffect" load_steps=6 format=3 uid="uid://dadr1kd14m7g3"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/HDRColor.cs" id="1_sk831"] [ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/HDRColor.cs" id="1_sk831"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/Highlight/HighlightEffect.cs" id="2_pq63c"] [ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/Highlight/HighlightEffect.cs" id="2_pq63c"]
@ -11,10 +11,20 @@ colorMultiply = 1.0
rgbMultiply = 1.0 rgbMultiply = 1.0
alphaMultiply = 1.0 alphaMultiply = 1.0
[sub_resource type="Curve" id="Curve_q8jgr"]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.503676, 0.105417), 0.560859, 0.560859, 0, 0, Vector2(1, 1), 4.02668, 0.0, 0, 0]
point_count = 3
[resource] [resource]
script = ExtResource("2_pq63c") script = ExtResource("2_pq63c")
timeline = ExtResource("3_8mahg") timeline = ExtResource("3_8mahg")
inDuration = 0.1 inDuration = 0.167
outDuration = 0.1 outDuration = 0.333
outCurve = SubResource("Curve_q8jgr")
color = SubResource("Resource_27v41") color = SubResource("Resource_27v41")
materialMode = 0 opacityModulationStrength = 0.75
opacityModulationDuration = 1.0
opacityModulationTransition = 1.0
outlineMaterialMode = 0
overlayOpacity = 0.01
overlayMaterialMode = 0

View File

@ -0,0 +1,35 @@
[gd_resource type="Resource" script_class="HighlightEffect" load_steps=7 format=3 uid="uid://di1vy33cwab4s"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/HDRColor.cs" id="1_3edxo"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/Highlight/HighlightEffect.cs" id="2_itc7c"]
[ext_resource type="Resource" uid="uid://h6oi6vkj4c2m" path="res://addons/rokojori_action_library/Runtime/Time/TimeLines/RealTime.tres" id="3_ttsky"]
[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]
point_count = 2
[sub_resource type="Curve" id="Curve_4o1t0"]
_data = [Vector2(0, 0), 0.0, 1.0, 0, 1, Vector2(1, 1), 1.0, 0.0, 1, 0]
point_count = 2
[resource]
script = ExtResource("2_itc7c")
timeline = ExtResource("3_ttsky")
inDuration = 0.083
inCurve = SubResource("Curve_vqio6")
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

View File

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class Rotate:Node3D
{
[Export]
public Vector3 eulerRotation;
[Export]
public Node3D target;
[Export]
public TimeLine timeline;
public override void _Process( double delta )
{
if ( target == null )
{
return;
}
var tl = TimeLineManager.Ensure( timeline );
var rotation = target.GetGlobalQuaternion() * Quaternion.FromEuler( eulerRotation * (float)tl.delta );
target.SetGlobalQuaternion( rotation );
}
}
}

View File

@ -44,7 +44,7 @@ namespace Rokojori
var duration = shakeEffect.shakeAmountCurve.GetRandomizedEndTime( randomization ); var duration = shakeEffect.shakeAmountCurve.GetRandomizedEndTime( randomization );
var curve = shakeEffect; var curve = shakeEffect;
var start = TimeLineManager.GetPosition( shakeEffect.timeline ); var start = shakeEffect.timeline.position;
var keyFrames = new List<KeyFrame<TransformData>>(); var keyFrames = new List<KeyFrame<TransformData>>();
var elapsed = 0f; var elapsed = 0f;
@ -74,10 +74,10 @@ namespace Rokojori
_currentSpanAnimationID = TimeLineScheduler.ScheduleSpanIn( timeline, 0, duration, _currentSpanAnimationID = TimeLineManager.ScheduleSpanIn( timeline, 0, duration,
( int spanAnimationID, TimeLineSpanUpdateType type )=> ( TimeLineSpan span, TimeLineSpanUpdateType type )=>
{ {
if ( spanAnimationID != _currentSpanAnimationID ) if ( span.id != _currentSpanAnimationID )
{ {
return; return;
} }
@ -107,7 +107,7 @@ namespace Rokojori
} }
var offset = TimeLineManager.GetPosition( shakeEffect.timeline ) - start; var offset = shakeEffect.timeline.position - start;
var keyFrame = kfAnimation.GetKeyFrameAt( offset ); var keyFrame = kfAnimation.GetKeyFrameAt( offset );
if ( keyFrame == lastKeyFrame && ! shakeEffect.smooth ) if ( keyFrame == lastKeyFrame && ! shakeEffect.smooth )
@ -155,7 +155,7 @@ namespace Rokojori
lastKeyFrame = keyFrame; lastKeyFrame = keyFrame;
} }
); ).id;
} }

View File

@ -39,7 +39,7 @@ namespace Rokojori
var timeline = animations.timeline; var timeline = animations.timeline;
var duration = animations.GetMaxDuration( _randomizations ); var duration = animations.GetMaxDuration( _randomizations );
var start = TimeLineManager.GetPosition( timeline ); var start = timeline.position;
var end = start + animations.GetMaxDuration( _randomizations ); var end = start + animations.GetMaxDuration( _randomizations );
var actionID = DispatchStart(); var actionID = DispatchStart();
@ -49,10 +49,10 @@ namespace Rokojori
AnimationManager.StartAnimation( c, target, c.animationMember ); AnimationManager.StartAnimation( c, target, c.animationMember );
} }
TimeLineScheduler.ScheduleSpanIn( timeline, 0, duration, TimeLineManager.ScheduleSpanIn( timeline, 0, duration,
( int id, TimeLineSpanUpdateType type )=> ( span, type )=>
{ {
var timeNow = TimeLineManager.GetPosition( timeline ); var timeNow = timeline.position;
var elapsed = timeNow - start; var elapsed = timeNow - start;
var index = 0; var index = 0;

View File

@ -76,11 +76,6 @@ namespace Rokojori
public bool ContainsPoint( Vector2 p ) public bool ContainsPoint( Vector2 p )
{ {
if ( true)
{
return true;
}
var d1 = Sign( p, a, b ); var d1 = Sign( p, a, b );
var d2 = Sign( p, b, c ); var d2 = Sign( p, b, c );
var d3 = Sign( p, c, a ); var d3 = Sign( p, c, a );

View File

@ -266,8 +266,6 @@ namespace Rokojori
var allBladesX = bladesX + blades; var allBladesX = bladesX + blades;
var allBladesZ = bladesZ + blades; var allBladesZ = bladesZ + blades;
var numDebugs = 0;
for ( int i = 0; i < allBladesX; i++ ) for ( int i = 0; i < allBladesX; i++ )
{ {
var x = ( i + 0.5f ) * cellSizeX; var x = ( i + 0.5f ) * cellSizeX;

View File

@ -146,8 +146,7 @@ namespace Rokojori
this.LogInfo( "Combining", _surfaces.Count, "meshes" ); this.LogInfo( "Combining", _surfaces.Count, "meshes" );
var index = 0; var index = 0;
var nm = 0;
var max = 100;
_materials.ForEach( _materials.ForEach(
( m )=> ( m )=>
{ {

View File

@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="SensorGroup" load_steps=11 format=3 uid="uid://c5rvf5v86ybks"] [gd_resource type="Resource" script_class="SensorGroup" load_steps=13 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="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://ci42d04kv03yx" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Button Left.tres" id="2_7ixeu"]
@ -10,7 +10,9 @@
[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://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://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"] [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"]
[ext_resource type="Resource" uid="uid://ds1rrltuj0mse" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Editor Camera/Move Up.tres" id="11_is0bq"]
[ext_resource type="Resource" uid="uid://dwigqkllvj8dq" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/PC/Mouse Editor Camera/Move Down.tres" id="12_rvojt"]
[resource] [resource]
script = ExtResource("1_eh8lb") 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")] 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"), ExtResource("11_is0bq"), ExtResource("12_rvojt")]

View File

@ -0,0 +1,16 @@
[gd_resource type="Resource" script_class="KeySensor" load_steps=2 format=3 uid="uid://dwigqkllvj8dq"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_7vkga"]
[resource]
script = ExtResource("1_7vkga")
key = 81
ctrlHold = 2
altHold = 2
shiftHold = 2
modifiersMode = 0
continous = false
_value = 0.0
_wasActive = false
_active = false
_activeTreshold = 0.5

View File

@ -4,7 +4,7 @@
[resource] [resource]
script = ExtResource("1_jess7") script = ExtResource("1_jess7")
key = 68 key = 87
ctrlHold = 2 ctrlHold = 2
altHold = 2 altHold = 2
shiftHold = 2 shiftHold = 2

View File

@ -4,7 +4,7 @@
[resource] [resource]
script = ExtResource("1_1s7kb") script = ExtResource("1_1s7kb")
key = 0 key = 65
ctrlHold = 2 ctrlHold = 2
altHold = 2 altHold = 2
shiftHold = 2 shiftHold = 2

View File

@ -0,0 +1,16 @@
[gd_resource type="Resource" script_class="KeySensor" load_steps=2 format=3 uid="uid://ds1rrltuj0mse"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_2vgvk"]
[resource]
script = ExtResource("1_2vgvk")
key = 69
ctrlHold = 2
altHold = 2
shiftHold = 2
modifiersMode = 0
continous = false
_value = 0.0
_wasActive = false
_active = false
_activeTreshold = 0.5

View File

@ -127,18 +127,62 @@ namespace Rokojori
} }
public static Material GetLastMaterial( Material material )
{
while ( material != null )
{
var nextMaterial = material.NextPass;
if ( nextMaterial == null )
{
return material;
}
material = nextMaterial;
}
return null;
}
public static Material GetLastMaterialOverlay( Node node )
{
if ( node is GeometryInstance3D gi )
{
return GetLastMaterial( gi.MaterialOverlay );
}
return null;
}
public static Material GetPreviousPass( Material firstMaterial, Material nextMaterial )
{
var material = firstMaterial;
while ( material != null )
{
if ( material.NextPass == nextMaterial )
{
return material;
}
material = material.NextPass;
}
return null;
}
public static void AddOverlay( Node node, Material material, bool forceTop = true ) public static void AddOverlay( Node node, Material material, bool forceTop = true )
{ {
if ( node is GeometryInstance3D gi ) if ( node is GeometryInstance3D gi )
{ {
if ( gi.MaterialOverlay == null || forceTop ) if ( gi.MaterialOverlay == null || forceTop )
{ {
gi.MaterialOverlay = material; gi.MaterialOverlay = material;
return;
} }
else
{ GetLastMaterial( gi.MaterialOverlay ).NextPass = material;
gi.MaterialOverlay.NextPass = material;
}
return; return;
} }
@ -148,26 +192,14 @@ namespace Rokojori
{ {
if ( node is GeometryInstance3D gi ) if ( node is GeometryInstance3D gi )
{ {
if ( forceTop ) if ( gi.MaterialOverlay == material || forceTop )
{ {
gi.MaterialOverlay = null; gi.MaterialOverlay = null;
} }
else if ( gi.MaterialOverlay == material )
{
gi.MaterialOverlay = gi.MaterialOverlay.NextPass;
}
else else
{ {
var mo = gi.MaterialOverlay; var previous = GetPreviousPass( gi.MaterialOverlay, material );
previous.NextPass = null;
while ( mo != null && mo.NextPass != material )
{
mo = mo.NextPass;
}
var next = material.NextPass;
mo.NextPass = next;
} }
return; return;

View File

@ -0,0 +1,62 @@
using Godot;
namespace Rokojori
{
public class FancyOutline
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutline.gdshader"
);
public static readonly ColorPropertyName albedo = ColorPropertyName.Create( "albedo" );
public static readonly FloatPropertyName size = FloatPropertyName.Create( "size" );
public static readonly FloatPropertyName sizeCloseScale = FloatPropertyName.Create( "sizeCloseScale" );
public static readonly FloatPropertyName sizeFarScale = FloatPropertyName.Create( "sizeFarScale" );
public static readonly FloatPropertyName closeDistance = FloatPropertyName.Create( "closeDistance" );
public static readonly FloatPropertyName farDistance = FloatPropertyName.Create( "farDistance" );
public static readonly FloatPropertyName opacityModulationStrength = FloatPropertyName.Create( "opacityModulationStrength" );
public static readonly FloatPropertyName opacityModulationDuration = FloatPropertyName.Create( "opacityModulationDuration" );
public static readonly FloatPropertyName scanLineAmount = FloatPropertyName.Create( "scanLineAmount" );
public static readonly FloatPropertyName scanLineDivisions = FloatPropertyName.Create( "scanLineDivisions" );
public static readonly FloatPropertyName scanLineSpeed = FloatPropertyName.Create( "scanLineSpeed" );
}
public partial class FancyOutlineMaterial:CustomMaterial
{
public static readonly CachedResource<FancyOutlineMaterial> ScanWhite500Ms20x = CustomMaterial.Cached<FancyOutlineMaterial>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutline Scan White 500ms 20x.material"
);
public readonly CustomMaterialProperty<Color> albedo;
public readonly CustomMaterialProperty<float> size;
public readonly CustomMaterialProperty<float> sizeCloseScale;
public readonly CustomMaterialProperty<float> sizeFarScale;
public readonly CustomMaterialProperty<float> closeDistance;
public readonly CustomMaterialProperty<float> farDistance;
public readonly CustomMaterialProperty<float> opacityModulationStrength;
public readonly CustomMaterialProperty<float> opacityModulationDuration;
public readonly CustomMaterialProperty<float> scanLineAmount;
public readonly CustomMaterialProperty<float> scanLineDivisions;
public readonly CustomMaterialProperty<float> scanLineSpeed;
public FancyOutlineMaterial()
{
Shader = FancyOutline.shader.Get();
albedo = new CustomMaterialProperty<Color>( this, FancyOutline.albedo );
size = new CustomMaterialProperty<float>( this, FancyOutline.size );
sizeCloseScale = new CustomMaterialProperty<float>( this, FancyOutline.sizeCloseScale );
sizeFarScale = new CustomMaterialProperty<float>( this, FancyOutline.sizeFarScale );
closeDistance = new CustomMaterialProperty<float>( this, FancyOutline.closeDistance );
farDistance = new CustomMaterialProperty<float>( this, FancyOutline.farDistance );
opacityModulationStrength = new CustomMaterialProperty<float>( this, FancyOutline.opacityModulationStrength );
opacityModulationDuration = new CustomMaterialProperty<float>( this, FancyOutline.opacityModulationDuration );
scanLineAmount = new CustomMaterialProperty<float>( this, FancyOutline.scanLineAmount );
scanLineDivisions = new CustomMaterialProperty<float>( this, FancyOutline.scanLineDivisions );
scanLineSpeed = new CustomMaterialProperty<float>( this, FancyOutline.scanLineSpeed );
}
}
}

View File

@ -0,0 +1,44 @@
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 size:hint_range(0,10) = 2;
uniform float sizeCloseScale : hint_range(0,10) = 1;
uniform float sizeFarScale : hint_range(0,10) = 0.5;
uniform float closeDistance = 20;
uniform float farDistance = 40;
uniform float opacityModulationStrength : hint_range(0,1) = 0.2;
uniform float opacityModulationDuration : hint_range(0,10) = 1;
uniform float scanLineAmount : hint_range(0,1) = 1;
uniform float scanLineDivisions = 50;
uniform float scanLineSpeed = 2;
varying vec4 appliedColor;
void vertex()
{
float cameraDistance = distance( VERTEX, CAMERA_POSITION_WORLD );
float outlineSize = size * mapClamped( cameraDistance, closeDistance, farDistance, sizeCloseScale, sizeFarScale );
VERTEX += NORMAL * outlineSize/500.0 * cameraDistance;
float sinTime = sin( mod( TIME, opacityModulationDuration ) / opacityModulationDuration * PI * 2.0 ) / 2.0;
float alpha = 1.0 - opacityModulationStrength * 0.5 + sinTime * opacityModulationStrength;
appliedColor = albedo;
appliedColor.a *= alpha;
}
void fragment()
{
vec2 sceenUV = SCREEN_UV;
float scanline = mix( 1, mod( sceenUV.y * scanLineDivisions - TIME * scanLineSpeed, 1.0 ), scanLineAmount );
ALBEDO = appliedColor.rgb;
ALPHA = appliedColor.a * scanline;
}

View File

@ -14,6 +14,9 @@ namespace Rokojori
public static readonly FloatPropertyName sizeFarScale = FloatPropertyName.Create( "sizeFarScale" ); public static readonly FloatPropertyName sizeFarScale = FloatPropertyName.Create( "sizeFarScale" );
public static readonly FloatPropertyName closeDistance = FloatPropertyName.Create( "closeDistance" ); public static readonly FloatPropertyName closeDistance = FloatPropertyName.Create( "closeDistance" );
public static readonly FloatPropertyName farDistance = FloatPropertyName.Create( "farDistance" ); public static readonly FloatPropertyName farDistance = FloatPropertyName.Create( "farDistance" );
public static readonly FloatPropertyName opacityModulationStrength = FloatPropertyName.Create( "opacityModulationStrength" );
public static readonly FloatPropertyName opacityModulationDuration = FloatPropertyName.Create( "opacityModulationDuration" );
public static readonly FloatPropertyName opacityModulationOffset = FloatPropertyName.Create( "opacityModulationOffset" );
} }
@ -32,6 +35,9 @@ namespace Rokojori
public readonly CustomMaterialProperty<float> sizeFarScale; public readonly CustomMaterialProperty<float> sizeFarScale;
public readonly CustomMaterialProperty<float> closeDistance; public readonly CustomMaterialProperty<float> closeDistance;
public readonly CustomMaterialProperty<float> farDistance; public readonly CustomMaterialProperty<float> farDistance;
public readonly CustomMaterialProperty<float> opacityModulationStrength;
public readonly CustomMaterialProperty<float> opacityModulationDuration;
public readonly CustomMaterialProperty<float> opacityModulationOffset;
public OutlineMaterial() public OutlineMaterial()
{ {
@ -43,6 +49,9 @@ namespace Rokojori
sizeFarScale = new CustomMaterialProperty<float>( this, Outline.sizeFarScale ); sizeFarScale = new CustomMaterialProperty<float>( this, Outline.sizeFarScale );
closeDistance = new CustomMaterialProperty<float>( this, Outline.closeDistance ); closeDistance = new CustomMaterialProperty<float>( this, Outline.closeDistance );
farDistance = new CustomMaterialProperty<float>( this, Outline.farDistance ); farDistance = new CustomMaterialProperty<float>( this, Outline.farDistance );
opacityModulationStrength = new CustomMaterialProperty<float>( this, Outline.opacityModulationStrength );
opacityModulationDuration = new CustomMaterialProperty<float>( this, Outline.opacityModulationDuration );
opacityModulationOffset = new CustomMaterialProperty<float>( this, Outline.opacityModulationOffset );
} }
} }

View File

@ -11,17 +11,26 @@ uniform float sizeCloseScale : hint_range(0,10) = 1;
uniform float sizeFarScale : hint_range(0,10) = 0.5; uniform float sizeFarScale : hint_range(0,10) = 0.5;
uniform float closeDistance = 20; uniform float closeDistance = 20;
uniform float farDistance = 40; uniform float farDistance = 40;
uniform float opacityModulationStrength : hint_range(0,1) = 0.2;
uniform float opacityModulationDuration : hint_range(0,10) = 1;
varying vec4 appliedColor;
void vertex() void vertex()
{ {
float cameraDistance = distance( VERTEX, CAMERA_POSITION_WORLD ); float cameraDistance = distance( VERTEX, CAMERA_POSITION_WORLD );
float outlineSize = size * mapClamped( cameraDistance, closeDistance, farDistance, sizeCloseScale, sizeFarScale ); float outlineSize = size * mapClamped( cameraDistance, closeDistance, farDistance, sizeCloseScale, sizeFarScale );
VERTEX += NORMAL * outlineSize/500.0 * cameraDistance; VERTEX += NORMAL * outlineSize/500.0 * cameraDistance;
float sinTime = sin( mod( TIME, opacityModulationDuration ) / opacityModulationDuration * PI * 2.0 ) / 2.0;
float alpha = 1.0 - opacityModulationStrength * 0.5 + sinTime * opacityModulationStrength;
appliedColor = albedo ;
appliedColor.a *= alpha;
} }
void fragment() void fragment()
{ {
ALBEDO = albedo.rgb; ALBEDO = appliedColor.rgb;
ALPHA = albedo.a; ALPHA = appliedColor.a;
} }

View File

@ -0,0 +1,36 @@
using Godot;
namespace Rokojori
{
public class Overlay
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Overlay/Overlay.gdshader"
);
public static readonly ColorPropertyName albedo = ColorPropertyName.Create( "albedo" );
public static readonly FloatPropertyName opacityModulationStrength = FloatPropertyName.Create( "opacityModulationStrength" );
public static readonly FloatPropertyName opacityModulationDuration = FloatPropertyName.Create( "opacityModulationDuration" );
}
public partial class OverlayMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<Color> albedo;
public readonly CustomMaterialProperty<float> opacityModulationStrength;
public readonly CustomMaterialProperty<float> opacityModulationDuration;
public OverlayMaterial()
{
Shader = Overlay.shader.Get();
albedo = new CustomMaterialProperty<Color>( this, Overlay.albedo );
opacityModulationStrength = new CustomMaterialProperty<float>( this, Overlay.opacityModulationStrength );
opacityModulationDuration = new CustomMaterialProperty<float>( this, Overlay.opacityModulationDuration );
}
}
}

View File

@ -0,0 +1,24 @@
// NOTE: Shader automatically converted from Godot Engine 4.3.stable.mono's StandardMaterial3D.
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx, unshaded;
uniform vec4 albedo : source_color;
uniform float opacityModulationStrength : hint_range(0,1) = 0.2;
uniform float opacityModulationDuration : hint_range(0,10) = 1;
varying vec4 appliedColor;
void vertex()
{
float sinTime = sin( mod( TIME, opacityModulationDuration ) / opacityModulationDuration * PI * 2.0 ) / 2.0;
float alpha = 1.0 - opacityModulationStrength * 0.5 + sinTime * opacityModulationStrength;
appliedColor = albedo ;
appliedColor.a *= alpha;
}
void fragment()
{
ALBEDO = appliedColor.rgb;
ALPHA *= appliedColor.a;
}

View File

@ -0,0 +1,48 @@
// NOTE: Shader automatically converted from Godot Engine 4.3.stable.mono's StandardMaterial3D.
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, 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 sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
uniform float colorScale = 1;
uniform float normalWrap = 1;
uniform float normalShift = 0;
uniform float weight = 1;
uniform float normalWrap2 = 1;
uniform float normalShift2 = 0;
uniform float weight2 = 1;
uniform float normalWrap3 = 1;
uniform float normalShift3 = 0;
uniform float weight3 = 1;
varying vec3 worldNormal;
void vertex()
{
worldNormal = NORMAL * MODEL_NORMAL_MATRIX;
}
void fragment()
{
float dotP = mod( dot( worldNormal, VIEW ) * normalWrap + normalShift, 1 );
float dotP2 = mod( dot( -NORMAL, -VIEW ) * normalWrap2 + normalShift2, 1 );
float dotP3 = mod( dot( -NORMAL, -VIEW ) * normalWrap3 + normalShift3, 1 );
vec4 albedo_tex = texture( texture_albedo, vec2( dotP, 0 ) ) * weight
+ texture( texture_albedo, vec2( dotP2, 0 ) ) * weight2
+ texture( texture_albedo, vec2( dotP3, 0 ) ) * weight3;
ALBEDO = albedo.rgb * albedo_tex.rgb * colorScale;
}

View File

@ -121,7 +121,17 @@ namespace Rokojori
var mMap = new StringMap(); var mMap = new StringMap();
mMap[ "${materialPath}" ] = resourceParentPath + "/" + materialName + ".material"; mMap[ "${materialPath}" ] = resourceParentPath + "/" + materialName + ".material";
mMap[ "${ShaderName}" ] = shaderName; mMap[ "${ShaderName}" ] = shaderName;
mMap[ "${csName}" ] = RegexUtility.ToValidCSName( shortName ).ToPascalCase();
var csName = RegexUtility.ToValidCSName( shortName ).ToPascalCase();
if ( System.Char.IsDigit( csName[ 0 ] ) )
{
csName = "_" + csName;
}
mMap[ "${csName}" ] = csName;
presets.Add( mMap.ReplaceAll( declaration ) ); presets.Add( mMap.ReplaceAll( declaration ) );
} }

View File

@ -10,13 +10,6 @@ namespace Rokojori
{ {
public class MapList<K,V>:Map<K,List<V>> public class MapList<K,V>:Map<K,List<V>>
{ {
public void ForEach( Action<K,List<V>> callback )
{
foreach ( var vk in this )
{
callback( vk.Key, vk.Value );
}
}
public void Add( K key, V value ) public void Add( K key, V value )
{ {

View File

@ -510,7 +510,7 @@ namespace Rokojori
public static string ToValidCSName( string source) public static string ToValidCSName( string source)
{ {
var output = new StringBuilder(); var output = new StringBuilder();
for ( int i = 0; i < source.Length; i++) for ( int i = 0; i < source.Length; i++)
{ {

View File

@ -15,8 +15,8 @@ namespace Rokojori
protected override void _OnTrigger() protected override void _OnTrigger()
{ {
var tm = Unique<TimeLineManager>.Get(); timeline = TimeLineManager.Ensure( timeline );
tm.SetSpeed( timeline, speed ); timeline.runner.speed = speed;
} }
} }

View File

@ -0,0 +1,76 @@
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;
namespace Rokojori
{
public partial class TimeLineManager:NetworkNode
{
public static void RemoveEvent( TimeLine timeline, int id )
{
timeline = TimeLineManager.Ensure( timeline );
var runner = timeline.runner;
runner.RemoveEvent( id );
}
public static TimeLineEvent ScheduleEvent( TimeLine timeline, float position, Action<TimeLineEvent> callback )
{
timeline = TimeLineManager.Ensure( timeline );
var runner = timeline.runner;
var eventID = TimeLineManager.CreateID();
return runner._ScheduleEvent( position, eventID, false, callback );
}
public static TimeLineEvent ScheduleEventIn( TimeLine timeline, float offset, Action<TimeLineEvent> callback )
{
timeline = TimeLineManager.Ensure( timeline );
var runner = timeline.runner;
var position = timeline.position + offset;
var eventID = TimeLineManager.CreateID();
return runner._ScheduleEvent( position, eventID, false, callback );
}
public static TimeLineEvent ScheduleLoopEvent( TimeLine timeline, float duration, float offset, Action<TimeLineEvent> callback )
{
timeline = TimeLineManager.Ensure( timeline );
var runner = timeline.runner;
var eventID = TimeLineManager.CreateID();
return runner._ScheduleLoopEvent( duration, offset, eventID, false, callback );
}
public static TimeLineSpan ScheduleSpan( TimeLine timeline, float start, float end, Action<TimeLineSpan,TimeLineSpanUpdateType> callback )
{
timeline = TimeLineManager.Ensure( timeline );
var runner = timeline.runner;
var spanID = TimeLineManager.CreateID();
var duration = end - start;
return runner._ScheduleSpan( start, end, spanID, false, callback );
}
public static TimeLineSpan ScheduleSpanIn( TimeLine timeline, float delay, float duration, Action<TimeLineSpan,TimeLineSpanUpdateType> callback )
{
timeline = TimeLineManager.Ensure( timeline );
var runner = timeline.runner;
var start = timeline.position + delay;
var end = start + duration;
var spanID = TimeLineManager.CreateID();
return runner._ScheduleSpan( start, end, spanID, false, callback );
}
}
}

View File

@ -28,35 +28,36 @@ namespace Rokojori
public bool autoStart = true; public bool autoStart = true;
public float delta public TimeLineRunner runner
{ {
get get
{ {
var tm = Unique<TimeLineManager>.Get();
return tm.GetRunner( this ).currentDelta; var tm = TimeLineManager.Get();
if ( tm == null )
{
return null;
}
return tm.GetRunner( this );
} }
} }
public static TimeLine IfNull_ReplaceByGameTime( TimeLine other ) public float delta => runner == null ? 1/60f : runner.currentDelta;
{
if ( other != null )
{
return other;
}
var tm = Unique<TimeLineManager>.Get(); public float position => runner.position;
return tm.gameTimeTimeLine;
public float ComputePhase( float duration, float offset = 0 )
{
var time = position + offset;
return ( time % duration ) / duration;
} }
public static TimeLine IfNull_ReplaceByRealTime( TimeLine other ) public float ComputeRange( float start, float end )
{ {
if ( other != null ) return MathX.Normalize( position, start, end );
{
return other;
}
var tm = Unique<TimeLineManager>.Get();
return tm.realTimeTimeLine;
} }

View File

@ -16,6 +16,8 @@ namespace Rokojori
public bool wasInside = false; public bool wasInside = false;
public bool looping = false; public bool looping = false;
public float loopDuration = 0; public float loopDuration = 0;
public Action<TimeLineEvent> callback;
public TimeLine timeLine;
public float GetNextLoopPosition( float timelinePosition ) public float GetNextLoopPosition( float timelinePosition )

View File

@ -24,9 +24,6 @@ namespace Rokojori
[Export] [Export]
public bool computeRealtimeWithEngineDelta; public bool computeRealtimeWithEngineDelta;
public readonly EventSlot<int> onEvent = new EventSlot<int>();
public readonly EventSlot<Tuple<int,TimeLineSpanUpdateType>> onSpan = new EventSlot<Tuple<int,TimeLineSpanUpdateType>>();
List<TimeLineRunner> _runners = new List<TimeLineRunner>(); List<TimeLineRunner> _runners = new List<TimeLineRunner>();
@ -38,6 +35,11 @@ namespace Rokojori
Initialize(); Initialize();
} }
public static TimeLineManager Get()
{
return Unique<TimeLineManager>.Get();
}
float _lastUpdate = 0; float _lastUpdate = 0;
DateTime lastUpdated = DateTime.Now; DateTime lastUpdated = DateTime.Now;
float _estimatedDelta = 0; float _estimatedDelta = 0;
@ -52,12 +54,12 @@ namespace Rokojori
{ {
UpdateRealTime( delta ); UpdateRealTime( delta );
if ( gameTimeTimeLine != null ) if ( ! Engine.IsEditorHint() && gameTimeTimeLine != null )
{ {
Engine.TimeScale = GetModulatedSpeed( gameTimeTimeLine ); Engine.TimeScale = gameTimeTimeLine.runner.modulatedSpeed;
} }
_runners.ForEach( r => r.UpdateTimeLine( unscaledTimeDelta, this ) ); _runners.ForEach( r => r.UpdateTimeLine( unscaledTimeDelta ) );
} }
@ -72,25 +74,6 @@ namespace Rokojori
runner.Modulate( c, onReady ); runner.Modulate( c, onReady );
} }
public static int Tween( TimeLine timeline, float duration, Action<int,TimeLineSpanUpdateType,float> callback )
{
timeline = TimeLine.IfNull_ReplaceByGameTime( timeline );
var startTime = GetPosition( timeline );
var spanID = TimeLineScheduler.ScheduleSpanIn( timeline, 0, duration,
( int id, TimeLineSpanUpdateType type )=>
{
var timeNow = GetPosition( timeline );
var elapsed = timeNow - startTime;
var phase = Mathf.Clamp( elapsed / duration, 0, 1 );
callback( id, type, phase );
}
);
return spanID;
}
void UpdateRealTime( double engineDelta ) void UpdateRealTime( double engineDelta )
{ {
var now = DateTime.Now; var now = DateTime.Now;
@ -128,13 +111,26 @@ namespace Rokojori
} }
_initialized = true; _initialized = true;
_runners = Lists.Map( timeLines, tl => new TimeLineRunner( tl ) ); _runners = Lists.Map( timeLines, tl => new TimeLineRunner( tl, this ) );
}
public static TimeLine Ensure( TimeLine timeline )
{
if ( timeline != null )
{
return timeline;
}
var tm = TimeLineManager.Get();
return tm.gameTimeTimeLine;
} }
public TimeLineRunner GetRunner( TimeLine timeline ) public TimeLineRunner GetRunner( TimeLine timeline )
{ {
return GetRunner( _runners.FindIndex( r => r.timeLine == timeline ) ); return GetRunner( _runners.FindIndex( r => r.timeLine == timeline ) );
} }
public TimeLineRunner GetRunner( int index ) public TimeLineRunner GetRunner( int index )
{ {
if ( index < 0 || index >= _runners.Count ) if ( index < 0 || index >= _runners.Count )
@ -145,128 +141,17 @@ namespace Rokojori
return _runners[ index ]; return _runners[ index ];
} }
public int CreateID() int _CreateID()
{ {
_idCounter ++; _idCounter ++;
return _idCounter; return _idCounter;
} }
public static float GetPosition( TimeLine timeLine ) public static int CreateID()
{ {
var manager = Unique<TimeLineManager>.Get(); var tm = TimeLineManager.Get();
return tm._CreateID();
if ( manager == null )
{
return Time.GetTicksMsec() / 1000f;
}
var index = Arrays.IndexOf( manager.timeLines, timeLine );
index = Mathf.Max( index, 0 );
return (float) manager.GetPosition( index );
} }
public static float GetPhase( TimeLine timeLine, float duration, float offset = 0 )
{
var time = GetPosition( timeLine ) + offset;
return ( time % duration ) / duration;
}
public static float GetRangePhase( TimeLine timeLine, float start, float end )
{
var time = GetPosition( timeLine );
var normalized = MathX.Normalize( time, start, end );
return normalized;
}
public void ScheduleEvent( int timeLineIndex, float position, int callbackID, bool isPersistent )
{
var runner = _runners[ timeLineIndex ];
runner.ScheduleEvent( position, callbackID, isPersistent );
}
public void ScheduleLoopEvent( int timeLineIndex, float loopDuration, float loopOffset, int callbackID, bool isPersistent )
{
var runner = _runners[ timeLineIndex ];
runner.ScheduleLoopEvent( loopDuration, loopOffset, callbackID, isPersistent );
}
public void RemoveEvent( int timeLineIndex, int eventID )
{
var runner = _runners[ timeLineIndex ];
runner.RemoveEvent( eventID );
}
public void ScheduleSpan( int timeLineIndex, float start, float end, int callbackID, bool isPersistent )
{
var runner = _runners[ timeLineIndex ];
runner.ScheduleSpan( start, end, callbackID, isPersistent );
}
public float GetLastPosition( int timeLineIndex )
{
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return 0; }
return runner.lastPosition;
}
public float GetPosition( int timeLineIndex )
{
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return 0; }
return runner.position;
}
public void SetPosition( int timeLineIndex, float position )
{
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return; }
runner.position = position;
}
public double GetSpeed( int timeLineIndex )
{
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return 1; }
return runner.speed;
}
public float GetModulatedSpeed( TimeLine timeline )
{
var timeLineIndex = GetTimeLineIndex( timeline );
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return 1; }
return runner.modulatedSpeed;
}
public float GetSpeed( TimeLine timeline )
{
return (float) GetSpeed( GetTimeLineIndex( timeline ) );
}
public void SetSpeed( int timeLineIndex, float speed )
{
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return; }
runner.speed = speed;
}
public void SetSpeed( TimeLine timeline, float speed )
{
SetSpeed( GetTimeLineIndex( timeline ), speed );
}
public bool GetPlayState( int timeLineIndex )
{
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return false; }
return runner.playing;
}
public void SetPlayState( int timeLineIndex, bool isPlaying )
{
var runner = GetRunner( timeLineIndex ); if ( runner == null ){ return; }
runner.playing = isPlaying;
}
} }
} }

View File

@ -11,6 +11,7 @@ namespace Rokojori
public class TimeLineRunner public class TimeLineRunner
{ {
public TimeLine timeLine; public TimeLine timeLine;
public TimeLineManager manager;
public float lastPosition = 0; public float lastPosition = 0;
public float position = 0; public float position = 0;
@ -31,9 +32,10 @@ namespace Rokojori
public float modulatedSpeed => (float)( speed * _lastModulation * deltaScale ); public float modulatedSpeed => (float)( speed * _lastModulation * deltaScale );
public float currentDelta => _currentDelta; public float currentDelta => _currentDelta;
public TimeLineRunner( TimeLine timeLine ) public TimeLineRunner( TimeLine timeLine, TimeLineManager manager )
{ {
this.timeLine = timeLine; this.timeLine = timeLine;
this.manager = manager;
playing = timeLine.autoStart; playing = timeLine.autoStart;
} }
@ -51,7 +53,7 @@ namespace Rokojori
modulatorOnReady = onReady; modulatorOnReady = onReady;
} }
public void UpdateTimeLine( float realtimeDelta, TimeLineManager manager ) public void UpdateTimeLine( float realtimeDelta )
{ {
if ( ! playing ) if ( ! playing )
{ {
@ -95,30 +97,24 @@ namespace Rokojori
if ( isForward ) if ( isForward )
{ {
ProcessForward( manager ); ProcessForward();
} }
} }
List<int> AddRemoval( bool isPersistent, int i, List<int> list )
void ProcessForward()
{ {
if ( isPersistent ) ProcessEvents();
{ ProcessSpans();
return list;
}
if ( list == null )
{
list = new List<int>();
}
list.Add( i );
return list;
} }
void ProcessEvents()
void ProcessForward( TimeLineManager manager )
{ {
if ( requestedRemovals.Count > 0 ) if ( requestedRemovals.Count > 0 )
{ {
@ -128,10 +124,6 @@ namespace Rokojori
} }
List<int> eventRemovals = null; List<int> eventRemovals = null;
List<int> spanRemovals = null;
var scheduler = Unique<TimeLineScheduler>.Get();
for ( int i = 0; i < events.Count; i++ ) for ( int i = 0; i < events.Count; i++ )
{ {
@ -160,36 +152,28 @@ namespace Rokojori
continue; continue;
} }
RJLog.Log( "Emitting:", events[ i ].callback( events[ i ] );
"last:", lastPosition,
"now:", position,
"event:", eventPosition
);
// 0 1 2 3 4 5
// Last 3, Position 4
//
// manager.EmitSignal( TimeLineManager.SignalName.OnEvent, events[ i ].id );
manager.onEvent.DispatchEvent( events[ i ].id );
events[ i ].wasInside = true; events[ i ].wasInside = true;
} }
if ( eventRemovals != null ) if ( eventRemovals != null )
{ {
eventRemovals.ForEach( ev => scheduler._RemoveEventEntry( ev ) );
Lists.RemoveIncreasingSortedIndices( events, eventRemovals ); Lists.RemoveIncreasingSortedIndices( events, eventRemovals );
} }
}
void ProcessSpans()
{
if ( spans.Count == 0 ) if ( spans.Count == 0 )
{ {
return; return;
} }
List<int> spanRemovals = null;
var timelineSpan = new RangeDouble( lastPosition, position ); var timelineSpan = new RangeDouble( lastPosition, position );
var span = new RangeDouble( 0, 1 ); var span = new RangeDouble( 0, 1 );
var isForward = lastPosition < position; var isForward = lastPosition < position;
@ -201,8 +185,6 @@ namespace Rokojori
var overlaps = timelineSpan.Overlaps( span ); var overlaps = timelineSpan.Overlaps( span );
// RJLog.Log( "Span", i, overlaps, spans[ i ].id, ">>", spans[ i ].start, spans[ i ].end, "||", lastPosition, position );
if ( ! overlaps ) if ( ! overlaps )
{ {
if ( spans[ i ].wasInside ) if ( spans[ i ].wasInside )
@ -234,18 +216,34 @@ namespace Rokojori
spans[ i ].wasInside = true; spans[ i ].wasInside = true;
manager.onSpan.DispatchEvent( new Tuple<int, TimeLineSpanUpdateType>( spans[ i ].id, spanType ) ); spans[ i ].callback( spans[ i ], spanType );
// manager.EmitSignal( TimeLineManager.SignalName.OnSpan, spans[ i ].id, spanType );
} }
if ( spanRemovals != null ) if ( spanRemovals != null )
{ {
spanRemovals.ForEach( ev => scheduler._RemoveSpanEntry( ev ) );
Lists.RemoveIncreasingSortedIndices( spans, spanRemovals ); Lists.RemoveIncreasingSortedIndices( spans, spanRemovals );
} }
} }
List<int> AddRemoval( bool isPersistent, int index, List<int> list )
{
if ( isPersistent )
{
return list;
}
if ( list == null )
{
list = new List<int>();
}
list.Add( index );
return list;
}
List<int> requestedRemovals = new List<int>(); List<int> requestedRemovals = new List<int>();
public void RemoveEvent( int eventID ) public void RemoveEvent( int eventID )
@ -253,18 +251,21 @@ namespace Rokojori
requestedRemovals.Add( eventID ); requestedRemovals.Add( eventID );
} }
public TimeLineEvent _ScheduleEvent( float position, int callbackID, bool isPersistent, Action<TimeLineEvent> callback )
public void ScheduleEvent( float position, int callbackID, bool isPersistent )
{ {
var tle = new TimeLineEvent(); var tle = new TimeLineEvent();
tle.position = position; tle.position = position;
tle.id = callbackID; tle.id = callbackID;
tle.persistent = isPersistent; tle.persistent = isPersistent;
tle.callback = callback;
tle.timeLine = timeLine;
events.Add( tle ); events.Add( tle );
return tle;
} }
public void ScheduleLoopEvent( float loopDuration, float loopOffset, int callbackID, bool isPersistent ) public TimeLineEvent _ScheduleLoopEvent( float loopDuration, float loopOffset, int callbackID, bool isPersistent, Action<TimeLineEvent> callback )
{ {
var tle = new TimeLineEvent(); var tle = new TimeLineEvent();
tle.position = loopOffset; tle.position = loopOffset;
@ -272,11 +273,14 @@ namespace Rokojori
tle.loopDuration = loopDuration; tle.loopDuration = loopDuration;
tle.id = callbackID; tle.id = callbackID;
tle.persistent = isPersistent; tle.persistent = isPersistent;
tle.callback = callback;
tle.timeLine = timeLine;
events.Add( tle ); events.Add( tle );
return tle;
} }
public void ScheduleSpan( float start, float end, int callbackID, bool isPersistent ) public TimeLineSpan _ScheduleSpan( float start, float end, int callbackID, bool isPersistent, Action<TimeLineSpan, TimeLineSpanUpdateType> callback )
{ {
var tse = new TimeLineSpan(); var tse = new TimeLineSpan();
tse.start = start; tse.start = start;
@ -284,8 +288,12 @@ namespace Rokojori
tse.id = callbackID; tse.id = callbackID;
tse.persistent = isPersistent; tse.persistent = isPersistent;
tse.wasInside = false; tse.wasInside = false;
tse.callback = callback;
tse.timeLine = timeLine;
spans.Add( tse ); spans.Add( tse );
return tse;
} }
} }
} }

View File

@ -1,167 +0,0 @@
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;
namespace Rokojori
{
[GlobalClass]
public partial class TimeLineScheduler:Node
{
public static int ScheduleEventIn( TimeLine timeLine, float offset, Action<int> action, bool persistent = false )
{
var scheduler = Unique<TimeLineScheduler>.Get();
return scheduler._ScheduleEventIn( timeLine, offset, action, persistent );
}
int _ScheduleEventIn( TimeLine timeLine, float offset, Action<int> action, bool persistent = false )
{
var tm = Unique<TimeLineManager>.Get();
var tIndex = tm.GetTimeLineIndex( timeLine );
var position = tm.GetPosition( tIndex ) + offset;
return _ScheduleEventAt( timeLine, position, action, persistent );
}
public static int ScheduleEventAt( TimeLine timeLine, float position, Action<int> action, bool persistent = false )
{
var scheduler = Unique<TimeLineScheduler>.Get();
return scheduler._ScheduleEventAt( timeLine, position, action, persistent );
}
int _ScheduleEventAt( TimeLine timeLine, float position, Action<int> action, bool persistent = false )
{
AttachListeners();
var tm = Unique<TimeLineManager>.Get();
var tIndex = tm.GetTimeLineIndex( timeLine );
var id = tm.CreateID();
_eventActions[ id ] = action;
tm.ScheduleEvent( tIndex, position, id, persistent );
return id;
}
public static int ScheduleLoopEvent( TimeLine timeLine, float loopDuration, float loopOffset, Action<int> action, bool persistent = false )
{
var scheduler = Unique<TimeLineScheduler>.Get();
return scheduler._ScheduleLoopEvent( timeLine, loopDuration, loopOffset, action, persistent );
}
int _ScheduleLoopEvent( TimeLine timeLine, float loopDuration, float loopOffset, Action<int> action, bool persistent = false )
{
AttachListeners();
var tm = Unique<TimeLineManager>.Get();
var tIndex = tm.GetTimeLineIndex( timeLine );
var id = tm.CreateID();
_eventActions[ id ] = action;
tm.ScheduleLoopEvent( tIndex, loopDuration, loopOffset, id, persistent );
return id;
}
public static void RemoveEvent( TimeLine timeLine, int id )
{
var tm = Unique<TimeLineManager>.Get();
var tIndex = tm.GetTimeLineIndex( timeLine );
tm.RemoveEvent( tIndex, id );
}
public static int ScheduleSpanAt( TimeLine timeLine, float start, float end, Action<int,TimeLineSpanUpdateType> action, bool persistent = false )
{
var scheduler = Unique<TimeLineScheduler>.Get();
return scheduler._ScheduleSpan( timeLine, start, end, action, persistent );
}
public static int ScheduleSpanIn( TimeLine timeLine, float offset, float duration, Action<int,TimeLineSpanUpdateType> action, bool persistent = false )
{
var scheduler = Unique<TimeLineScheduler>.Get();
var tm = Unique<TimeLineManager>.Get();
var tIndex = tm.GetTimeLineIndex( timeLine );
var position = tm.GetPosition( tIndex );
var start = position + offset;
var end = start + duration;
return scheduler._ScheduleSpan( timeLine, start, end, action, persistent );
}
int _ScheduleSpan( TimeLine timeLine, float start, float end, Action<int,TimeLineSpanUpdateType> action, bool persistent = false )
{
AttachListeners();
var tm = Unique<TimeLineManager>.Get();
var tIndex = tm.GetTimeLineIndex( timeLine );
var id = tm.CreateID();
_spanActions[ id ] = action;
tm.ScheduleSpan( tIndex, start, end, id, persistent );
return id;
}
bool _listenersAttached = false;
HashSet<int> _persistentEventsAndSpans = new HashSet<int>();
Dictionary<int,Action<int>> _eventActions = new Dictionary<int, Action<int>>();
Dictionary<int,Action<int,TimeLineSpanUpdateType>> _spanActions = new Dictionary<int, Action<int,TimeLineSpanUpdateType>>();
void AttachListeners()
{
if ( _listenersAttached )
{
return;
}
_listenersAttached = true;
var tm = Unique<TimeLineManager>.Get();
tm.onEvent.AddAction(
( id )=>
{
OnEvent( id );
}
);
tm.onSpan.AddAction(
( t )=>
{
OnSpan( t.Item1 , t.Item2 );
}
);
}
public void _RemoveEventEntry( int id )
{
_eventActions.Remove( id );
}
public void _RemoveSpanEntry( int id )
{
_spanActions.Remove( id );
}
void OnEvent( int id )
{
if ( ! _eventActions.ContainsKey( id ) )
{
return;
}
_eventActions[ id ]( id );
}
void OnSpan( int id, TimeLineSpanUpdateType type )
{
if ( ! _spanActions.ContainsKey( id ) )
{
return;
}
_spanActions[ id ]( id, type );
}
}
}

View File

@ -16,11 +16,6 @@ namespace Rokojori
CompletelyInside CompletelyInside
} }
public class TimeLineSpanUpdate
{
public TimeLineSpan span;
public TimeLineSpanUpdate type;
}
public class TimeLineSpan public class TimeLineSpan
{ {
@ -29,5 +24,19 @@ namespace Rokojori
public float start; public float start;
public float end; public float end;
public bool wasInside = false; public bool wasInside = false;
public TimeLine timeLine;
public Action<TimeLineSpan, TimeLineSpanUpdateType> callback;
public float duration => end - start;
public float phase
{
get
{
var position = timeLine.position;
return Mathf.Clamp( ( position - start ) / duration, 0, 1 );
}
}
} }
} }

View File

@ -217,7 +217,8 @@ namespace Rokojori
{ {
for ( var i = increasinglySortedRemovals.Count - 1; i >= 0; i-- ) for ( var i = increasinglySortedRemovals.Count - 1; i >= 0; i-- )
{ {
list.RemoveAt( i ); var index = increasinglySortedRemovals[ i ];
list.RemoveAt( index );
} }
} }

View File

@ -75,7 +75,7 @@ namespace Rokojori
{ {
var transitionSettings = UIStyle.GetTransitionSettings( container, property ); var transitionSettings = UIStyle.GetTransitionSettings( container, property );
propertyTransition.timeLine = transitionSettings.timeLine; propertyTransition.timeLine = transitionSettings.timeLine;
propertyTransition.start = TimeLineManager.GetPosition( transitionSettings.timeLine ); propertyTransition.start = transitionSettings.timeLine.position;
propertyTransition.end = propertyTransition.start + transitionSettings.duration; propertyTransition.end = propertyTransition.start + transitionSettings.duration;
propertyTransition.transitioning = true; propertyTransition.transitioning = true;
propertyTransition.curve = transitionSettings.curve; propertyTransition.curve = transitionSettings.curve;
@ -90,7 +90,7 @@ namespace Rokojori
var computedTransitionValue = Compute( control, propertyTransition.value, defaultColor ); var computedTransitionValue = Compute( control, propertyTransition.value, defaultColor );
var transitionPhase = TimeLineManager.GetRangePhase( propertyTransition.timeLine, propertyTransition.start, propertyTransition.end ); var transitionPhase = propertyTransition.timeLine.ComputeRange( propertyTransition.start, propertyTransition.end );
if ( transitionPhase >= 1 ) if ( transitionPhase >= 1 )
{ {
@ -120,7 +120,8 @@ namespace Rokojori
return color.color; return color.color;
} }
var phase = TimeLineManager.GetPhase( color.timeLine, color.animationDuration, color.animationOffset ); // var phase = TimeLineManager.GetPhase( color.timeLine, color.animationDuration, color.animationOffset );
var phase = color.timeLine.ComputePhase( color.animationDuration, color.animationOffset );
var gradientColor = color.animationGradient.Sample( phase ); var gradientColor = color.animationGradient.Sample( phase );

View File

@ -170,7 +170,7 @@ namespace Rokojori
{ {
var transitionSettings = UIStyle.GetTransitionSettings( container, property ); var transitionSettings = UIStyle.GetTransitionSettings( container, property );
propertyTransition.timeLine = transitionSettings.timeLine; propertyTransition.timeLine = transitionSettings.timeLine;
propertyTransition.start = TimeLineManager.GetPosition( transitionSettings.timeLine ); propertyTransition.start = transitionSettings.timeLine.position;
propertyTransition.end = propertyTransition.start + transitionSettings.duration; propertyTransition.end = propertyTransition.start + transitionSettings.duration;
propertyTransition.transitioning = true; propertyTransition.transitioning = true;
propertyTransition.curve = transitionSettings.curve; propertyTransition.curve = transitionSettings.curve;
@ -185,7 +185,7 @@ namespace Rokojori
var computedTransitionValue = Compute( control, propertyTransition.value, alternative, relative ); var computedTransitionValue = Compute( control, propertyTransition.value, alternative, relative );
var transitionPhase = TimeLineManager.GetRangePhase( propertyTransition.timeLine, propertyTransition.start, propertyTransition.end ); var transitionPhase = propertyTransition.timeLine.ComputeRange( propertyTransition.start, propertyTransition.end );
if ( transitionPhase >= 1 ) if ( transitionPhase >= 1 )
{ {
@ -235,7 +235,7 @@ namespace Rokojori
return value; return value;
} }
var phase = TimeLineManager.GetPhase( number.timeLine, number.animationDuration, number.animationOffset ); var phase = number.timeLine.ComputePhase( number.animationDuration, number.animationOffset );
return number.animationCurve.Sample( phase ) * value; return number.animationCurve.Sample( phase ) * value;

View File

@ -46,7 +46,7 @@ namespace Rokojori
{ {
var transitionSettings = getTransitionSettings(); var transitionSettings = getTransitionSettings();
propertyTransition.timeLine = transitionSettings.timeLine; propertyTransition.timeLine = transitionSettings.timeLine;
propertyTransition.start = TimeLineManager.GetPosition( transitionSettings.timeLine ); propertyTransition.start = transitionSettings.timeLine.position;
propertyTransition.end = propertyTransition.start + transitionSettings.duration; propertyTransition.end = propertyTransition.start + transitionSettings.duration;
propertyTransition.transitioning = true; propertyTransition.transitioning = true;
propertyTransition.curve = transitionSettings.curve; propertyTransition.curve = transitionSettings.curve;
@ -61,7 +61,7 @@ namespace Rokojori
var computedTransitionValue = computeValue( propertyTransition.value ); var computedTransitionValue = computeValue( propertyTransition.value );
var transitionPhase = TimeLineManager.GetRangePhase( propertyTransition.timeLine, propertyTransition.start, propertyTransition.end ); var transitionPhase = propertyTransition.timeLine.ComputeRange( propertyTransition.start, propertyTransition.end );
if ( transitionPhase >= 1 ) if ( transitionPhase >= 1 )
{ {

View File

@ -56,7 +56,7 @@ namespace Rokojori
void Start() void Start()
{ {
timelineOffset = TimeLineManager.GetPosition( effect.timeline ); timelineOffset = effect.timeline.position;
randomOffsets = new List<Vector3>(); randomOffsets = new List<Vector3>();
Arrays.ForEach( effect.animations, ( a => randomOffsets.Add( a.Randomize() ) ) ) ; Arrays.ForEach( effect.animations, ( a => randomOffsets.Add( a.Randomize() ) ) ) ;
@ -64,7 +64,7 @@ namespace Rokojori
public void Update() public void Update()
{ {
float timeLinePosition = TimeLineManager.GetPosition( effect.timeline ); float timeLinePosition = effect.timeline.position;
timePosition = timeLinePosition - timelineOffset; timePosition = timeLinePosition - timelineOffset;
position = Vector3.Zero; position = Vector3.Zero;

View File

@ -0,0 +1,61 @@
[gd_resource type="Resource" script_class="CameraEffect" load_steps=10 format=3 uid="uid://uyuplc6hm25j"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/VirtualCameras/Effects/CameraEffect.cs" id="1_5l6xm"]
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/VirtualCameras/Effects/CameraEffectTargetAnimationCurve.cs" id="1_x21rf"]
[ext_resource type="Resource" uid="uid://ch5nsa6yafs5l" path="res://addons/rokojori_action_library/Runtime/Time/TimeLines/GameTime.tres" id="3_lfgu3"]
[sub_resource type="Curve" id="Curve_62jxv"]
min_value = -1.0
_data = [Vector2(0, 0), 0.0, 5.72558, 0, 1, Vector2(0.0625, 0.357849), 0.0, 0.0, 0, 0, Vector2(0.231707, -0.252644), 0.0, 0.0, 0, 0, Vector2(0.429878, 0.113984), 0.0, 0.0, 0, 0, Vector2(1, 0), -0.199929, 0.0, 1, 0]
point_count = 5
[sub_resource type="Resource" id="Resource_esvga"]
script = ExtResource("1_x21rf")
target = 0
flipScaleYRandomly = true
duration = 0.2
durationRandomRange = 0.0
delay = 0.0
delayRandomRange = 0.0
curve = SubResource("Curve_62jxv")
scaleY = 0.1
scaleRandomRange = 0.2
[sub_resource type="Curve" id="Curve_h7nko"]
min_value = -1.0
_data = [Vector2(0, 0), 0.0, -2.46399, 0, 1, Vector2(0.170732, -0.420681), 0.0, 0.0, 0, 0, Vector2(0.271341, 0.388954), 0.0, 0.0, 0, 0, Vector2(0.503049, -0.130435), 0.0, 0.0, 0, 0, Vector2(0.689024, 0.0223267), 0.0, 0.0, 0, 0, Vector2(1, 0), -0.0717957, 0.0, 1, 0]
point_count = 6
[sub_resource type="Resource" id="Resource_s8na2"]
script = ExtResource("1_x21rf")
target = 1
flipScaleYRandomly = false
duration = 0.2
durationRandomRange = 0.0
delay = 0.0
delayRandomRange = 0.0
curve = SubResource("Curve_h7nko")
scaleY = 0.1
scaleRandomRange = 0.2
[sub_resource type="Curve" id="Curve_opp1p"]
min_value = -1.0
_data = [Vector2(0, 0), 0.0, 3.46886, 0, 1, Vector2(0.0945122, 0.32785), 0.0, 0.0, 0, 0, Vector2(1, 0), -0.36207, 0.0, 1, 0]
point_count = 3
[sub_resource type="Resource" id="Resource_wlebh"]
script = ExtResource("1_x21rf")
target = 6
flipScaleYRandomly = true
duration = 0.3
durationRandomRange = 0.0
delay = 0.0
delayRandomRange = 0.0
curve = SubResource("Curve_opp1p")
scaleY = 10.0
scaleRandomRange = 0.0
[resource]
script = ExtResource("1_5l6xm")
animations = [SubResource("Resource_esvga"), SubResource("Resource_s8na2"), SubResource("Resource_wlebh")]
timeline = ExtResource("3_lfgu3")