Beispiel #1
0
    protected override void OnUpdate()
    {
        {
            Entities.With(Component_Query).ForEach((Unity.Entities.Entity Component_QueryEntity, PlayerControllerVS Component_QueryPlayerControllerVS, ref Unity.Transforms.Translation Component_QueryTranslation) =>
            {
                var Variable = 0F;
                var var      = 0F;
                Component_QueryTranslation.Value.x = math.clamp((Component_QueryTranslation.Value.x + ((UnityEngine.Input.GetAxis("Horizontal") * Time.deltaTime) * Component_QueryPlayerControllerVS.Speed)), -9F, 9F);
                Component_QueryTranslation.Value.y = 0.55F;
                Component_QueryTranslation.Value.z = math.clamp((Component_QueryTranslation.Value.z + ((UnityEngine.Input.GetAxis("Vertical") * Time.deltaTime) * Component_QueryPlayerControllerVS.Speed)), -9F, 9F);
                {
                    var Pickup_QueryEntities         = Pickup_Query.ToEntityArray(Allocator.TempJob);
                    var Pickup_QueryTranslationArray = Pickup_Query.ToComponentDataArray <Unity.Transforms.Translation>(Allocator.TempJob);
                    for (int Pickup_QueryIdx = 0; Pickup_QueryIdx < Pickup_QueryEntities.Length; Pickup_QueryIdx++)
                    {
                        var Pickup_QueryEntity      = Pickup_QueryEntities[Pickup_QueryIdx];
                        var Pickup_QueryTranslation = Pickup_QueryTranslationArray[Pickup_QueryIdx];
                        if ((1F >= math.distance(Component_QueryTranslation.Value, Pickup_QueryTranslation.Value)))
                        {
                            PostUpdateCommands.AddComponent <DestroyTag>(Pickup_QueryEntity, new DestroyTag {
                            });
                        }
                    }

                    Pickup_QueryTranslationArray.Dispose();
                    Pickup_QueryEntities.Dispose();
                }
            }

                                                   );
        }
    }
        /// <summary>
        /// Adds a component to a set of entities defines by the EntityQuery and
        /// sets the component of each entity in the query to the value in the component array.
        /// componentArray.Length must match entityQuery.ToEntityArray().Length.
        /// </summary>
        /// <param name="entityQuery">THe EntityQuery defining the entities to add component to</param>
        /// <param name="componentArray"></param>
        public void AddComponentData <T>(EntityQuery entityQuery, NativeArray <T> componentArray) where T : struct, IComponentData
        {
            using (var entities = entityQuery.ToEntityArray(Allocator.TempJob))
            {
                if (entities.Length != componentArray.Length)
                {
                    throw new System.ArgumentException($"AddComponentData number of entities in query '{entities.Length}' must match componentArray.Length '{componentArray.Length}'.");
                }

                AddComponent(entityQuery, ComponentType.ReadWrite <T>());

                var componentData = GetComponentDataFromEntity <T>();
                for (int i = 0; i != componentArray.Length; i++)
                {
                    componentData[entities[i]] = componentArray[i];
                }
            }
        }
Beispiel #3
0
    protected override void OnUpdate()
    {
        {
            Entities.With(Camera_Query).ForEach((Unity.Entities.Entity Camera_QueryEntity, UnityEngine.Transform Camera_QueryTransform) =>
            {
                var offset = new float3(0F, 10F, -10F);
                {
                    var Player_QueryEntities         = Player_Query.ToEntityArray(Allocator.TempJob);
                    var Player_QueryTranslationArray = Player_Query.ToComponentDataArray <Unity.Transforms.Translation>(Allocator.TempJob);
                    for (int Player_QueryIdx = 0; Player_QueryIdx < Player_QueryEntities.Length; Player_QueryIdx++)
                    {
                        var Player_QueryEntity         = Player_QueryEntities[Player_QueryIdx];
                        var Player_QueryTranslation    = Player_QueryTranslationArray[Player_QueryIdx];
                        Camera_QueryTransform.position = (Player_QueryTranslation.Value + offset);
                    }

                    Player_QueryTranslationArray.Dispose();
                    Player_QueryEntities.Dispose();
                }
            }

                                                );
        }
    }
        NativeArray <Entity> GetTempEntityArray(EntityQuery query)
        {
            var entityArray = query.ToEntityArray(Allocator.TempJob);

            return(entityArray);
        }
