Exemplo n.º 1
0
            public EntitySliceConfiguration GetEntities(SliceEntityOutput output)
            {
                RestrictedArray <Entity> writeArray = new RestrictedArray <Entity>(mRegistry.Capacity);
                ValueInjector <Entity>   injector   = new ValueInjector <Entity>(mRegistry, writeArray);

                mLooseInjectors.Add(injector);

                //InjectExistingValue is impossible to use in this context. An entity would never be replaced, without being destroyed and then created

                //Set the write array to be accessed by the component output passed
                Type      outputType = typeof(SliceEntityOutput);
                FieldInfo arrayField = outputType.GetField("mArray", BindingFlags.NonPublic | BindingFlags.Instance);

                arrayField.SetValue(output, writeArray);

                return(this);
            }
Exemplo n.º 2
0
            public EntitySliceConfiguration Require <TComponent>(SliceRequirementOutput <TComponent> targetOutput) where TComponent : struct
            {
                Debug.Assert(targetOutput != null, "Target output cannot be null before calling this method!");

                ComponentSet <TComponent>    componentSet = mRegistry.GetComponentSet <TComponent>();
                RestrictedArray <TComponent> writeArray   = new RestrictedArray <TComponent>(mRegistry.Capacity);
                ValueInjector <TComponent>   injector     = new ValueInjector <TComponent>(componentSet, writeArray);

                componentSet.ValueModified += injector.InjectExistingValue;

                Tuple <IPublishingIndexSet, ValueInjectorBase> matchPair = new Tuple <IPublishingIndexSet, ValueInjectorBase>(componentSet, injector);

                mMatchedInjectorRequirements.Add(matchPair);

                //Set the write array to be accessed by the component output passed
                Type      outputType = typeof(SliceRequirementOutput <TComponent>);
                FieldInfo arrayField = outputType.GetField("mArray", BindingFlags.NonPublic | BindingFlags.Instance);

                arrayField.SetValue(targetOutput, writeArray);

                return(this);
            }
Exemplo n.º 3
0
 public ValueInjector(IReadonlyIndexedSet <TValue> source, RestrictedArray <TValue> target)
 {
     mSourceSet    = source;
     mTargetOutput = target;
 }