-
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.
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 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,53 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Elements.Core; | ||
using FrooxEngine; | ||
using FrooxEngine.ProtoFlux.Core; | ||
|
||
namespace Obsidian | ||
{ | ||
[ImplementableClass(true)] | ||
internal static class ExecutionHook | ||
{ | ||
// Fields for reflective access | ||
private static Type? __connectorType; | ||
private static Type? __connectorTypes; | ||
|
||
// Static constructor for initializing the hook | ||
static ExecutionHook() | ||
{ | ||
try | ||
{ | ||
Engine.Current.OnReady += () => | ||
{ | ||
ShaderInjection.AppendShaders(); | ||
|
||
}; | ||
} | ||
catch (Exception e) | ||
{ | ||
UniLog.Log($"Exception thrown during initialization: {e}"); | ||
} | ||
} | ||
|
||
// Method to instantiate the connector | ||
private static DummyConnector InstantiateConnector() => new DummyConnector(); | ||
|
||
// Dummy connector class implementing IConnector | ||
private class DummyConnector : IConnector | ||
{ | ||
public IImplementable? Owner { get; private set; } | ||
|
||
public void ApplyChanges() { } | ||
|
||
public void AssignOwner(IImplementable owner) => Owner = owner; | ||
|
||
public void Destroy(bool destroyingWorld) { } | ||
|
||
public void Initialize() { } | ||
|
||
public void RemoveOwner() => Owner = null; | ||
} | ||
} | ||
} |
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,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using FrooxEngine; | ||
using SkyFrost.Base; | ||
using FrooxEngine.Store; | ||
using System.IO; | ||
namespace Obsidian.Shaders | ||
{ | ||
internal class ShaderInjection | ||
{ | ||
|
||
|
||
private static readonly List<Uri> Shaders = new() | ||
{ | ||
|
||
}; | ||
public static string ExtractSignature(Uri uri) | ||
{ | ||
if (uri.Scheme != "resdb") | ||
{ | ||
throw new ArgumentException("Not a resdb URI"); | ||
} | ||
string path = uri.Segments[1]; | ||
return Path.GetFileNameWithoutExtension(path); | ||
} | ||
|
||
private static async Task RegisterShader(Uri uri) | ||
{ | ||
var signature = ExtractSignature(uri); | ||
var shaderExists = await Engine.Current.LocalDB.ReadVariableAsync(signature, false); | ||
if (!shaderExists) await Engine.Current.LocalDB.WriteVariableAsync(signature, true); | ||
} | ||
|
||
|
||
public static void AppendShaders() => Task.WaitAll(Shaders.Select(shader => RegisterShader(shader)).ToArray()); | ||
} | ||
} |