public void SetOrAddComponent <TComponent>(Entity entity, TComponent component) where TComponent : struct { Debug.Assert(IsValid(entity)); ComponentSet <TComponent> componentSet = GetComponentSet <TComponent>(); componentSet.AddOrReplace(component, entity.Index); }
public EntitySliceConfiguration Exclude <TComponent>() where TComponent : struct { ComponentSet <TComponent> componentSet = mRegistry.GetComponentSet <TComponent>(); mExclusions.Add(componentSet); return(this); }
public EntitySliceConfiguration Require <TComponent>() where TComponent : struct { ComponentSet <TComponent> componentSet = mRegistry.GetComponentSet <TComponent>(); mLooseRequirements.Add(componentSet); return(this); }
public TComponent GetComponent <TComponent>(Entity entity) where TComponent : struct { Debug.Assert(IsValid(entity)); ComponentSet <TComponent> componentSet = GetComponentSet <TComponent>(); return(componentSet.GetValue(entity.Index)); }
private void ValidateOrRegisterComponentType <TComponent>() where TComponent : struct { Type componentType = typeof(TComponent); if (!mComponentSetLookup.ContainsKey(componentType)) { ComponentSet <TComponent> componentSet = new ComponentSet <TComponent>(mEntities.Length); ushort lookup = (ushort)mComponentSets.Count; mComponentSets.Add(componentSet); mComponentSetLookup.Add(componentType, lookup); } }
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); }