private void CreateAuthChangeAction <T>(AuthChangeFunc <T> authFunc)
            where T : class
        {
            var componentQueryDesc = TransformUtils.ConstructEntityQueryDesc <T>(requireAuthority: false, authBaseComponentTypes);

            componentQueryDesc.None = componentQueryDesc.None
                                      .Append(ComponentType.ReadOnly <NewlyAddedSpatialOSEntity>())
                                      .ToArray();

            var entityQuery = GetEntityQuery(componentQueryDesc);

            authKinematicActions.Add(typeof(T), () => Entities.With(entityQuery).ForEach(
                                         (
                                             T component,
                                             ref KinematicStateWhenAuth kinematicStateWhenAuth,
                                             ref SpatialEntityId spatialEntityId) =>
            {
                var changes = updateSystem.GetAuthorityChangesReceived(spatialEntityId.EntityId,
                                                                       TransformInternal.ComponentId);
                if (changes.Count == 0)
                {
                    return;
                }

                var auth = changes[changes.Count - 1];

                authFunc(ref kinematicStateWhenAuth, auth, component);
            }));
        }
Example #2
0
        internal void RegisterTransformSyncType <T>(ITransformSync <T> impl)
            where T : class
        {
            var componentQueryDesc = TransformUtils.ConstructEntityQueryDesc <T>(requireAuthority: true, baseComponentTypes);

            componentQueryDesc.None = baseExcludeComponentTypes;

            var entityQuery = GetEntityQuery(componentQueryDesc);

            resetAuthorityActions.Add(typeof(T), () => Entities.With(entityQuery).ForEach(
                                          (Entity entity,
                                           DynamicBuffer <BufferedTransform> buffer,
                                           ref TicksSinceLastTransformUpdate ticksSinceLastTransformUpdate,
                                           ref TransformInternal.Component transformInternal,
                                           ref SpatialEntityId spatialEntityId) =>
            {
                if (updateSystem
                    .GetAuthorityChangesReceived(spatialEntityId.EntityId, TransformInternal.ComponentId)
                    .Count == 0)
                {
                    return;
                }

                var component = EntityManager.GetComponentObject <T>(entity);

                impl.OnResetAuth(worker, entity, ref transformInternal, component);

                buffer.Clear();
                ticksSinceLastTransformUpdate = new TicksSinceLastTransformUpdate();
            }));

            UpdateTransformQuery();
        }
        private void CreateInitAction <T>(EntityQueryBuilder.F_DC <KinematicStateWhenAuth, T> initFunc)
            where T : class
        {
            var entityQuery = GetEntityQuery(TransformUtils.ConstructEntityQueryDesc <T>(requireAuthority: false, initBaseComponentTypes));

            initKinematicActions.Add(typeof(T), () => Entities.With(entityQuery).ForEach(initFunc));
        }
Example #4
0
        private void UpdateTransformQuery()
        {
            var transformQueryDesc = TransformUtils.ConstructEntityQueryDesc <UnityEngine.Transform>(requireAuthority: true, baseComponentTypes);

            transformQueryDesc.None = updateLatestTransformActions.Keys
                                      .Select(ComponentType.ReadOnly)
                                      .ToArray();

            transformQuery = GetEntityQuery(transformQueryDesc);
        }
Example #5
0
        internal void RegisterTransformSyncType <T>(ITransformSync <T> impl)
            where T : class
        {
            var entityQuery = GetEntityQuery(TransformUtils.ConstructEntityQueryDesc <T>(requireAuthority: false, baseComponentTypes));

            applyLatestTransformActions.Add(typeof(T),
                                            () => Entities.With(entityQuery)
                                            .ForEach((EntityQueryBuilder.F_DC <TransformToSet, T>)impl.ApplyLatestTransform));
            UpdateTransformQuery();
        }
Example #6
0
        private void UpdateTransformQuery()
        {
            var transformQueryDesc = TransformUtils.ConstructEntityQueryDesc <UnityEngine.Transform>(baseComponentTypes);

            transformQueryDesc.None = applyLatestTransformActions.Keys
                                      .Select(ComponentType.ReadOnly)
                                      .ToArray();

            transformQuery = GetEntityQuery(transformQueryDesc);
            transformQuery.SetFilter(TransformInternal.ComponentAuthority.NotAuthoritative);
        }
        internal void RegisterTransformSyncType <T>(ITransformSync <T> impl)
            where T : class
        {
            var entityQuery = GetEntityQuery(TransformUtils.ConstructEntityQueryDesc <T>(baseComponentTypes));

            entityQuery.SetFilter(TransformInternal.ComponentAuthority.Authoritative);

            updateLatestTransformActions.Add(typeof(T),
                                             () => Entities.With(entityQuery)
                                             .ForEach((EntityQueryBuilder.F_DC <TransformToSend, T>)impl.UpdateLatestTransform));

            UpdateTransformQuery();
        }