Skip to content

Commit

Permalink
gonna slip this in
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlinka committed Jul 2, 2024
1 parent 9c111fe commit c83ed60
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
53 changes: 53 additions & 0 deletions ProjectObsidian/Injection/Injection.cs
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;
}
}
}
39 changes: 39 additions & 0 deletions ProjectObsidian/Injection/ShaderInjection.cs
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());
}
}

0 comments on commit c83ed60

Please sign in to comment.