From ac8d8cea5388c90d807adeb95b50b55e936e4c77 Mon Sep 17 00:00:00 2001 From: copygirl Date: Fri, 16 Dec 2022 17:42:45 +0100 Subject: [PATCH] Non-public entities won't have symbols set --- src/gaemstone.Client/Components/InputComponents.cs | 8 ++++---- src/gaemstone/ECS/Attributes.cs | 8 -------- src/gaemstone/ECS/Universe+Modules.cs | 5 +++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/gaemstone.Client/Components/InputComponents.cs b/src/gaemstone.Client/Components/InputComponents.cs index cc24c09..72261a5 100644 --- a/src/gaemstone.Client/Components/InputComponents.cs +++ b/src/gaemstone.Client/Components/InputComponents.cs @@ -68,8 +68,8 @@ public class InputComponents public struct CursorCapturedBy { } - [Private, Component] - public readonly struct RawValue1D + [Component] + internal readonly struct RawValue1D { private readonly float _value; private RawValue1D(float value) => _value = value; @@ -78,8 +78,8 @@ public class InputComponents public static implicit operator RawValue1D(float value) => new(value); } - [Private, Component] - public readonly struct RawValue2D + [Component] + internal readonly struct RawValue2D { private readonly Vector2 _value; private RawValue2D(Vector2 value) => _value = value; diff --git a/src/gaemstone/ECS/Attributes.cs b/src/gaemstone/ECS/Attributes.cs index c043ece..0a80b16 100644 --- a/src/gaemstone/ECS/Attributes.cs +++ b/src/gaemstone/ECS/Attributes.cs @@ -11,14 +11,6 @@ namespace gaemstone.ECS; /// public interface ICreateEntityAttribute { } -/// -/// By default, entities registered automatically have their symbol -/// (a globally unique identifier) set equal to their name. If they -/// are also marked with this attribute, the symbol won't be set. -/// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum)] -public class PrivateAttribute : Attribute { } - /// /// A singleton is a single instance of a tag or component that can be retrieved /// without explicitly specifying an entity in a query, where it is equivalent diff --git a/src/gaemstone/ECS/Universe+Modules.cs b/src/gaemstone/ECS/Universe+Modules.cs index 38b81a1..521c9b0 100644 --- a/src/gaemstone/ECS/Universe+Modules.cs +++ b/src/gaemstone/ECS/Universe+Modules.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using gaemstone.Utility; using static gaemstone.Flecs.Core; +using BindingFlags = System.Reflection.BindingFlags; namespace gaemstone.ECS; @@ -174,7 +175,7 @@ internal class ModuleInfo private void RegisterNestedTypes() { - foreach (var type in Type.GetNestedTypes()) { + foreach (var type in Type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)) { if (!type.GetCustomAttributes(true).OfType().Any()) continue; // If proxied type is specified, use it instead of the marked type. @@ -191,7 +192,7 @@ internal class ModuleInfo : new EntityPath(false, proxyType.Name); var builder = path.IsAbsolute ? Universe.New(path) : Entity.NewChild(path); - if (!type.Has()) builder.Symbol(path.Name); + if (!type.IsPublic) builder.Symbol(path.Name); var entity = builder.Build();