#pragma warning restore 649

        public GameObject Resolve(SpatialOSEntityInfo entityInfo, EntityManager manager)
        {
            var authComponent = ComponentDatabase.GetMetaclass(authComponentId).Authority;

            return(manager.HasComponent(entityInfo.Entity, authComponent)
                ? ownedPrefab
                : unownedPrefab);
        }
Пример #2
0
        protected CommandReceiverSubscriptionManagerBase(World world, uint componentId) : base(world)
        {
            var componentMetaClass = ComponentDatabase.GetMetaclass(componentId);

            componentAuthType = componentMetaClass.Authority;

            entityManager = world.EntityManager;

            var constraintSystem = world.GetExistingSystem <ComponentConstraintsCallbackSystem>();

            constraintSystem.RegisterAuthorityCallback(componentId, authorityChange =>
            {
                if (authorityChange.Authority == Authority.Authoritative)
                {
                    if (!entitiesNotMatchingRequirements.Contains(authorityChange.EntityId))
                    {
                        return;
                    }

                    var entity = WorkerSystem.GetEntity(authorityChange.EntityId);

                    foreach (var subscription in entityIdToReceiveSubscriptions[authorityChange.EntityId])
                    {
                        subscription.SetAvailable(CreateReceiver(world, entity, authorityChange.EntityId));
                    }

                    entitiesMatchingRequirements.Add(authorityChange.EntityId);
                    entitiesNotMatchingRequirements.Remove(authorityChange.EntityId);
                }
                else if (authorityChange.Authority == Authority.NotAuthoritative)
                {
                    if (!entitiesMatchingRequirements.Contains(authorityChange.EntityId))
                    {
                        return;
                    }

                    foreach (var subscription in entityIdToReceiveSubscriptions[authorityChange.EntityId])
                    {
                        ResetValue(subscription);
                        subscription.SetUnavailable();
                    }

                    entitiesNotMatchingRequirements.Add(authorityChange.EntityId);
                    entitiesMatchingRequirements.Remove(authorityChange.EntityId);
                }
            });
        }