diff --git a/src/Immersion/ManagedComponentTest.cs b/src/Immersion/ManagedComponentTest.cs index cb9e6c4..8236728 100644 --- a/src/Immersion/ManagedComponentTest.cs +++ b/src/Immersion/ManagedComponentTest.cs @@ -1,4 +1,5 @@ using System; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; diff --git a/src/Immersion/ObserverTest.cs b/src/Immersion/ObserverTest.cs index 3940632..7bd4ff3 100644 --- a/src/Immersion/ObserverTest.cs +++ b/src/Immersion/ObserverTest.cs @@ -1,7 +1,7 @@ using System; -using gaemstone.ECS; +using gaemstone; +using static flecs.core; using static gaemstone.Bloxel.Components.CoreComponents; -using static gaemstone.Flecs.Core; namespace Immersion; diff --git a/src/Immersion/Program.cs b/src/Immersion/Program.cs index 92a6b5f..6b59f54 100644 --- a/src/Immersion/Program.cs +++ b/src/Immersion/Program.cs @@ -23,12 +23,12 @@ var universe = new Universe(); var world = universe.World; // TODO: Figure out a nice way to get rid of "compile errors" here. -universe.Modules.Import(); -universe.Modules.Import(); -universe.Modules.Import(); -universe.Modules.Import(); -universe.Modules.Import(); -universe.Modules.Import(); +universe.Modules.Import(); +universe.Modules.Import(); +universe.Modules.Import(); +universe.Modules.Import(); +universe.Modules.Import(); +universe.Modules.Import(); var window = Window.Create(WindowOptions.Default with { Title = "gæmstone - Immersion", diff --git a/src/gaemstone.Bloxel/Client/Systems/ChunkMeshGenerator.cs b/src/gaemstone.Bloxel/Client/Systems/ChunkMeshGenerator.cs index 5fffbcc..3ba91af 100644 --- a/src/gaemstone.Bloxel/Client/Systems/ChunkMeshGenerator.cs +++ b/src/gaemstone.Bloxel/Client/Systems/ChunkMeshGenerator.cs @@ -43,7 +43,7 @@ public partial class ChunkMeshGenerator public static void GenerateChunkMeshes( World world, Canvas canvas, Entity entity, in Chunk chunk, ChunkStoreBlocks blocks, - Has _1, Not _2) + Has _1, Not _2) { var result = Generate(world, canvas.GL, chunk.Position, blocks); if (result is MeshHandle handle) { diff --git a/src/gaemstone.Client/Systems/EntityInspector.cs b/src/gaemstone.Client/Systems/EntityInspector.cs index d9737a4..f2f62e3 100644 --- a/src/gaemstone.Client/Systems/EntityInspector.cs +++ b/src/gaemstone.Client/Systems/EntityInspector.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Numerics; using gaemstone.Client.Utility; using gaemstone.ECS; -using gaemstone.Flecs; using ImGuiNET; using static gaemstone.Client.Systems.ImGuiManager; using ImGuiInternal = ImGuiNET.Internal.ImGui; @@ -20,7 +19,7 @@ public partial class EntityInspector public struct InspectorWindow { } [Relation, Exclusive] - [Add] + [Add] public struct Selected { } [Tag] @@ -173,7 +172,7 @@ public partial class EntityInspector if (!isOpen) window.Delete(); } - [Observer] + [Observer] public static void ClearStorageOnRemove(Entity _1, InspectorWindow _2) { // TODO: Clear out settings store for the window. @@ -197,9 +196,9 @@ public partial class EntityInspector ImGui.TableSetupColumn("Entity", ImGuiTableColumnFlags.WidthFixed); ImGui.TableNextColumn(); - var hasExpanded = window.Has(); + var hasExpanded = window.Has(); if (IconButtonWithToolTip(ForkAwesome.Outdent, "Collapse all items in the Explorer View", hasExpanded)) - window.Remove(); + window.Remove(); if (history != null) { var hasPrev = ((selected != null) ? history.Current?.Prev : history.Current) != null; @@ -374,10 +373,10 @@ public partial class EntityInspector // nullable, so let's be explicit about the type here. var world = window.World; - var Wildcard = world.Entity().Value; - var Any = world.Entity().Value; - var This = world.Entity().Value; - var Variable = world.Entity().Value; + var Wildcard = world.Entity().Value; + var Any = world.Entity().Value; + var This = world.Entity().Value; + var Variable = world.Entity().Value; bool IsSpecialEntity(Entity entity) => (entity == Wildcard) || (entity == Any) || (entity == This) || (entity == Variable); @@ -396,7 +395,7 @@ public partial class EntityInspector for (var i = 0; i < iter.Count; i++) { var entity = iter.Entity(i); var count = IsSpecialEntity(entity) ? 0 - : world.Pair(entity).Count; + : world.Pair(entity).Count; result.Add(new ExplorerEntry(entity, count, isExpanded, isDisabled)); } } @@ -480,7 +479,7 @@ public partial class EntityInspector private static void ComponentsTab(Entity window, History? history, Entity? sel) { if (sel is not Entity selected) return; - var ChildOf = window.World.Entity(); + var ChildOf = window.World.Entity(); foreach (var id in selected.Type) { // Hide ChildOf relations, as they are visible in the explorer. if (id.IsPair && (id.Value.RelationUnsafe == ChildOf)) continue; @@ -492,8 +491,8 @@ public partial class EntityInspector { if (sel is not Entity selected) return; var world = window.World; - var ChildOf = world.Entity(); - var Wildcard = world.Entity(); + var ChildOf = world.Entity(); + var Wildcard = world.Entity(); if (ImGui.CollapsingHeader($"As {ForkAwesome.Tag} Component", ImGuiTreeNodeFlags.DefaultOpen)) foreach (var iter in world.Term(new(selected))) @@ -631,7 +630,7 @@ public partial class EntityInspector bool scrollTo = true) // Should entity be scrolled to in the explorer view? { if (entity is Entity e1) window.Add(e1); - else window.Remove(); + else window.Remove(); for (var p = entity?.Parent; p is Entity parent; p = parent.Parent) window.Add(parent); @@ -671,7 +670,7 @@ public partial class EntityInspector private static (Entity? DisplayType, float Priority) FindDisplayType(Entity entity) { var world = entity.World; - var component = world.Entity(); + var component = world.Entity(); var rule = (Rule)(_findDisplayTypeRule ??= world.Rule(new( $"$Type, gaemstone.Doc.DisplayType($Type)"))); @@ -682,8 +681,8 @@ public partial class EntityInspector foreach (var iter in rule.Iter().SetVar(rule.ThisVar!, entity)) for (var i = 0; i < iter.Count; i++) { var type = iter.GetVar(typeVar); - if ((type == component) && (entity.GetOrNull(component)?.Size == 0)) - type = world.Entity(); + if ((type == component) && (entity.GetOrNull(component)?.Size == 0)) + type = world.Entity(); var priority = type?.GetOrNull()?.Value ?? float.MaxValue; if (priority <= curPriority) { curType = type; curPriority = priority; } } @@ -773,7 +772,7 @@ public partial class EntityInspector if (isHeaderLike) pos.X += ImGui.GetStyle().FramePadding.X; drawList.AddText(ImGui.GetFont(), ImGui.GetFontSize(), pos, color.RGBA, displayName); if (!isHeaderLike && canClick && hovered) { - // Draw a hyperlink-link underscore. + // Draw a hyperlink-link undersflecs.core. var p1 = pos + new Vector2( 0, size.Y - 1.75f); var p2 = pos + new Vector2(size.X, size.Y - 1.75f); if (docIcon != null) p1.X += ImGui.CalcTextSize($"{docIcon} ").X; diff --git a/src/gaemstone.Client/Systems/ImGuiManager.cs b/src/gaemstone.Client/Systems/ImGuiManager.cs index 6dc1d51..3e81dca 100644 --- a/src/gaemstone.Client/Systems/ImGuiManager.cs +++ b/src/gaemstone.Client/Systems/ImGuiManager.cs @@ -5,7 +5,6 @@ using System.Text; using gaemstone.Client.Utility; using gaemstone.ECS; using gaemstone.ECS.Utility; -using gaemstone.Flecs; using ImGuiNET; using Silk.NET.Input; using Silk.NET.OpenGL.Extensions.ImGui; @@ -21,12 +20,12 @@ namespace gaemstone.Client.Systems; [DependsOn] public partial class ImGuiManager { - [Entity, Add] - [DependsOn] + [Entity, Add] + [DependsOn] public struct ImGuiUpdatePhase { } - [Entity, Add] - [DependsOn] + [Entity, Add] + [DependsOn] public struct ImGuiRenderPhase { } [Singleton] @@ -85,7 +84,7 @@ public partial class ImGuiManager } [System] - [DependsOn] + [DependsOn] public static unsafe void Initialize(World world, GameWindow window, Canvas canvas, [Source] InputContext inputContext, Not _) => world.Entity().Set(new ImGuiData( @@ -141,7 +140,7 @@ public partial class ImGuiManager }))); [System] - [DependsOn] + [DependsOn] public static void UpdateMouse(World world, [Source] MouseImpl impl, ImGuiData _) { diff --git a/src/gaemstone.Client/Systems/InputManager.cs b/src/gaemstone.Client/Systems/InputManager.cs index cc6f088..67c5ef2 100644 --- a/src/gaemstone.Client/Systems/InputManager.cs +++ b/src/gaemstone.Client/Systems/InputManager.cs @@ -2,7 +2,6 @@ using System; using System.Linq; using System.Numerics; using gaemstone.ECS; -using gaemstone.Flecs; using Silk.NET.Input; using static gaemstone.Client.Components.InputComponents; using static gaemstone.Client.Systems.Windowing; @@ -21,7 +20,7 @@ public partial class InputManager [Component] public record class GamepadImpl(IGamepad Value) { } [System] - [DependsOn] + [DependsOn] public static void Initialize(World world, GameWindow window, [Source] Not _) { @@ -42,25 +41,25 @@ public partial class InputManager } - [Observer] + [Observer] public static void OnCursorCaptured(World universe, - [Source] Has _) + [Source] Has _) => universe.Entity().GetOrThrow() .Value.Cursor.CursorMode = CursorMode.Raw; - [Observer] + [Observer] public static void OnCursorReleased(World universe, - [Source] Has _) + [Source] Has _) => universe.Entity().GetOrThrow() .Value.Cursor.CursorMode = CursorMode.Normal; [System] - [DependsOn] + [DependsOn] public static void ProcessMouse(TimeSpan delta, Entity entity, MouseImpl impl) { var mouse = impl.Value; - var isCaptured = entity.Parent?.Has() ?? false; + var isCaptured = entity.Parent?.Has() ?? false; ref var position = ref entity.NewChild("Position").Build().GetMut(); ref var posDelta = ref entity.NewChild("Delta" ).Build().GetMut(); posDelta = mouse.Position - position; @@ -76,7 +75,7 @@ public partial class InputManager } [System] - [DependsOn] + [DependsOn] public static void ProcessKeyboard(TimeSpan delta, Entity entity, KeyboardImpl impl) { var keyboard = impl.Value; @@ -87,7 +86,7 @@ public partial class InputManager } [System] - [DependsOn] + [DependsOn] public static void ProcessGamepad(TimeSpan delta, Entity entity, GamepadImpl impl) { var gamepad = impl.Value; @@ -150,12 +149,12 @@ public partial class InputManager // public static void OnActiveAdded(EntityRef entity, Active _) // => entity.Add(); - // [Observer] + // [Observer] // public static void OnActiveRemoved(Entity entity, Active _) // => entity.Add(); // [System] - // [DependsOn] + // [DependsOn] // public static void ClearDeActivated(Entity entity, Has> _) // => entity.Remove().Remove(); } diff --git a/src/gaemstone.Client/Systems/Renderer.cs b/src/gaemstone.Client/Systems/Renderer.cs index 3dbbed2..03f10d7 100644 --- a/src/gaemstone.Client/Systems/Renderer.cs +++ b/src/gaemstone.Client/Systems/Renderer.cs @@ -4,7 +4,6 @@ using System.Numerics; using System.Runtime.InteropServices; using gaemstone.ECS; using gaemstone.ECS.Utility; -using gaemstone.Flecs; using Silk.NET.OpenGL; using Silk.NET.Windowing; using static gaemstone.Client.Components.CameraComponents; @@ -26,7 +25,7 @@ public partial class Renderer private static int _modelMatrixUniform; private static object? _renderEntityRule; - [Observer] + [Observer] public static void OnCanvasSet(Canvas canvas) { var GL = canvas.GL; @@ -55,7 +54,7 @@ public partial class Renderer } [System] - [DependsOn] + [DependsOn] public static void Clear(Canvas canvas) { var GL = canvas.GL; @@ -66,7 +65,7 @@ public partial class Renderer } [System] - [DependsOn] + [DependsOn] public static void Render(World world, Canvas canvas, in GlobalTransform cameraTransform, in Camera camera, CameraViewport? viewport) { @@ -128,7 +127,7 @@ public partial class Renderer } [System] - [DependsOn] + [DependsOn] public static void SwapBuffers(GameWindow window) => window.Handle.SwapBuffers(); diff --git a/src/gaemstone.Client/Systems/TextureManager.cs b/src/gaemstone.Client/Systems/TextureManager.cs index f4fc310..fd3212c 100644 --- a/src/gaemstone.Client/Systems/TextureManager.cs +++ b/src/gaemstone.Client/Systems/TextureManager.cs @@ -1,7 +1,6 @@ using System; using System.IO; using gaemstone.ECS; -using gaemstone.Flecs; using Silk.NET.OpenGL; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; @@ -17,7 +16,7 @@ namespace gaemstone.Client.Systems; [DependsOn] public partial class TextureManager { - [Observer] + [Observer] public static void OnCanvasSet(Canvas canvas) { var GL = canvas.GL; diff --git a/src/gaemstone.Client/Systems/Windowing.cs b/src/gaemstone.Client/Systems/Windowing.cs index e3e46e8..93d12e6 100644 --- a/src/gaemstone.Client/Systems/Windowing.cs +++ b/src/gaemstone.Client/Systems/Windowing.cs @@ -1,6 +1,4 @@ using System.Drawing; -using gaemstone.ECS; -using gaemstone.Flecs; using Silk.NET.OpenGL; using Silk.NET.Windowing; @@ -29,7 +27,7 @@ public partial class Windowing } [System] - [DependsOn] + [DependsOn] public static void ProcessWindow(GameWindow window, Canvas canvas) { canvas.Size = new(window.Handle.Size.X, window.Handle.Size.Y); diff --git a/src/gaemstone.SourceGen/ModuleGenerator.cs b/src/gaemstone.SourceGen/ModuleGenerator.cs index d8809c1..7991638 100644 --- a/src/gaemstone.SourceGen/ModuleGenerator.cs +++ b/src/gaemstone.SourceGen/ModuleGenerator.cs @@ -81,8 +81,10 @@ public class ModuleGenerator private void AppendHeader(StringBuilder sb, string @namespace) => sb.AppendLine($$""" // + #pragma warning disable using System.Collections.Generic; using System.Collections.Immutable; + using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; @@ -188,8 +190,8 @@ public class ModuleGenerator sb.AppendLine($"\t\t\t.Symbol({e.EntitySymbol.ToStringLiteral()})"); // Tags and relations in Flecs are marked as empty components. - if (e.IsTag || e.IsRelation) sb.AppendLine("\t\t\t.Add()"); - if (e.IsTag && e.IsRelation) sb.AppendLine("\t\t\t.Add()"); + if (e.IsTag || e.IsRelation) sb.AppendLine("\t\t\t.Add()"); + if (e.IsTag && e.IsRelation) sb.AppendLine("\t\t\t.Add()"); sb.Append( "\t\t\t"); if (!e.IsBuiltIn) sb.Append(".Build()"); @@ -322,7 +324,7 @@ public class ModuleGenerator // If system doesn't have an explicit phase set, default to OnUpdate. if (e is MethodEntityInfo { IsSystem: true, HasPhaseSet: false }) - sb.AppendLine($"\t\t{@var}.Add();"); + sb.AppendLine($"\t\t{@var}.Add();"); } } diff --git a/src/gaemstone.SourceGen/RelevantSymbolReceiver.cs b/src/gaemstone.SourceGen/RelevantSymbolReceiver.cs index cc8ce79..9e8ff07 100644 --- a/src/gaemstone.SourceGen/RelevantSymbolReceiver.cs +++ b/src/gaemstone.SourceGen/RelevantSymbolReceiver.cs @@ -12,7 +12,7 @@ namespace gaemstone.SourceGen; public class RelevantSymbolReceiver : ISyntaxContextReceiver { - // Attributes from gaemstone.ECS and gaemstone.Doc are considered. + // Attributes from gaemstone and gaemstone.Doc are considered. private static readonly HashSet RelevantAttributeNames = new(){ // Base entity attributes "Module", // Can also be [Singleton] @@ -68,7 +68,7 @@ public class RelevantSymbolReceiver Symbols.Add(symbol, symbol switch { INamedTypeSymbol typeSymbol => typeSymbol.GetAttributes().Any(attr => attr.AttributeClass! - .GetFullName() == "gaemstone.ECS.ModuleAttribute") + .GetFullName() == "gaemstone.ModuleAttribute") ? new ModuleEntityInfo(typeSymbol) : new TypeEntityInfo(typeSymbol), IMethodSymbol methodSymbol => new MethodEntityInfo(methodSymbol), @@ -88,7 +88,7 @@ public class RelevantSymbolReceiver var sep = name.LastIndexOf('.'); if (sep < 0) return null; - if (name.AsSpan()[..sep] is not ("gaemstone.ECS" or "gaemstone.Doc")) return null; + if (name.AsSpan()[..sep] is not ("gaemstone" or "gaemstone.Doc")) return null; return name[(sep+1)..^"Attribute".Length]; } diff --git a/src/gaemstone.SourceGen/Structure/MethodEntityInfo.cs b/src/gaemstone.SourceGen/Structure/MethodEntityInfo.cs index b59400c..2329ec8 100644 --- a/src/gaemstone.SourceGen/Structure/MethodEntityInfo.cs +++ b/src/gaemstone.SourceGen/Structure/MethodEntityInfo.cs @@ -88,9 +88,9 @@ public class MethodEntityInfo : BaseEntityInfo param.TermIndex = termIndex++; // See if we have any [DependsOn<...>] attributes for this system. - // If not, ModuleGenerator will add [DependsOn]. + // If not, ModuleGenerator will add [DependsOn]. HasPhaseSet = IsSystem && RelationsToAdd.Any(entry => entry.Relation - .GetFullName(FullNameStyle.NoGeneric) == "gaemstone.ECS.DependsOnAttribute"); + .GetFullName(FullNameStyle.NoGeneric) == "gaemstone.DependsOnAttribute"); // TODO: Handle systems with [Source]. // TODO: Validate ObserverEvents. diff --git a/src/gaemstone.SourceGen/Structure/ModuleEntityInfo.cs b/src/gaemstone.SourceGen/Structure/ModuleEntityInfo.cs index 025444f..b25013b 100644 --- a/src/gaemstone.SourceGen/Structure/ModuleEntityInfo.cs +++ b/src/gaemstone.SourceGen/Structure/ModuleEntityInfo.cs @@ -19,7 +19,7 @@ public class ModuleEntityInfo : TypeEntityInfo IsPartial = classDecl.Modifiers.Any(t => t.IsKind(SyntaxKind.PartialKeyword)); HasLifetimeInterface = Symbol.AllInterfaces.Any(i => - i.GetFullName(FullNameStyle.NoGeneric) == "gaemstone.ECS.IModuleLifetime"); + i.GetFullName(FullNameStyle.NoGeneric) == "gaemstone.IModuleLifetime"); IsBuiltIn = Has("BuiltIn"); } @@ -38,7 +38,7 @@ public class ModuleEntityInfo : TypeEntityInfo public IEnumerable GetDependencies() { foreach (var (relation, target) in RelationsToAdd) - if (relation.GetFullName(FullNameStyle.NoGeneric) == "gaemstone.Flecs.Core.DependsOn") + if (relation.GetFullName(FullNameStyle.NoGeneric) == "flecs.core.DependsOn") yield return GetModulePath(target); } diff --git a/src/gaemstone.SourceGen/Structure/ParameterInfo.cs b/src/gaemstone.SourceGen/Structure/ParameterInfo.cs index eeeabdb..c32312d 100644 --- a/src/gaemstone.SourceGen/Structure/ParameterInfo.cs +++ b/src/gaemstone.SourceGen/Structure/ParameterInfo.cs @@ -54,9 +54,9 @@ public class ParameterInfo : BaseInfo } else { - IsOr = typeFullName.StartsWith("gaemstone.ECS.Or"); - var isHas = typeFullName.StartsWith("gaemstone.ECS.Has"); - var isNot = typeFullName.StartsWith("gaemstone.ECS.Not"); + IsOr = typeFullName.StartsWith("gaemstone.Or"); + var isHas = typeFullName.StartsWith("gaemstone.Has"); + var isNot = typeFullName.StartsWith("gaemstone.Not"); if (IsGeneric) { @@ -66,7 +66,7 @@ public class ParameterInfo : BaseInfo // Has<...> usually doesn't support a generic type as its own type parameter. // However, Has> is an exception to this rule, so we check for this here. if (isHas && (args is [ INamedTypeSymbol { IsGenericType: true } argType ]) - && argType.GetFullName(FullNameStyle.NoGeneric) == "gaemstone.ECS.Or") + && argType.GetFullName(FullNameStyle.NoGeneric) == "gaemstone.Or") { TermTypes = argType.TypeArguments.ToImmutableList(); FieldType = null; @@ -91,13 +91,13 @@ public class ParameterInfo : BaseInfo // If the type of the parameter has the [Tag] attribute, // the only way to sensibly use it is to check for its (non-)existance. // (This would also apply to [Relation, Tag] but should be no issue.) - if (Symbol.Type.HasAttribute("gaemstone.ECS.TagAttribute")) isHas = true; + if (Symbol.Type.HasAttribute("gaemstone.TagAttribute")) isHas = true; // TODO: Make sure [Tag] is used appropriately. } Source = Get("Source")?.AttributeClass!.TypeArguments[0] // If the type of the parameter has the [Singleton] attribute, use it as the default Source. - ?? ((FieldType?.HasAttribute("gaemstone.ECS.SingletonAttribute") == true) ? FieldType : null); + ?? ((FieldType?.HasAttribute("gaemstone.SingletonAttribute") == true) ? FieldType : null); Kind = isHas ? ParameterKind.Has : isNot ? ParameterKind.Not diff --git a/src/gaemstone/Doc+Extensions.cs b/src/gaemstone/Doc+Extensions.cs index c1db2af..7962056 100644 --- a/src/gaemstone/Doc+Extensions.cs +++ b/src/gaemstone/Doc+Extensions.cs @@ -1,6 +1,5 @@ using gaemstone.ECS; using gaemstone.ECS.Utility; -using gaemstone.Flecs; using static flecs_hub.flecs; namespace gaemstone; @@ -9,11 +8,11 @@ public static unsafe class DocExtensions { private static Entity Set(Entity entity, string? value) { - var id = entity.World.Pair(); + var id = entity.World.Pair(); if (value != null) { var str = GlobalHeapAllocator.Instance.AllocateCString(value); - var desc = new Flecs.Doc.Description { Value = (void*)(nint)str }; + var desc = new flecs.doc.Description { Value = (void*)(nint)str }; entity.Set(id, desc); } else { entity.Remove(id); @@ -23,28 +22,28 @@ public static unsafe class DocExtensions } public static string? GetDocName(this Entity entity, bool fallbackToEntityName = true) - => fallbackToEntityName || entity.Has() + => fallbackToEntityName || entity.Has() ? ecs_doc_get_name(entity.World, entity).FlecsToString() : null; public static Entity SetDocName(this Entity entity, string? value) - => Set(entity, value); + => Set(entity, value); public static string? GetDocBrief(this Entity entity) => ecs_doc_get_brief(entity.World, entity).FlecsToString()!; public static Entity SetDocBrief(this Entity entity, string? value) - => Set(entity, value); + => Set(entity, value); public static string? GetDocDetail(this Entity entity) => ecs_doc_get_detail(entity.World, entity).FlecsToString()!; public static Entity SetDocDetail(this Entity entity, string? value) - => Set(entity, value); + => Set(entity, value); public static string? GetDocLink(this Entity entity) => ecs_doc_get_link(entity.World, entity).FlecsToString()!; public static Entity SetDocLink(this Entity entity, string? value) - => Set(entity, value); + => Set(entity, value); public static string? GetDocColor(this Entity entity) => ecs_doc_get_color(entity.World, entity).FlecsToString()!; public static Entity SetDocColor(this Entity entity, string? value) - => Set(entity, value); + => Set(entity, value); } diff --git a/src/gaemstone/Doc.cs b/src/gaemstone/Doc.cs index f919906..8193adb 100644 --- a/src/gaemstone/Doc.cs +++ b/src/gaemstone/Doc.cs @@ -1,6 +1,3 @@ -using gaemstone.ECS; -using static gaemstone.Flecs.Core; - namespace gaemstone; [Module] diff --git a/src/gaemstone/Flecs/Core.cs b/src/gaemstone/Flecs/Core.cs index aeca2ba..3654db4 100644 --- a/src/gaemstone/Flecs/Core.cs +++ b/src/gaemstone/Flecs/Core.cs @@ -1,21 +1,19 @@ +using gaemstone; using gaemstone.ECS; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/core")] -public partial class Core +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public partial class core : IModuleImport { // Entity Tags - // TODO: - // [Tag] public struct Observer { } - - // // Technically, this type should be in the Flecs.System addon, - // // but unfortunately due to language limitations, it has to reside here. - // [Tag, Path("/flecs/system/System")] - // public struct System { } + [Tag] public struct Observer { } + // TODO: Put back World? [Tag] public struct Module { } [Tag] public struct Private { } [Tag] public struct Prefab { } diff --git a/src/gaemstone/Flecs/CoreDoc.cs b/src/gaemstone/Flecs/CoreDoc.cs index a541154..d235a12 100644 --- a/src/gaemstone/Flecs/CoreDoc.cs +++ b/src/gaemstone/Flecs/CoreDoc.cs @@ -1,14 +1,17 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/coredoc")] -[DependsOn] -[DependsOn] -public unsafe partial class CoreDoc +[DependsOn] +[DependsOn] +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class coredoc : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/Flecs/Doc.cs b/src/gaemstone/Flecs/Doc.cs index b12deae..b309667 100644 --- a/src/gaemstone/Flecs/Doc.cs +++ b/src/gaemstone/Flecs/Doc.cs @@ -1,12 +1,15 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/doc")] -public unsafe partial class Doc +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class doc : IModuleImport { [Tag] public struct Brief { } diff --git a/src/gaemstone/Flecs/Meta.cs b/src/gaemstone/Flecs/Meta.cs index 8bd700f..a33c927 100644 --- a/src/gaemstone/Flecs/Meta.cs +++ b/src/gaemstone/Flecs/Meta.cs @@ -1,12 +1,15 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/meta")] -public unsafe partial class Meta +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class meta : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/Flecs/Metrics.cs b/src/gaemstone/Flecs/Metrics.cs index 021e351..6877c3f 100644 --- a/src/gaemstone/Flecs/Metrics.cs +++ b/src/gaemstone/Flecs/Metrics.cs @@ -1,15 +1,18 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/timer")] -[DependsOn] -[DependsOn] -[DependsOn] -public unsafe partial class Metrics +[DependsOn] +[DependsOn] +[DependsOn] +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class metrics : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/Flecs/Monitor.cs b/src/gaemstone/Flecs/Monitor.cs index ddd9778..91ea331 100644 --- a/src/gaemstone/Flecs/Monitor.cs +++ b/src/gaemstone/Flecs/Monitor.cs @@ -1,12 +1,15 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/monitor")] -public unsafe partial class Monitor +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class monitor : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/Flecs/Pipeline.cs b/src/gaemstone/Flecs/Pipeline.cs index a7bbe07..bdb2e20 100644 --- a/src/gaemstone/Flecs/Pipeline.cs +++ b/src/gaemstone/Flecs/Pipeline.cs @@ -1,13 +1,16 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/pipeline")] -[DependsOn] -public unsafe partial class Pipeline +[DependsOn] +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class pipeline : IModuleImport { [Entity] public struct Phase { } diff --git a/src/gaemstone/Flecs/Rest.cs b/src/gaemstone/Flecs/Rest.cs index 49bd764..63d5316 100644 --- a/src/gaemstone/Flecs/Rest.cs +++ b/src/gaemstone/Flecs/Rest.cs @@ -1,13 +1,16 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/rest")] -[DependsOn] -public unsafe partial class Rest +[DependsOn] +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class rest : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/Flecs/Script.cs b/src/gaemstone/Flecs/Script.cs index a028131..e17ae3b 100644 --- a/src/gaemstone/Flecs/Script.cs +++ b/src/gaemstone/Flecs/Script.cs @@ -1,13 +1,16 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/script")] -[DependsOn] -public unsafe partial class Script +[DependsOn] +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class script : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/Flecs/System.cs b/src/gaemstone/Flecs/System.cs index c3fd6b7..3547a96 100644 --- a/src/gaemstone/Flecs/System.cs +++ b/src/gaemstone/Flecs/System.cs @@ -1,14 +1,20 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/system")] -public unsafe partial class System +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class system : IModuleImport { + [Tag] + public struct System { } + static Entity IModuleImport.Import(World world) { using var alloc = TempAllocator.Use(); diff --git a/src/gaemstone/Flecs/Timer.cs b/src/gaemstone/Flecs/Timer.cs index 84edfdf..681a597 100644 --- a/src/gaemstone/Flecs/Timer.cs +++ b/src/gaemstone/Flecs/Timer.cs @@ -1,13 +1,16 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/timer")] -[DependsOn] -public unsafe partial class Timer +[DependsOn] +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class timer : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/Flecs/Units.cs b/src/gaemstone/Flecs/Units.cs index e47123c..aff6c87 100644 --- a/src/gaemstone/Flecs/Units.cs +++ b/src/gaemstone/Flecs/Units.cs @@ -1,12 +1,15 @@ using System.Runtime.InteropServices; +using gaemstone; using gaemstone.ECS; using gaemstone.ECS.Utility; using static flecs_hub.flecs; -namespace gaemstone.Flecs; +namespace flecs; [BuiltIn, Module, Path("/flecs/units")] -public unsafe partial class Units +#pragma warning disable IDE1006 // Naming rule violation +#pragma warning disable CS8981 // Only contains lower-cased ascii characters +public unsafe partial class units : IModuleImport { static Entity IModuleImport.Import(World world) diff --git a/src/gaemstone/ECS/Module+Attributes.cs b/src/gaemstone/Module+Attributes.cs similarity index 84% rename from src/gaemstone/ECS/Module+Attributes.cs rename to src/gaemstone/Module+Attributes.cs index 5c38ca5..c7fbe74 100644 --- a/src/gaemstone/ECS/Module+Attributes.cs +++ b/src/gaemstone/Module+Attributes.cs @@ -1,7 +1,6 @@ using System; -using static gaemstone.Flecs.Core; -namespace gaemstone.ECS; +namespace gaemstone; /// /// Entities marked with this attribute are automatically registered with a @@ -57,13 +56,22 @@ public class SetAttribute : Attribute /// -public class IsAAttribute : AddAttribute { } +public class IsAAttribute + : AddAttribute { } + /// -public class ChildOfAttribute : AddAttribute { } +public class ChildOfAttribute + : AddAttribute { } + /// -public class DependsOnAttribute : AddAttribute { } +public class DependsOnAttribute + : AddAttribute { } + /// -public class ExclusiveAttribute : AddAttribute { } +public class ExclusiveAttribute + : AddAttribute { } + /// -public class WithAttribute : AddAttribute { } +public class WithAttribute + : AddAttribute { } diff --git a/src/gaemstone/ECS/Module+Components.cs b/src/gaemstone/Module+Components.cs similarity index 98% rename from src/gaemstone/ECS/Module+Components.cs rename to src/gaemstone/Module+Components.cs index ab9c46c..4153825 100644 --- a/src/gaemstone/ECS/Module+Components.cs +++ b/src/gaemstone/Module+Components.cs @@ -1,6 +1,6 @@ using System; -namespace gaemstone.ECS; +namespace gaemstone; /// Use a custom name or path for this entity instead of the type's name. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct diff --git a/src/gaemstone/ECS/Module.cs b/src/gaemstone/Module.cs similarity index 96% rename from src/gaemstone/ECS/Module.cs rename to src/gaemstone/Module.cs index 827f7fc..4272005 100644 --- a/src/gaemstone/ECS/Module.cs +++ b/src/gaemstone/Module.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; +using gaemstone.ECS; -namespace gaemstone.ECS; +namespace gaemstone; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] public class ModuleAttribute : SingletonAttribute { } diff --git a/src/gaemstone/ECS/System+Terms.cs b/src/gaemstone/System+Terms.cs similarity index 99% rename from src/gaemstone/ECS/System+Terms.cs rename to src/gaemstone/System+Terms.cs index 46d4b43..37496a6 100644 --- a/src/gaemstone/ECS/System+Terms.cs +++ b/src/gaemstone/System+Terms.cs @@ -1,7 +1,7 @@ using System; using gaemstone.Utility; -namespace gaemstone.ECS; +namespace gaemstone; [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] public class SourceAttribute : Attribute { } diff --git a/src/gaemstone/ECS/System.cs b/src/gaemstone/System.cs similarity index 96% rename from src/gaemstone/ECS/System.cs rename to src/gaemstone/System.cs index 5665f95..9c89c84 100644 --- a/src/gaemstone/ECS/System.cs +++ b/src/gaemstone/System.cs @@ -1,6 +1,6 @@ using System; -namespace gaemstone.ECS; +namespace gaemstone; [AttributeUsage(AttributeTargets.Method)] public class SystemAttribute : Attribute { } diff --git a/src/gaemstone/Universe+Modules.cs b/src/gaemstone/Universe+Modules.cs index 80db2cf..4357a8d 100644 --- a/src/gaemstone/Universe+Modules.cs +++ b/src/gaemstone/Universe+Modules.cs @@ -1,7 +1,5 @@ using System; using gaemstone.ECS; -using static gaemstone.Flecs.Core; -using Module = gaemstone.Flecs.Core.Module; namespace gaemstone; @@ -54,20 +52,24 @@ public class ModuleManager $"Unexpected operation, {T.Path} is a built-in module"); var builder = World.New(T.Path) - .Add().Add() + .Add() + .Add() .Set(new ModuleInfo()); foreach (var depPath in T.Dependencies) { - var dependency = World.LookupPathOrNull(depPath) ?? - World.New(depPath).Add().Add().Build(); - builder.Add(dependency); + var dependency = World.LookupPathOrNull(depPath) + ?? World.New(depPath) + .Add() + .Add() + .Build(); + builder.Add(dependency); } var module = builder.Build().CreateLookup(); // Ensure all parent entities have the Module tag set. for (var p = module.Parent; p is Entity parent; p = parent.Parent) - parent.Add(); + parent.Add(); Console.WriteLine($"Registered module {module.Path}"); diff --git a/src/gaemstone/Universe.cs b/src/gaemstone/Universe.cs index 17bf103..1fae210 100644 --- a/src/gaemstone/Universe.cs +++ b/src/gaemstone/Universe.cs @@ -17,14 +17,14 @@ public class Universe .CreateLookup(); // Bootstrap core module from Flecs. - Modules.Import(); + Modules.Import(); // Import addon modules from Flecs we use for the engine. - Modules.Import(); - Modules.Import(); - Modules.Import(); - Modules.Import(); - Modules.Import(); + Modules.Import(); + Modules.Import(); + Modules.Import(); + Modules.Import(); + Modules.Import(); Modules.Register(); }