Esempio n. 1
0
            public bool TryActivateObjectByPhase(ref PhaseEnabler phaseEnabler, ref ActivatableObject activatableObject)
            {
                int  phase   = phaseConfig.phase;
                bool enabled = phase == phaseEnabler.enabledPhase;

                if (activatableObject.linkedObjectActive == enabled)
                {
                    return(false);
                }

                activatableObject.linkedObjectActive = enabled;
                activatableObject.synchronized       = false;
                return(true);
            }
Esempio n. 2
0
            public void ExecuteEach(EntityManager entityManager, ComponentGroup phaseEnablerGroup)
            {
                NativeArray <Entity> entities = phaseEnablerGroup.ToEntityArray(Allocator.TempJob);

                for (int entityIndex = 0, numEntities = entities.Length; entityIndex < numEntities; ++entityIndex)
                {
                    Entity            entity            = entities[entityIndex];
                    PhaseEnabler      phaseEnabler      = entityManager.GetComponentData <PhaseEnabler>(entity);
                    ActivatableObject activatableObject = entityManager.GetSharedComponentData <ActivatableObject>(entity);
                    if (!TryActivateObjectByPhase(ref phaseEnabler, ref activatableObject))
                    {
                        continue;
                    }

                    entityManager.SetSharedComponentData <ActivatableObject>(entity, activatableObject);
                }
                entities.Dispose();
            }