Пример #1
0
        /// <summary>
        ///     Creates a <see cref="Constraint"/> object with an Component QueryConstraint.
        /// </summary>
        /// <typeparam name="T">
        ///     Type of the component to constrain.
        /// </typeparam>
        /// <returns>
        ///     A <see cref="Constraint"/> object.
        /// </returns>
        public static Constraint Component <T>() where T : ISpatialComponentData
        {
            var constraint = Default();

            constraint.ComponentConstraint = ComponentDatabase.GetComponentId <T>();
            return(new Constraint(constraint));
        }
Пример #2
0
        private void UpdateComponentSet()
        {
            using (var components = world.EntityManager.GetComponentTypes(selected.Value.Entity, allocator: Allocator.Temp))
            {
                var spatialComponents = components
                                        .Where(type => typeof(ISpatialComponentData).IsAssignableFrom(type.GetManagedType()))
                                        .OrderBy(type => ComponentDatabase.GetComponentId(type.GetManagedType()));

                if (AreSameComponents(spatialComponents, visualElements))
                {
                    return;
                }

                componentContainer.Clear();
                visualElements.Clear();

                foreach (var componentType in spatialComponents)
                {
                    var componentElement = Cache.Get(componentType);
                    componentContainer.Add(componentElement);
                    visualElements.Add(componentElement);
                }
            }
        }
Пример #3
0
 /// <summary>
 ///     Clears all InterestQueries for a given authoritative component.
 /// </summary>
 /// <typeparam name="T">
 ///     Type of the authoritative component to clear InterestQueries from.
 /// </typeparam>
 /// <returns>
 ///     An <see cref="InterestTemplate"/> object.
 /// </returns>
 public InterestTemplate ClearQueries <T>()
     where T : ISpatialComponentData
 {
     return(ClearQueries(ComponentDatabase.GetComponentId <T>()));
 }
Пример #4
0
 /// <summary>
 ///     Replaces a component's InterestQueries in the Interest component.
 /// </summary>
 /// <param name="interestQueries">
 ///     Set of InterestQueries to add for a given authoritative component.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the authoritative component to replace InterestQueries of.
 /// </typeparam>
 /// <remarks>
 ///     At least one <see cref="InterestQuery"/> must be provided to replace a component's interest.
 /// </remarks>
 /// <returns>
 ///     An <see cref="InterestTemplate"/> object.
 /// </returns>
 public InterestTemplate ReplaceQueries <T>(IEnumerable <InterestQuery> interestQueries)
     where T : ISpatialComponentData
 {
     return(ReplaceQueries(ComponentDatabase.GetComponentId <T>(), interestQueries));
 }
Пример #5
0
 /// <summary>
 ///     Replaces a component's InterestQueries in the Interest component.
 /// </summary>
 /// <param name="interestQuery">
 ///     First <see cref="InterestQuery"/> to add for a given authoritative component.
 /// </param>
 /// <param name="interestQueries">
 ///     Further InterestQueries to add for a given authoritative component.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the authoritative component to replace InterestQueries of.
 /// </typeparam>
 /// <remarks>
 ///     At least one <see cref="InterestQuery"/> must be provided to replace a component's interest.
 /// </remarks>
 /// <returns>
 ///     An <see cref="InterestTemplate"/> object.
 /// </returns>
 public InterestTemplate ReplaceQueries <T>(InterestQuery interestQuery,
                                            params InterestQuery[] interestQueries)
     where T : ISpatialComponentData
 {
     return(ReplaceQueries(ComponentDatabase.GetComponentId <T>(), interestQuery, interestQueries));
 }