protected override void OnCreate() { base.OnCreate(); m_Canvas = World.GetOrCreateSystem <ClientCanvasSystem>().CreateCanvas(out _, "UIDrumCanvas", defaultAddRaycaster: false); m_Canvas.renderMode = RenderMode.WorldSpace; m_Canvas.transform.localScale = new Vector3() * 0.05f; m_CameraQuery = GetEntityQuery(typeof(GameCamera)); var address = AddressBuilder.Client() .Folder("Models") .Folder("InGame") .Folder("UIDrum") .GetAsset("UIDrumPressure"); for (var i = 1; i <= 4; i++) { DrumPresentationPools[i] = new AsyncAssetPool <GameObject>(address); DrumBackendPools[i] = new AssetPool <GameObject>(CreateBackendDrumGameObject, World); DrumVariantCount[i] = 0; } timeSystem = World.GetExistingSystem <TimeSystem>(); m_EngineQuery = GetEntityQuery(typeof(RhythmEngineDescription), typeof(Relative <PlayerDescription>)); }
protected override void OnCreate() { Component_Query = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadOnly <PlayerInput>()); EntityManager.CreateEntity(typeof(GraphData)); SetSingleton(new GraphData { Movement_Multiplier = 0.1F }); }
protected override void OnCreate() { Quad_Query = GetEntityQuery( ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadWrite <MoveDirection>(), ComponentType.ReadOnly <MoveSpeed>()); myQuery = EntityManager.UniversalQuery; }
protected override void OnCreate() { Ball_Query = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadOnly <Unity.Physics.PhysicsVelocity>(), ComponentType.ReadOnly <BallTag>()); Ball_Query0 = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadOnly <Unity.Physics.PhysicsVelocity>(), ComponentType.ReadOnly <BallTag>()); EntityManager.CreateEntity(typeof(GraphData)); SetSingleton(new GraphData { xBoundaryValue = 12F }); }
protected override void OnCreate() { base.OnCreate(); group = GetEntityQuery( ComponentType.ReadOnly <PlayerInfo.Component>(), ComponentType.ReadOnly <Position.Component>(), ComponentType.ReadOnly <SpatialEntityId>() ); }
protected override void OnCreate() { LeftPaddle_Query = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadOnly <PlayerTag>()); RightPaddle_Query = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadOnly <Player2Tag>()); Sphere_QueryEnter = GetEntityQuery(ComponentType.Exclude <Sphere_QueryTracking>(), ComponentType.ReadOnly <Unity.Physics.PhysicsVelocity>(), ComponentType.ReadOnly <BallTag>()); EntityManager.CreateEntity(typeof(GraphData)); SetSingleton(new GraphData { speed = 10F, leftPaddlePosition = -8F, rightPaddlePosition = 8F, topClamp = 4F, bottomClamp = -2F }); }
protected override void OnCreate() { m_EndFrameBarrier = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>(); SpawnerQueryEnter = GetEntityQuery( ComponentType.ReadWrite <LogoSpawner>(), ComponentType.Exclude <SpawnerQueryTracking>()); SpawnerQueryTrackingQuery = GetEntityQuery(ComponentType.ReadOnly <SpawnerQueryTracking>()); EntityManager.CreateEntity(typeof(GraphData)); SetSingleton(new GraphData { range = new float2(128F, -128F) }); }
protected override void OnCreate() { base.OnCreate(); group = GetEntityQuery( ComponentType.ReadOnly <PlayerInfo.Component>(), ComponentType.ReadOnly <Transform>() ); interClient = IntervalCheckerInitializer.InitializedChecker(this.IntervalTime, setChecked: true); action = Query; }
protected override void OnCreate() { base.OnCreate(); group = GetEntityQuery( ComponentType.ReadWrite <StrategyOrderManager.Component>(), ComponentType.ReadOnly <StrategyOrderManager.HasAuthority>(), ComponentType.ReadOnly <BaseUnitStatus.Component>(), ComponentType.ReadOnly <SpatialEntityId>() ); inter = IntervalCheckerInitializer.InitializedChecker(1.0f); action = Query; }
protected override void OnCreate() { EventSystem <AddPointEvent> .Initialize(World); DestroyPickup_Query_MissingAddPointEvent = GetEntityQuery(ComponentType.Exclude <AddPointEvent>(), ComponentType.ReadOnly <DestroyTag>(), ComponentType.ReadOnly <PickupTag>()); DestroyPickup_Query = GetEntityQuery(ComponentType.ReadOnly <DestroyTag>(), ComponentType.ReadOnly <PickupTag>()); Empty_Query_WithAddPointEvent = GetEntityQuery(ComponentType.ReadOnly <AddPointEvent>()); Empty_Query = EntityManager.UniversalQuery; GameManager_Query = GetEntityQuery(ComponentType.ReadWrite <GameManager_QueryTracking>(), ComponentType.ReadWrite <GameManager>()); GameManager_Query0Enter = GetEntityQuery(ComponentType.Exclude <GameManager_QueryTracking>(), ComponentType.ReadWrite <GameManager>()); PickupObjects_Query = GetEntityQuery(ComponentType.ReadOnly <PickupTag>()); EntityManager.CreateEntity(typeof(GraphData)); SetSingleton(new GraphData { Game_Score = 0, Pickups_Amount = 0 }); }
static unsafe void Initialize(ComponentSystemBase system, EntityQuery entityQuery, Type jobType, Type wrapperJobType, bool isParallelFor, ref JobForEachCache cache, out ProcessIterationData iterator) { // Get the job reflection data and cache it if we don't already have it cached. if (isParallelFor && cache.JobReflectionDataParallelFor == IntPtr.Zero || !isParallelFor && cache.JobReflectionData == IntPtr.Zero) { var iType = GetIJobForEachInterface(jobType); if (cache.Types == null) { cache.Types = GetComponentTypes(jobType, iType, out cache.ProcessTypesCount, out cache.FilterChanged); } var res = GetJobReflection(jobType, wrapperJobType, iType, isParallelFor); if (isParallelFor) { cache.JobReflectionDataParallelFor = res; } else { cache.JobReflectionData = res; } } // Update cached EntityQuery and ComponentSystem data. if (system != null) { if (cache.ComponentSystem != system) { cache.EntityQuery = system.GetEntityQueryInternal(cache.Types); // If the cached filter has changed, update the newly cached EntityQuery with those changes. if (cache.FilterChanged.Length != 0) { cache.EntityQuery.SetFilterChanged(cache.FilterChanged); } // Otherwise, just reset our newly cached EntityQuery's filter. else { cache.EntityQuery.ResetFilter(); } cache.ComponentSystem = system; } } else if (entityQuery != null) { if (cache.EntityQuery != entityQuery) { // Cache the new EntityQuery and cache that our system is null. cache.EntityQuery = entityQuery; cache.ComponentSystem = null; } } var query = cache.EntityQuery; iterator.IsReadOnly0 = iterator.IsReadOnly1 = iterator.IsReadOnly2 = iterator.IsReadOnly3 = iterator.IsReadOnly4 = iterator.IsReadOnly5 = 0; fixed(int *isReadOnly = &iterator.IsReadOnly0) { for (var i = 0; i != cache.ProcessTypesCount; i++) { isReadOnly[i] = cache.Types[i].AccessModeType == ComponentType.AccessMode.ReadOnly ? 1 : 0; } } iterator.TypeIndex0 = iterator.TypeIndex1 = iterator.TypeIndex2 = iterator.TypeIndex3 = iterator.TypeIndex4 = iterator.TypeIndex5 = -1; fixed(int *typeIndices = &iterator.TypeIndex0) { for (var i = 0; i != cache.ProcessTypesCount; i++) { typeIndices[i] = cache.Types[i].TypeIndex; } } iterator.m_IsParallelFor = isParallelFor; iterator.m_Length = query.CalculateChunkCountWithoutFiltering(); iterator.GlobalSystemVersion = query.GetComponentChunkIterator().m_GlobalSystemVersion; #if ENABLE_UNITY_COLLECTIONS_CHECKS iterator.m_MaxIndex = iterator.m_Length - 1; iterator.m_MinIndex = 0; iterator.m_Safety0 = iterator.m_Safety1 = iterator.m_Safety2 = iterator.m_Safety3 = iterator.m_Safety4 = iterator.m_Safety5 = iterator.m_Safety6 = iterator.m_Safety7 = iterator.m_Safety8 = iterator.m_Safety9 = iterator.m_Safety10 = iterator.m_Safety11 = default(AtomicSafetyHandle); var bufferTypeCount = 0; iterator.m_SafetyReadOnlyCount = 0; fixed(AtomicSafetyHandle *safety = &iterator.m_Safety0) { for (var i = 0; i != cache.ProcessTypesCount; i++) { if (cache.Types[i].AccessModeType == ComponentType.AccessMode.ReadOnly) { safety[iterator.m_SafetyReadOnlyCount] = query.GetSafetyHandle(query.GetIndexInEntityQuery(cache.Types[i].TypeIndex)); iterator.m_SafetyReadOnlyCount++; if (cache.Types[i].IsBuffer) { safety[iterator.m_SafetyReadOnlyCount] = query.GetBufferSafetyHandle(query.GetIndexInEntityQuery(cache.Types[i].TypeIndex)); iterator.m_SafetyReadOnlyCount++; bufferTypeCount++; } } } } iterator.m_SafetyReadWriteCount = 0; fixed(AtomicSafetyHandle *safety = &iterator.m_Safety0) { for (var i = 0; i != cache.ProcessTypesCount; i++) { if (cache.Types[i].AccessModeType == ComponentType.AccessMode.ReadWrite) { safety[iterator.m_SafetyReadOnlyCount + iterator.m_SafetyReadWriteCount] = query.GetSafetyHandle(query.GetIndexInEntityQuery(cache.Types[i].TypeIndex)); iterator.m_SafetyReadWriteCount++; if (cache.Types[i].IsBuffer) { safety[iterator.m_SafetyReadOnlyCount + iterator.m_SafetyReadWriteCount] = query.GetBufferSafetyHandle(query.GetIndexInEntityQuery(cache.Types[i].TypeIndex)); iterator.m_SafetyReadWriteCount++; bufferTypeCount++; } } } } Assert.AreEqual(cache.ProcessTypesCount + bufferTypeCount, iterator.m_SafetyReadWriteCount + iterator.m_SafetyReadOnlyCount); #endif }
protected override void OnCreate() { LogoQuery = GetEntityQuery( ComponentType.ReadOnly <Unity.Transforms.LocalToWorld>(), ComponentType.ReadOnly <LogoPosition>()); }
protected override void OnCreate() { Component_QueryEnter = GetEntityQuery(ComponentType.Exclude <Component_QueryTracking>(), ComponentType.ReadWrite <TimedSelfDestruct>()); Component_Query0 = GetEntityQuery(ComponentType.ReadWrite <Component_QueryTracking>(), ComponentType.ReadOnly <TimedSelfDestruct>()); }
/// <summary> /// Destroy all entities having a common set of component types. /// </summary> /// <remarks>Since entities in the same chunk share the same component structure, this function effectively destroys /// the chunks holding any entities identified by the `entityQueryFilter` parameter.</remarks> /// <param name="entityQueryFilter">Defines the components an entity must have to qualify for destruction.</param> public void DestroyEntity(EntityQuery entityQuery) { var iterator = entityQuery.GetComponentChunkIterator(); DestroyEntity(iterator.m_MatchingArchetypeList, iterator.m_Filter); }
public void UnlockChunkOrder(EntityQuery query) { }
protected override void OnCreate() { Cube_Query = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Rotation>(), ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadOnly <CubeRotationComponent>()); }
public EntityQuery ToEntityQuery() => m_Query ?? (m_Query = m_System.GetEntityQuery(ToEntityQueryDesc()));
protected override void OnCreate() { Component_Query = GetEntityQuery(ComponentType.ReadWrite <PlayerInput>(), ComponentType.ReadOnly <PlayerTag>()); }
/// <summary> /// Adds an IJobChunk instance to the Job scheduler queue. /// </summary> /// <param name="jobData">An IJobChunk instance.</param> /// <param name="query">The query selecting chunks with the necessary components.</param> /// <param name="dependsOn">The handle identifying already scheduled Jobs that could constrain this Job. /// A Job that writes to a component must run before other Jobs that read or write that component. Jobs that /// only read the same components can run in parallel.</param> /// <typeparam name="T">The specific IJobChunk implementation type.</typeparam> /// <returns>A handle that combines the current Job with previous dependencies identified by the `dependsOn` /// parameter.</returns> public static unsafe JobHandle Schedule <T>(this T jobData, EntityQuery query, JobHandle dependsOn = default(JobHandle)) where T : struct, IJobChunk { return(ScheduleInternal(ref jobData, query, dependsOn, ScheduleMode.Batched)); }
public void DestroyEntity(EntityQuery entityQuery) { Unity.Entities.EntityComponentStore.AssertValidEntityQuery(entityQuery, EntityComponentStore); DestroyEntity(entityQuery._QueryData->MatchingArchetypes, entityQuery._Filter); }
protected override void OnCreate() { Component_Query = GetEntityQuery(ComponentType.ReadOnly <PlayerWeaponData>(), ComponentType.ReadOnly <PlayerInput>(), ComponentType.ReadOnly <Unity.Transforms.Translation>()); }
/// <summary> /// Runs the Job immediately on the current thread. /// </summary> /// <param name="jobData">An IJobChunk instance.</param> /// <param name="query">The query selecting chunks with the necessary components.</param> /// <typeparam name="T">The specific IJobChunk implementation type.</typeparam> public static void Run <T>(this T jobData, EntityQuery query) where T : struct, IJobChunk { ScheduleInternal(ref jobData, query, default(JobHandle), ScheduleMode.Run); }
public static JobHandle ScheduleSingle <T>(this T jobData, EntityQuery query, JobHandle dependsOn = default(JobHandle)) where T : struct, IBaseJobForEach { throw new CodegenShouldReplaceException(); }
protected override void OnCreate() { Component_Query = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Translation>(), ComponentType.ReadOnly <PlayerControllerVS>()); Pickup_Query = GetEntityQuery(ComponentType.ReadOnly <PickupTag>(), ComponentType.ReadOnly <Unity.Transforms.Translation>()); }
protected override void OnCreate() { Rotator_Query = GetEntityQuery(ComponentType.ReadWrite <Unity.Transforms.Rotation>(), ComponentType.ReadOnly <RotatorVS>()); }
/// <summary> /// Adds a component to a set of entities defined by a EntityQuery. /// </summary> /// <remarks> /// Adding a component changes an entity's archetype and results in the entity being moved to a different /// chunk. /// /// The added components have the default values for the type. /// /// **Important:** This function creates a sync point, which means that the EntityManager waits for all /// currently running Jobs to complete before adding the component and no additional Jobs can start before /// the function is finished. A sync point can cause a drop in performance because the ECS framework may not /// be able to make use of the processing power of all available cores. /// </remarks> /// <param name="entityQuery">The EntityQuery defining the entities to modify.</param> /// <param name="componentType">The type of component to add.</param> public void AddComponent(EntityQuery entityQuery, ComponentType componentType) { var iterator = entityQuery.GetComponentChunkIterator(); AddComponent(iterator.m_MatchingArchetypeList, iterator.m_Filter, componentType); }
public static JobHandle RunGroup <T>(this T jobData, EntityQuery cg, JobHandle dependsOn = default(JobHandle)) where T : struct, JobForEachExtensions.IBaseJobForEach { return(jobData.Run(cg, dependsOn)); }
/// <summary> /// Moves a selection of the entities managed by the specified EntityManager to the <see cref="World"/> of this EntityManager /// and fills an array with their <see cref="Entity"/> objects. /// </summary> /// <remarks> /// After the move, the entities are managed by this EntityManager. Use the `output` array to make post-move /// changes to the transferred entities. /// /// Each world has one EntityManager, which manages all the entities in that world. This function /// allows you to transfer entities from one World to another. /// /// **Important:** This function creates a sync point, which means that the EntityManager waits for all /// currently running Jobs to complete before moving the entities and no additional Jobs can start before /// the function is finished. A sync point can cause a drop in performance because the ECS framework may not /// be able to make use of the processing power of all available cores. /// </remarks> /// <param name="output">An array to receive the Entity objects of the transferred entities.</param> /// <param name="srcEntities">The EntityManager whose entities are appropriated.</param> /// <param name="filter">A EntityQuery that defines the entities to move. Must be part of the source /// World.</param> /// <param name="entityRemapping">A set of entity transformations to make during the transfer.</param> /// <exception cref="ArgumentException"></exception> public void MoveEntitiesFrom(out NativeArray <Entity> output, EntityManager srcEntities, EntityQuery filter, NativeArray <EntityRemapUtility.EntityRemapInfo> entityRemapping) { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (filter.EntityComponentStore != srcEntities.EntityComponentStore) { throw new ArgumentException( "EntityManager.MoveEntitiesFrom failed - srcEntities and filter must belong to the same World)"); } #endif using (var chunks = filter.CreateArchetypeChunkArray(Allocator.TempJob)) { MoveEntitiesFrom(out output, srcEntities, chunks, entityRemapping); } }
public static JobHandle ScheduleGroupSingle <T>(this T jobData, EntityQuery cg, JobHandle dependsOn = default(JobHandle)) where T : struct, JobForEachExtensions.IBaseJobForEach { return(jobData.ScheduleSingle(cg, dependsOn)); }
/// <summary> /// Removes a component from a set of entities defined by a EntityQuery. /// </summary> /// <remarks> /// Removing a component changes an entity's archetype and results in the entity being moved to a different /// chunk. /// /// **Important:** This function creates a sync point, which means that the EntityManager waits for all /// currently running Jobs to complete before removing the component and no additional Jobs can start before /// the function is finished. A sync point can cause a drop in performance because the ECS framework may not /// be able to make use of the processing power of all available cores. /// </remarks> /// <param name="entityQuery">The EntityQuery defining the entities to modify.</param> /// <typeparam name="T">The type of component to remove.</typeparam> public void RemoveComponent <T>(EntityQuery entityQuery) { RemoveComponent(entityQuery, ComponentType.ReadWrite <T>()); }