-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from LeCloutPanda/main
Added new Tween nodes(More to come soon)
- Loading branch information
Showing
20 changed files
with
290 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Threading.Tasks; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Actions | ||
{ | ||
[NodeCategory("Obsidian/Actions")] | ||
public class TweenPosition : AsyncActionNode<ExecutionContext> | ||
{ | ||
public ValueInput<float3> To; | ||
public ValueInput<float3> From; | ||
[Core.DefaultValueAttribute(1f)] | ||
public ValueInput<float> Duration; | ||
[Core.DefaultValueAttribute(CurvePreset.Smooth)] | ||
public ValueInput<CurvePreset> Curve; | ||
public ValueInput<bool> ProportionalDuration; | ||
public ObjectInput<Slot> Target; | ||
public AsyncCall OnStarted; | ||
public Continuation OnDone; | ||
|
||
protected override async Task<IOperation> RunAsync(ExecutionContext context) | ||
{ | ||
IField <float3> field = Target.Evaluate(context).Position_Field; | ||
if (field == null) | ||
{ | ||
return null; | ||
} | ||
float3 val = field.Value; | ||
float3 val2 = field.Value; | ||
if (To.Source != null) | ||
{ | ||
val2 = To.Evaluate(context); | ||
} | ||
if (From.Source != null) | ||
{ | ||
val = From.Evaluate(context); | ||
} | ||
float num = Duration.Evaluate(context, 1f); | ||
bool num2 = ProportionalDuration.Evaluate(context, defaultValue: false); | ||
CurvePreset curve = Curve.Evaluate(context, CurvePreset.Smooth); | ||
if (num2 && Coder<float3>.SupportsDistance) | ||
{ | ||
float num3 = Coder<float3>.Distance(val, val2); | ||
if (num3.IsValid()) | ||
{ | ||
num *= num3; | ||
} | ||
} | ||
TaskCompletionSource<bool> completion = new TaskCompletionSource<bool>(); | ||
field.TweenFromTo(val, val2, num, curve, null, delegate | ||
{ | ||
completion.SetResult(result: true); | ||
}); | ||
await OnStarted.ExecuteAsync(context); | ||
await completion.Task; | ||
return OnDone.Target; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Threading.Tasks; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Actions | ||
{ | ||
[NodeCategory("Obsidian/Actions")] | ||
public class TweenRotation : AsyncActionNode<ExecutionContext> | ||
{ | ||
public ValueInput<floatQ> To; | ||
public ValueInput<floatQ> From; | ||
[Core.DefaultValueAttribute(1f)] | ||
public ValueInput<float> Duration; | ||
[Core.DefaultValueAttribute(CurvePreset.Smooth)] | ||
public ValueInput<CurvePreset> Curve; | ||
public ValueInput<bool> ProportionalDuration; | ||
public ObjectInput<Slot> Target; | ||
public AsyncCall OnStarted; | ||
public Continuation OnDone; | ||
|
||
protected override async Task<IOperation> RunAsync(ExecutionContext context) | ||
{ | ||
IField <floatQ> field = Target.Evaluate(context).Rotation_Field; | ||
if (field == null) | ||
{ | ||
return null; | ||
} | ||
floatQ val = field.Value; | ||
floatQ val2 = field.Value; | ||
if (To.Source != null) | ||
{ | ||
val2 = To.Evaluate(context); | ||
} | ||
if (From.Source != null) | ||
{ | ||
val = From.Evaluate(context); | ||
} | ||
float num = Duration.Evaluate(context, 1f); | ||
bool num2 = ProportionalDuration.Evaluate(context, defaultValue: false); | ||
CurvePreset curve = Curve.Evaluate(context, CurvePreset.Smooth); | ||
if (num2 && Coder<floatQ>.SupportsDistance) | ||
{ | ||
float num3 = Coder<floatQ>.Distance(val, val2); | ||
if (num3.IsValid()) | ||
{ | ||
num *= num3; | ||
} | ||
} | ||
TaskCompletionSource<bool> completion = new TaskCompletionSource<bool>(); | ||
field.TweenFromTo(val, val2, num, curve, null, delegate | ||
{ | ||
completion.SetResult(result: true); | ||
}); | ||
await OnStarted.ExecuteAsync(context); | ||
await completion.Task; | ||
return OnDone.Target; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Threading.Tasks; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Actions | ||
{ | ||
[NodeCategory("Obsidian/Actions")] | ||
public class TweenScale: AsyncActionNode<ExecutionContext> | ||
{ | ||
public ValueInput<float3> To; | ||
public ValueInput<float3> From; | ||
[Core.DefaultValueAttribute(1f)] | ||
public ValueInput<float> Duration; | ||
[Core.DefaultValueAttribute(CurvePreset.Smooth)] | ||
public ValueInput<CurvePreset> Curve; | ||
public ValueInput<bool> ProportionalDuration; | ||
public ObjectInput<Slot> Target; | ||
public AsyncCall OnStarted; | ||
public Continuation OnDone; | ||
|
||
protected override async Task<IOperation> RunAsync(ExecutionContext context) | ||
{ | ||
IField<float3> field = Target.Evaluate(context).Scale_Field; | ||
if (field == null) | ||
{ | ||
return null; | ||
} | ||
float3 val = field.Value; | ||
float3 val2 = field.Value; | ||
if (To.Source != null) | ||
{ | ||
val2 = To.Evaluate(context); | ||
} | ||
if (From.Source != null) | ||
{ | ||
val = From.Evaluate(context); | ||
} | ||
float num = Duration.Evaluate(context, 1f); | ||
bool num2 = ProportionalDuration.Evaluate(context, defaultValue: false); | ||
CurvePreset curve = Curve.Evaluate(context, CurvePreset.Smooth); | ||
if (num2 && Coder<float3>.SupportsDistance) | ||
{ | ||
float num3 = Coder<float3>.Distance(val, val2); | ||
if (num3.IsValid()) | ||
{ | ||
num *= num3; | ||
} | ||
} | ||
TaskCompletionSource<bool> completion = new TaskCompletionSource<bool>(); | ||
field.TweenFromTo(val, val2, num, curve, null, delegate | ||
{ | ||
completion.SetResult(result: true); | ||
}); | ||
await OnStarted.ExecuteAsync(context); | ||
await completion.Task; | ||
return OnDone.Target; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using FrooxEngine; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Users.Avatar | ||
{ | ||
[ContinuouslyChanging] | ||
[NodeCategory("ProtoFlux/Obsidian/Avatar")] | ||
public class FindGrabbableFromSlot : ObjectFunctionNode<ExecutionContext, IGrabbable> | ||
{ | ||
public readonly ObjectInput<Slot> Slot; | ||
|
||
protected override IGrabbable Compute(ExecutionContext context) | ||
{ | ||
Slot slot = Slot.Evaluate(context); | ||
return slot == null ? null : slot.GetComponentInParents<Grabbable>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using FrooxEngine; | ||
using FrooxEngine.ProtoFlux; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Users.Avatar | ||
{ | ||
[ContinuouslyChanging] | ||
[NodeCategory("ProtoFlux/Obsidian/Slots")] | ||
public class CreateEmptySlot : ActionBreakableFlowNode<FrooxEngineContext> | ||
{ | ||
public readonly ObjectInput<Slot> Parent; | ||
public readonly ObjectInput<string> Name; | ||
public readonly ObjectInput<string> Tag; | ||
public readonly ValueInput<bool> Persistent; | ||
public readonly ValueInput<bool> Active; | ||
|
||
public readonly ObjectOutput<Slot> Slot; | ||
|
||
protected override bool Do(FrooxEngineContext context) | ||
{ | ||
Slot slot = context.LocalUser.LocalUserSpace.AddSlot(); | ||
slot.Parent = Parent.Evaluate(context); | ||
slot.Name = Name.Evaluate(context); | ||
slot.Tag = Tag.Evaluate(context); | ||
slot.PersistentSelf = Persistent.Evaluate(context); | ||
slot.ActiveSelf = Active.Evaluate(context); | ||
|
||
Slot.Write(slot, context); | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
using FrooxEngine; | ||
using FrooxEngine.CommonAvatar; | ||
using ProtoFlux.Core; | ||
using ProtoFlux.Runtimes.Execution; | ||
|
||
namespace ProtoFlux.Users.Avatar | ||
{ | ||
[ContinuouslyChanging] | ||
[NodeCategory("ProtoFlux/Obsidian/Avatar")] | ||
public class AvatarRootSlot : ObjectFunctionNode<ExecutionContext, Slot> | ||
{ | ||
public readonly ObjectInput<User> User; | ||
|
||
protected override Slot Compute(ExecutionContext context) | ||
{ | ||
User user = User.Evaluate(context); | ||
Slot slot = user.Root.Slot; | ||
List<AvatarRoot> list = new List<AvatarRoot>(); | ||
slot.GetFirstDirectComponentsInChildren(list); | ||
return user == null || list.Count == 0 ? null : list[0].Slot; | ||
} | ||
} | ||
} |
Oops, something went wrong.