Пример #1
0
        private Node CreateNode(NodeClassInstanceDescription description)
        {
            Node node = description.CreateNode(this.entity);

            this.descriptionByNode[node] = description;
            return(node);
        }
Пример #2
0
 public Node GetNode(NodeClassInstanceDescription instanceDescription)
 {
     if (!instanceDescription.NodeDescription.IsEmpty)
     {
         throw new NotSupportedException();
     }
     return(this.node);
 }
Пример #3
0
        public bool TryGetEntityNode(Entity entity, out EntityNode entityNode)
        {
            NodeClassInstanceDescription classInstanceDescription = this.argument.ClassInstanceDescription;

            entityNode = null;
            if (!((EntityInternal)entity).CanCast(classInstanceDescription.NodeDescription))
            {
                return(false);
            }
            entityNode = Cache.entityNode.GetInstance().Init(this, entity);
            return(true);
        }
Пример #4
0
 public void CleanNodes()
 {
     Dictionary <NodeClassInstanceDescription, Node> .Enumerator enumerator = this.nodeByDescription.GetEnumerator();
     while (enumerator.MoveNext())
     {
         KeyValuePair <NodeClassInstanceDescription, Node> current = enumerator.Current;
         NodeClassInstanceDescription key = current.Key;
         Node node = current.Value;
         key.FreeNode(node);
     }
     this.nodeByDescription.Clear();
     this.descriptionByNode.Clear();
 }
Пример #5
0
        private IList ConvertNodeCollection(NodeClassInstanceDescription nodeClassInstanceDescription, ICollection <Entity> entities)
        {
            int   count = entities.Count;
            IList genericListInstance = Cache.GetGenericListInstance(nodeClassInstanceDescription.NodeClass, count);

            Collections.Enumerator <Entity> enumerator = Collections.GetEnumerator <Entity>(entities);
            while (enumerator.MoveNext())
            {
                Node node = this.GetNode(enumerator.Current, nodeClassInstanceDescription);
                genericListInstance.Add(node);
            }
            return(genericListInstance);
        }
        public override bool Equals(object o)
        {
            if (ReferenceEquals(this, o))
            {
                return(true);
            }
            if ((o == null) || !ReferenceEquals(base.GetType(), o.GetType()))
            {
                return(false);
            }
            NodeClassInstanceDescription description = (NodeClassInstanceDescription)o;

            return(ReferenceEquals(this.NodeClass, description.NodeClass));
        }
Пример #7
0
 public HandlerArgument(int nodeNumber, bool collection, NodeClassInstanceDescription nodeClassInstanceDescription, Optional <Platform.Kernel.ECS.ClientEntitySystem.Impl.JoinType> joinJoinType, bool context, bool mandatory, bool combine, bool optional, Type argumentType)
 {
     this.NodeNumber = nodeNumber;
     this.Collection = collection;
     this.ClassInstanceDescription = nodeClassInstanceDescription;
     this.JoinType     = joinJoinType;
     this.Context      = context;
     this.Mandatory    = mandatory;
     this.Combine      = combine;
     this.Optional     = optional;
     this.ArgumentType = argumentType;
     this.SelectAll    = !this.JoinType.IsPresent() || (this.JoinType.IsPresent() && ReferenceEquals(this.JoinType.Get().GetType(), typeof(JoinAllType)));
     this.Validate();
 }
Пример #8
0
        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);
                }
            }
        }
Пример #9
0
        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>());
        }
Пример #10
0
        public Node GetNode(NodeClassInstanceDescription nodeClassInstanceDescription)
        {
            Node node;

            if (ReferenceEquals(nodeClassInstanceDescription, NodeClassInstanceDescription.EMPTY))
            {
                return(this.emptyNode);
            }
            this.AssertCanCast(nodeClassInstanceDescription.NodeDescription);
            if (!this.nodeByDescription.TryGetValue(nodeClassInstanceDescription, out node))
            {
                node = this.CreateNode(nodeClassInstanceDescription);
                this.nodeByDescription[nodeClassInstanceDescription] = node;
            }
            return(node);
        }
        private static string CreateMessage(Handler handler, NodeClassInstanceDescription nodeDesc, Entity entity)
        {
            object[] objArray1 = new object[6];
            objArray1[0] = "\nMethod: ";
            objArray1[1] = handler.GetHandlerName();
            objArray1[2] = "\nNodeClass: ";
            objArray1[3] = nodeDesc?.NodeClass.Name;
            object[] local1 = objArray1;
            local1[4] = " Node: ";
            local1[5] = nodeDesc?.NodeDescription;
            string str = string.Concat(local1);

            if (entity != null)
            {
                str = str + "\nEntity: " + (entity as EntityInternal).ToStringWithComponentsClasses();
            }
            return(str);
        }
Пример #12
0
        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());
        }
Пример #13
0
 public Node GetNode(NodeClassInstanceDescription instanceDescription) =>
 this.nodeProvider.GetNode(instanceDescription);
 public HandlerCallContextChangedException(Handler handler, NodeClassInstanceDescription nodeDesc, Entity entity) : base(CreateMessage(handler, nodeDesc, entity))
 {
 }
Пример #15
0
        private bool CheckNodeIsActual(Node node)
        {
            NodeClassInstanceDescription orCreateNodeClassDescription = NodeDescriptionRegistry.GetOrCreateNodeClassDescription(node.GetType(), null);

            return(((EntityImpl)node.Entity).NodeDescriptionStorage.Contains(orCreateNodeClassDescription.NodeDescription));
        }
Пример #16
0
 public HandlerArgumentBuilder SetNodeClassInstanceDescription(NodeClassInstanceDescription nodeClassInstanceDescription)
 {
     this.nodeClassInstanceDescription = nodeClassInstanceDescription;
     return(this);
 }
 public NodeFieldResolverException(NodeClassInstanceDescription description, Exception e) : base("description = " + description, e)
 {
 }
Пример #18
0
        public void PrepareInvokeArgument()
        {
            NodeClassInstanceDescription classInstanceDescription = this.argumentNode.argument.ClassInstanceDescription;

            this.invokeArgument = ((EntityInternal)this.entity).GetNode(classInstanceDescription);
        }
Пример #19
0
 private Node GetNode(Entity entity, NodeClassInstanceDescription nodeClassInstanceDescription) =>
 ((EntityInternal)entity).GetNode(nodeClassInstanceDescription);