Beispiel #5
0
    protected override void OnUpdate()
    {
        GraphData graphData = GetSingleton <GraphData>();

        {
            EventSystem <AddPointEvent> .AddMissingBuffers(Entities, DestroyPickup_Query_MissingAddPointEvent, EntityManager);

            Entities.With(DestroyPickup_Query).ForEach((Unity.Entities.Entity DestroyPickup_QueryEntity) =>
            {
                var DestroyPickup_Query_AddPointEventBuffer = EntityManager.GetBuffer <AddPointEvent>(DestroyPickup_QueryEntity);
                PostUpdateCommands.DestroyEntity(DestroyPickup_QueryEntity);
                DestroyPickup_Query_AddPointEventBuffer.Add(new AddPointEvent {
                });
                graphData.Pickups_Amount = (graphData.Pickups_Amount - 1);
            }

                                                       );
        }

        {
            Entities.With(Empty_Query_WithAddPointEvent).ForEach((Unity.Entities.Entity Empty_QueryEntity, DynamicBuffer <AddPointEvent> eventBuffer) =>
            {
                for (int event_index = 0; event_index < eventBuffer.Length; event_index++)
                {
                    AddPointEvent ev = eventBuffer[event_index];
                    {
                        var GameManager_QueryEntities = GameManager_Query.ToEntityArray(Allocator.TempJob);
                        for (int GameManager_QueryIdx = 0; GameManager_QueryIdx < GameManager_QueryEntities.Length; GameManager_QueryIdx++)
                        {
                            var GameManager_QueryEntity      = GameManager_QueryEntities[GameManager_QueryIdx];
                            var GameManager_QueryGameManager = EntityManager.GetSharedComponentData <GameManager>(GameManager_QueryEntity);
                            graphData.Game_Score++;
                            GameManager_QueryGameManager.Score.text = graphData.Game_Score.ToString();
                            if ((graphData.Pickups_Amount <= 0))
                            {
                                GameManager_QueryGameManager.WinText.enabled = true;
                                Time.timeScale = 0F;
                            }

                            PostUpdateCommands.SetSharedComponent <GameManager>(GameManager_QueryEntities[GameManager_QueryIdx], GameManager_QueryGameManager);
                        }

                        GameManager_QueryEntities.Dispose();
                    }
                }
            }

                                                                 );
        }

        {
            Entities.With(GameManager_Query0Enter).ForEach((Unity.Entities.Entity GameManager_QueryEntity, GameManager GameManager_Query0EnterGameManager) =>
            {
                {
                    var PickupObjects_QueryEntities = PickupObjects_Query.ToEntityArray(Allocator.TempJob);
                    for (int PickupObjects_QueryIdx = 0; PickupObjects_QueryIdx < PickupObjects_QueryEntities.Length; PickupObjects_QueryIdx++)
                    {
                        var PickupObjects_QueryEntity = PickupObjects_QueryEntities[PickupObjects_QueryIdx];
                        graphData.Pickups_Amount      = (graphData.Pickups_Amount + 1);
                    }

                    PickupObjects_QueryEntities.Dispose();
                }

                GameManager_Query0EnterGameManager.Score.text      = graphData.Game_Score.ToString();
                GameManager_Query0EnterGameManager.WinText.enabled = false;
                PostUpdateCommands.AddComponent <GameManager_QueryTracking>(GameManager_QueryEntity, default(GameManager_QueryTracking));
            }

                                                           );
        }

        SetSingleton(graphData);
    }