Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlinka committed Jan 21, 2024
1 parent 4f86808 commit 861a7b8
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 15 deletions.
3 changes: 0 additions & 3 deletions ProjectObsidian.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
<Reference Include="Elements.Assets">
<HintPath>$(ResonitePath)Resonite_Data/Managed/Elements.Assets.dll</HintPath>
</Reference>
<Reference Include="SteamVR">
<HintPath>$(ResonitePath)/Managed/SteamVR.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
</ItemGroup>
</Project>
96 changes: 96 additions & 0 deletions ProtoFlux/Bindings/Utility/writetolog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using FrooxEngine;
using FrooxEngine.ProtoFlux;
using FrooxEngine.ProtoFlux.Runtimes.Execution;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Utility;


[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Utility" })]
public class WriteToLogBinding : AsyncActionNode<FrooxEngineContext>
{
public readonly SyncRef<INodeObjectOutput<string>> Value;
public readonly SyncRef<INodeValueOutput<LogSeverity>> Severity;
public readonly SyncRef<INodeObjectOutput<string>> Tag;
public readonly SyncRef<INodeObjectOutput<User>> HandlingUser;

public readonly SyncRef<INodeOperation> OnWriteStart;
public readonly SyncRef<INodeOperation> OnWriteComplete;

public override Type NodeType => typeof(WriteToLogNode);

public WriteToLogNode TypedNodeInstance { get; private set; }

public override INode NodeInstance => TypedNodeInstance;

public override int NodeInputCount => base.NodeInputCount + 4;

public override int NodeImpulseCount => base.NodeImpulseCount + 2;

public override N Instantiate<N>()
{
if (TypedNodeInstance != null)
{
throw new InvalidOperationException("Node has already been instantiated");
}
WriteToLogNode writeToLogNode = (TypedNodeInstance = new WriteToLogNode());
return writeToLogNode as N;
}

protected override void AssociateInstanceInternal(INode node)
{
if (node is WriteToLogNode typedNodeInstance)
{
TypedNodeInstance = typedNodeInstance;
return;
}
throw new ArgumentException("Node instance is not of type " + typeof(WriteToLogNode));
}

public override void ClearInstance()
{
TypedNodeInstance = null;
}

protected override ISyncRef GetInputInternal(ref int index)
{
ISyncRef inputInternal = base.GetInputInternal(ref index);
if (inputInternal != null)
{
return inputInternal;
}
switch (index)
{
case 0:
return Value;
case 1:
return Severity;
case 2:
return Tag;
case 3:
return HandlingUser;
default:
index -= 4;
return null;
}
}

protected override ISyncRef GetImpulseInternal(ref int index)
{
ISyncRef impulseInternal = base.GetImpulseInternal(ref index);
if (impulseInternal != null)
{
return impulseInternal;
}
switch (index)
{
case 0:
return OnWriteStart;
case 1:
return OnWriteComplete;
default:
index -= 2;
return null;
}
}
}
23 changes: 11 additions & 12 deletions ProtoFlux/Utility/WriteToLogNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using FrooxEngine;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using System;
using System.Threading;
using System.Threading.Tasks;
using FrooxEngine.ProtoFlux;

namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Utility
{
Expand All @@ -16,17 +15,17 @@ public enum LogSeverity
}

[NodeCategory("Obsidian/Utility/WriteToLog")]
public class WriteToLogNode : AsyncActionNode<ExecutionContext>
public class WriteToLogNode : AsyncActionNode<FrooxEngineContext>
{
public readonly ValueInput<string> Value;
public readonly ValueInput<LogSeverity> Severity;
public readonly ValueInput<string> Tag;
public readonly ValueInput<User> HandlingUser;
public ObjectInput<string> Value;
public ValueInput<LogSeverity> Severity;
public ObjectInput<string> Tag;
public ObjectInput<User> HandlingUser;

public AsyncCall OnWriteStart;
public Continuation OnWriteComplete;

protected override async Task<IOperation> RunAsync(ExecutionContext context)
protected override async Task<IOperation> RunAsync(FrooxEngineContext context)
{
User user = HandlingUser.Evaluate(context, context.LocalUser);
if (user != null)
Expand All @@ -35,18 +34,18 @@ protected override async Task<IOperation> RunAsync(ExecutionContext context)
switch (Severity.Evaluate(context))
{
case LogSeverity.Log:
UniLog.Log(Tag.EvaluateRaw(context) + Value.EvaluateRaw(context)?.ToString());
UniLog.Log(Tag.Evaluate(context) + Value.Evaluate(context)?.ToString());
break;
case LogSeverity.Warning:
UniLog.Warning(Tag.EvaluateRaw(context) + Value.EvaluateRaw(context)?.ToString());
UniLog.Warning(Tag.Evaluate(context) + Value.Evaluate(context)?.ToString());
break;
case LogSeverity.Error:
UniLog.Error(Tag.EvaluateRaw(context) + Value.EvaluateRaw(context)?.ToString());
UniLog.Error(Tag.Evaluate(context) + Value.Evaluate(context)?.ToString());
break;
}
return OnWriteComplete.Target;
}
return null;
}
}
}
}

0 comments on commit 861a7b8

Please sign in to comment.