private void RegisterNodesDeclaredInSystem(Type systemClass) { foreach (Type type in systemClass.GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Public)) { if (type.IsSubclassOf(typeof(Node)) && !type.IsGenericTypeDefinition) { NodeDescriptionRegistry.AddNodeDescription(new StandardNodeDescription(type, null)); } } }
private void CollectHandlersAndNodes(ECSSystem systemInstance) { foreach (Handler handler in this.engineService.HandlerCollector.CollectHandlers(systemInstance)) { IList <HandlerArgument> handlerArguments = handler.HandlerArgumentsDescription.HandlerArguments; foreach (HandlerArgument argument in handlerArguments) { NodeDescriptionRegistry.AddNodeDescription(argument.NodeDescription); } } }
private IList <N> DoSelect <N>(Entity entity, Type groupComponentType) where N : Node { ICollection <Entity> is2; GroupComponent componentUnsafe = (GroupComponent)((EntityUnsafe)entity).GetComponentUnsafe(groupComponentType); if (componentUnsafe == null) { return(Collections.EmptyList <N>()); } NodeClassInstanceDescription orCreateNodeClassDescription = NodeDescriptionRegistry.GetOrCreateNodeClassDescription(typeof(N), null); NodeDescriptionRegistry.AssertRegister(orCreateNodeClassDescription.NodeDescription); return(((is2 = componentUnsafe.GetGroupMembers(orCreateNodeClassDescription.NodeDescription)).Count != 0) ? ((is2.Count != 1) ? ((IList <N>) this.ConvertNodeCollection(orCreateNodeClassDescription, is2)) : Collections.SingletonList <N>((N)this.GetNode(Collections.GetOnlyElement <Entity>(is2), orCreateNodeClassDescription))) : Collections.EmptyList <N>()); }
private void UpdateComponentValue(Component component, Type componentType) { IEnumerator <NodeClassInstanceDescription> enumerator = NodeDescriptionRegistry.GetClassInstanceDescriptionByComponent(componentType).GetEnumerator(); while (enumerator.MoveNext()) { Node node; NodeClassInstanceDescription current = enumerator.Current; if (this.nodeByDescription.TryGetValue(current, out node)) { current.SetComponent(node, componentType, component); } } }
public EntityImpl(EngineServiceInternal engineService, long id, string name, Optional <Platform.Kernel.ECS.ClientEntitySystem.Impl.TemplateAccessor> templateAccessor) { this.engineService = engineService; this.id = id; this.Name = name; this.nodeCache = engineService.NodeCache; this.TemplateAccessor = templateAccessor; this.storage = new EntityComponentStorage(this, engineService.ComponentBitIdRegistry); this.nodeProvider = new NodeProvider(this); this.nodeDescriptionStorage = new Platform.Kernel.ECS.ClientEntitySystem.Impl.NodeDescriptionStorage(); this.hashCode = this.calcHashCode(); this.nodeAddedEventMaker = new NodeChangedEventMaker(NodeAddedEvent.Instance, typeof(NodeAddedFireHandler), typeof(NodeAddedCompleteHandler), engineService.HandlerCollector); this.nodeRemoveEventMaker = new NodeChangedEventMaker(NodeRemoveEvent.Instance, typeof(NodeRemovedFireHandler), typeof(NodeRemovedCompleteHandler), engineService.HandlerCollector); this.Init(); this.UpdateNodes(NodeDescriptionRegistry.GetNodeDescriptionsWithNotComponentsOnly()); }
public void AddState <T>() where T : Node, new() { Type key = typeof(T); if (this.entityStates.ContainsKey(key)) { throw new EntityStateAlreadyRegisteredException(key); } EntityState state = new EntityState(key, NodeDescriptionRegistry.GetOrCreateNodeClassDescription(key, null).NodeDescription); if (this.entity != null) { state.Entity = this.entity; } this.entityStates[key] = state; }
private static HandlerArgument CreateNodeType(int position, Type type, Optional <JoinType> join, Optional <JoinType> rightJoin, object[] annotatedTypes, bool isNodeChangeHandler) { Type nodeType = GetNodeType(type); if (nodeType == null) { return(null); } HashSet <Type> components = new HashSet <Type>(); bool context = IsContextNode(annotatedTypes, join); if (isNodeChangeHandler && context) { CollectGroupComponent(join, components); CollectGroupComponent(rightJoin, components); } NodeClassInstanceDescription orCreateNodeClassDescription = NodeDescriptionRegistry.GetOrCreateNodeClassDescription(nodeType, components); return(new HandlerArgumentBuilder().SetPosition(position).SetType(type).SetJoinType(join).SetContext(context).SetCollection(IsCollection(type)).SetNodeClassInstanceDescription(orCreateNodeClassDescription).SetMandatory(IsMandatory(annotatedTypes)).SetCombine(IsCombine(annotatedTypes)).SetOptional(IsOptional(type)).Build()); }
private bool CheckNodeIsActual(Node node) { NodeClassInstanceDescription orCreateNodeClassDescription = NodeDescriptionRegistry.GetOrCreateNodeClassDescription(node.GetType(), null); return(((EntityImpl)node.Entity).NodeDescriptionStorage.Contains(orCreateNodeClassDescription.NodeDescription)); }
protected ICollection <NodeDescription> GetRemovedNodes(EntityInternal entity, Type componentClass) { BitSet componentsBitId = entity.ComponentsBitId; List <NodeDescription> instance = flowInstances.listNodeDescription.GetInstance(); Collections.Enumerator <NodeDescription> enumerator = Collections.GetEnumerator <NodeDescription>(NodeDescriptionRegistry.GetNodeDescriptionsByNotComponent(componentClass)); while (enumerator.MoveNext()) { NodeDescription current = enumerator.Current; if (componentsBitId.Mask(current.NodeComponentBitId) && (!componentsBitId.MaskNot(current.NotNodeComponentBitId) && entity.NodeDescriptionStorage.Contains(current))) { instance.Add(current); } } return(instance); }
public void Register(Type nodeType, ICollection <Type> additionalComponents) { NodeDescriptionRegistry.AddNodeDescription(new StandardNodeDescription(nodeType, additionalComponents)); }
public void RegisterSingleNode <T>() where T : Component { NodeDescriptionRegistry.AddNodeDescription(new StandardNodeDescription(typeof(SingleNode <T>), null)); }
public void RegisterNode <T>() where T : Node { NodeDescriptionRegistry.AddNodeDescription(new StandardNodeDescription(typeof(T), null)); }