add: LoadingScene, ProxyNode
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||||
<IsRoslynComponent>true</IsRoslynComponent>
|
<IsRoslynComponent>true</IsRoslynComponent>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Version>0.0.2</Version>
|
<Version>0.0.5</Version>
|
||||||
<Authors>Hangman</Authors>
|
<Authors>Hangman</Authors>
|
||||||
<PackageId>Polonium.Generators</PackageId>
|
<PackageId>Polonium.Generators</PackageId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace Polonium.Generators;
|
namespace Polonium.Generators.Generators;
|
||||||
[Generator]
|
[Generator]
|
||||||
public class AssetRegisterGenerator : AssetProcessGenerator
|
public class AssetRegisterGenerator : AssetProcessGenerator
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace Polonium.Generators;
|
namespace Polonium.Generators.Generators;
|
||||||
[Generator]
|
[Generator]
|
||||||
public class GlobalRegistryGenerator : ISourceGenerator
|
public class GlobalRegistryGenerator : ISourceGenerator
|
||||||
{
|
{
|
||||||
44
src/Generators/ProxyNodeGenerator.cs
Normal file
44
src/Generators/ProxyNodeGenerator.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
|
namespace Polonium.Generators.Generators;
|
||||||
|
[Generator]
|
||||||
|
public class ProxyNodeGenerator : AssetProcessGenerator
|
||||||
|
{
|
||||||
|
private INamedTypeSymbol? NodeProxy { get; set; }
|
||||||
|
|
||||||
|
private IEnumerable<INamedTypeSymbol> ProxyNodesInNamespace(INamespaceSymbol ns)
|
||||||
|
{
|
||||||
|
foreach (INamespaceOrTypeSymbol member in ns.GetMembers())
|
||||||
|
{
|
||||||
|
if (member is INamespaceSymbol nsx)
|
||||||
|
foreach (INamedTypeSymbol nsz in ProxyNodesInNamespace(nsx))
|
||||||
|
yield return nsz;
|
||||||
|
else if (member is INamedTypeSymbol nsu)
|
||||||
|
if (nsu.GetAttributes().Any(attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, NodeProxy)))
|
||||||
|
yield return nsu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void Execute(GeneratorExecutionContext context)
|
||||||
|
{
|
||||||
|
Compilation compilation = context.Compilation;
|
||||||
|
NodeProxy = compilation.GetTypeByMetadataName("Polonium.Attributes.ProxyNode");
|
||||||
|
foreach (INamedTypeSymbol node in ProxyNodesInNamespace(compilation.GlobalNamespace))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new();
|
||||||
|
sb
|
||||||
|
.AppendLine($"namespace Polonium.Nodes;")
|
||||||
|
.AppendLine("using Godot;")
|
||||||
|
.AppendLine($"[GlobalClass]")
|
||||||
|
.AppendLine($"[Tool]")
|
||||||
|
.AppendLine($"public partial class {node.Name} : {node.ToDisplayString()}")
|
||||||
|
.AppendLine("{")
|
||||||
|
.AppendLine("}");
|
||||||
|
context.AddSource($"NodeProxy_{node.Name}.g.cs", sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace Polonium.Generators;
|
namespace Polonium.Generators.Generators;
|
||||||
[Generator]
|
[Generator]
|
||||||
public class RegistryEntityGenerator : AssetProcessGenerator
|
public class RegistryEntityGenerator : AssetProcessGenerator
|
||||||
{
|
{
|
||||||
Reference in New Issue
Block a user