From cfc1ffe9a6f48997a55a7a9f69510179e26531de Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 14 Jul 2025 20:55:09 +0800 Subject: [PATCH] impl EcsPipeline.Builder.MergeWith --- src/EcsPipeline.Builder.cs | 108 ++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 55 deletions(-) diff --git a/src/EcsPipeline.Builder.cs b/src/EcsPipeline.Builder.cs index 3d3b04c..34e1efe 100644 --- a/src/EcsPipeline.Builder.cs +++ b/src/EcsPipeline.Builder.cs @@ -44,45 +44,6 @@ namespace DCFApixels.DragonECS private HashSet _uniqueSystemsSet = new HashSet(); - - #region InitInjector - public readonly struct InitInjectionList - { - private readonly Builder _pipelineBuilder; - public readonly Injector.InjectionList Instance; - public InitInjectionList(Injector.InjectionList instance, Builder pipelineBuilder) - { - Instance = instance; - _pipelineBuilder = pipelineBuilder; - } - public Builder AddNode() - { - Instance.AddNode(); - return _pipelineBuilder; - } - public Builder Inject(T obj) - { - Instance.Inject(obj); - return _pipelineBuilder; - } - public Builder Extract(ref T obj) - { - Instance.Extract(ref obj); - return _pipelineBuilder; - } - public Builder Merge(Injector.InjectionList other) - { - Instance.MergeWith(other); - return _pipelineBuilder; - } - public Builder Merge(InitInjectionList other) - { - Instance.MergeWith(other.Instance); - return _pipelineBuilder; - } - } - #endregion - #region Properties //private ReadOnlySpan SystemRecords //{ @@ -274,22 +235,21 @@ namespace DCFApixels.DragonECS } private void MergeWith(Builder other) { - throw new NotImplementedException(); - //Injector.Add(other.Injector); - //foreach (var declaredRunners in other._initDeclaredRunners) - //{ - // _initDeclaredRunners.Add(declaredRunners); - //} - //foreach (var config in other.Configs.Instance.GetAllConfigs()) - //{ - // Configs.Instance.Set(config.Key, config.Value); - //} - //Layers.MergeWith(other.Layers); - // - //foreach (ref readonly SystemNode otherRecord in new LinkedListCountIterator(_systemNodes, _systemNodesCount, _startIndex)) - //{ - // AddNode_Internal(otherRecord.system, otherRecord.layerName, otherRecord.sortOrder, otherRecord.isUnique); - //} + Injections.MergeWith(other.Injections); + foreach (var declaredRunners in other._initDeclaredRunners) + { + _initDeclaredRunners.Add(declaredRunners); + } + foreach (var config in other.Configs.Instance.GetAllConfigs()) + { + Configs.Instance.Set(config.Key, config.Value); + } + Layers.MergeWith(other.Layers); + + foreach (ref readonly SystemNode otherRecord in new LinkedListCountIterator(_systemNodes, _systemNodesCount, _startIndex)) + { + AddNode_Internal(otherRecord.system, otherRecord.layerName, otherRecord.sortOrder, otherRecord.isUnique); + } } #endregion @@ -434,6 +394,44 @@ namespace DCFApixels.DragonECS } #endregion + #region InitInjector + public readonly struct InitInjectionList + { + private readonly Builder _pipelineBuilder; + public readonly Injector.InjectionList Instance; + public InitInjectionList(Injector.InjectionList instance, Builder pipelineBuilder) + { + Instance = instance; + _pipelineBuilder = pipelineBuilder; + } + public Builder AddNode() + { + Instance.AddNode(); + return _pipelineBuilder; + } + public Builder Inject(T obj) + { + Instance.Inject(obj); + return _pipelineBuilder; + } + public Builder Extract(ref T obj) + { + Instance.Extract(ref obj); + return _pipelineBuilder; + } + public Builder Merge(Injector.InjectionList other) + { + Instance.MergeWith(other); + return _pipelineBuilder; + } + public Builder MergeWith(InitInjectionList other) + { + Instance.MergeWith(other.Instance); + return _pipelineBuilder; + } + } + #endregion + #region Configurator public readonly struct Configurator {