daily update on 20240828 by nitload youmu, autotexture added

This commit is contained in:
Nitload
2024-08-28 10:58:31 +08:00
parent d082071f2d
commit 1ee4e4a42f
586 changed files with 60910 additions and 123106 deletions
@@ -35,18 +35,15 @@ using StgSharp.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Logic
namespace StgSharp.BluePrint
{
public delegate void BlueprintNodeAction(
in Dictionary<string, BlueprintPipeline> inpput,
in Dictionary<string, BlueprintPipeline> output);
/// <summary>
///
@@ -59,83 +56,62 @@ namespace StgSharp.Logic
public class BlueprintNode : IComparable<BlueprintNode>
#pragma warning restore CA1036
{
private BlueprintNodeAction mainOperation;
private protected bool levelAvailable, nativeRequested;
private protected int _level;
private string name;
private protected Dictionary<string, BlueprintPipeline> _inputInterfaces;
private protected Dictionary<string, BlueprintPipeline> _outputInterfaces;
private protected int _level;
private IConvertableToBlueprintNode mainOperation;
private string name;
internal BlueprintNode(string name,
BlueprintNodeAction operation, bool isNative,
string[] inputPorts,
string[] outputPorts)
IConvertableToBlueprintNode node, bool isNative)
{
this.levelAvailable = false;
this.name = name;
nativeRequested = isNative;
mainOperation = operation;
mainOperation = node;
_inputInterfaces = new Dictionary<string, BlueprintPipeline>();
_outputInterfaces = new Dictionary<string, BlueprintPipeline>();
if (inputPorts.Length == 0 )
foreach (string portName in node.InputInterfacesName)
{
throw new ArgumentNullException(nameof(inputPorts));
_inputInterfaces.Add(portName, null!);
}
if (outputPorts.Length == 0)
foreach (string portName in node.OutputInterfacesName)
{
throw new ArgumentNullException(nameof(outputPorts));
}
foreach (var portName in inputPorts)
{
_inputInterfaces.Add(portName, null);
}
foreach (var portName in outputPorts)
{
_outputInterfaces.Add(portName, null);
_outputInterfaces.Add(portName, null!);
}
}
public BlueprintNode(string name, IConvertableToBlueprintNode convertable)
{
this.levelAvailable = false;
this.name = name;
_inputInterfaces = new Dictionary<string, BlueprintPipeline>();
_outputInterfaces = new Dictionary<string, BlueprintPipeline>();
mainOperation = convertable.MainExecution;
foreach (var soket in convertable.InputInterfacesName)
{
_inputInterfaces.Add(soket, null);
}
foreach (var soket in convertable.OutputInterfacesName)
{
_outputInterfaces.Add(soket, null);
}
}
public BlueprintNode(string name,
#pragma warning disable CS8618
internal BlueprintNode(string name, bool isNative,
string[] inputPorts,
string[] outputPorts
)
#pragma warning restore CS8618
{
this.levelAvailable = false;
if ((inputPorts == null) || (inputPorts.Length == 0))
{
throw new ArgumentNullException(nameof(inputPorts));
}
if ((outputPorts == null) || (outputPorts.Length == 0))
{
throw new ArgumentNullException(nameof(outputPorts));
}
levelAvailable = false;
this.name = name;
IsNative = isNative;
_inputInterfaces = new Dictionary<string, BlueprintPipeline>();
_outputInterfaces = new Dictionary<string, BlueprintPipeline>();
if (inputPorts.Length * outputPorts.Length == 0)
foreach (string portName in inputPorts)
{
throw new Exception();
_inputInterfaces.Add(portName, null!);
}
foreach (var portName in inputPorts)
foreach (string portName in outputPorts)
{
_inputInterfaces.Add(portName, null);
}
foreach (var portName in outputPorts)
{
_outputInterfaces.Add(portName, null);
_outputInterfaces.Add(portName, null!);
}
}
@@ -154,7 +130,7 @@ namespace StgSharp.Logic
return _level;
}
_level = 0;
foreach (var item in _inputInterfaces)
foreach (KeyValuePair<string, BlueprintPipeline> item in _inputInterfaces)
{
if (item.Value == null)
{
@@ -175,6 +151,11 @@ namespace StgSharp.Logic
internal Dictionary<string, BlueprintPipeline> InputInterfaces => _inputInterfaces;
internal Dictionary<string, BlueprintPipeline> OutputInterfaces => _outputInterfaces;
internal IConvertableToBlueprintNode Value
{
get => mainOperation;
}
public void AddAfter(
BlueprintNode former,
@@ -213,21 +194,6 @@ namespace StgSharp.Logic
SetCertainOutputPort(thisOutputPortName, pipeline);
}
public void Run()
{
try
{
//Console.WriteLine(name);
BlueprintPipeline.WaitAll(_inputInterfaces);
mainOperation(in _inputInterfaces, in _outputInterfaces);
}
catch (Exception)
{
throw;
}
}
public int CompareTo(BlueprintNode other)
{
#pragma warning disable CA1062
@@ -235,12 +201,30 @@ namespace StgSharp.Logic
#pragma warning restore CA1062
}
public virtual void Run()
{
try
{
//Console.WriteLine(name);
BlueprintPipeline.WaitAll(_inputInterfaces);
if (mainOperation != null)
{
mainOperation.ExecuteMain(in _inputInterfaces, in _outputInterfaces);
}
}
catch (Exception)
{
throw;
}
}
#region port operation
public BlueprintPipeline GetCertainInputPort(string name)
{
BlueprintPipeline ret;
if (!_inputInterfaces.TryGetValue(name,out ret))
if (!_inputInterfaces.TryGetValue(name, out ret))
{
throw new Exception($"Cannot find the interface named {name} in node {Name}.");
}
@@ -281,17 +265,15 @@ namespace StgSharp.Logic
}//--------------------------------- end of class -----------------------------------
public interface IConvertableToBlueprintNode
{
public string[] InputInterfacesName { get; }
public BlueprintNodeAction MainExecution { get; }
public string[] OutputInterfacesName { get; }
}
public class BlueprintNodeRunException : Exception
{
protected BlueprintNodeRunException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
public BlueprintNodeRunException()
{
}
@@ -308,9 +290,6 @@ namespace StgSharp.Logic
{
}
protected BlueprintNodeRunException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}