Example #1
0
        protected override void OnUpdate()
        {
            GameManager gameManager = GameManager.Instance();

            Debug.Assert(gameManager, "GameManager is null");

            Entities.With(OnRegisteredCellQuery).ForEach((Entity entity, ref CellComponent cellComp) =>
            {
                Entity dungeonEntity         = GetSingletonEntity <DungeonComponent>();
                DungeonComponent dungeonComp = GetSingleton <DungeonComponent>();
                DynamicBuffer <EntityBufferElement> cellsBuffer = ActiveEntityManager.GetBuffer <EntityBufferElement>(dungeonEntity);
                EntityBufferElement bufferElem = new EntityBufferElement
                {
                    Entity = entity,
                };

                int index          = cellComp.Coordinate.x + (cellComp.Coordinate.y * dungeonComp.SizeInCell.x);
                cellsBuffer[index] = bufferElem;

                PostUpdateCommands.AddComponent(entity, new RegisteredCellComponent());
            });

            Entities.With(OnChangedCellQuery).ForEach((Entity entity, ref CellComponent cellComp) =>
            {
                Material cellMaterial = cellComp.IsWall ? gameManager.CellWallMaterial : gameManager.CellGroundMaterial;
                PostUpdateCommands.SetSharedComponent(entity, new RenderMesh
                {
                    mesh     = gameManager.CellMesh,
                    material = cellMaterial,
                });
            });
        }
Example #2
0
        protected override void OnUpdate()
        {
            // Should only be one
            Fittest            fittestData   = Saved.Fittest[0];
            float              fitnessToBeat = fittestData.fitness;
            int                tag           = 0;
            Nullable <NetData> netToSave     = null;

            for (int i = 0; i < Entities.Length; ++i)
            {
                if (Entities.Stats[i].Fitness > fitnessToBeat)
                {
                    tag           = Entities.Stats[i].Tag;
                    fitnessToBeat = Entities.Stats[i].Fitness;
                    netToSave     = Entities.Net[i].Data;
                }
            }

            if (netToSave != null)
            {
                Debug.Log("FITTEST: " + fitnessToBeat);
                fittestData.fitness = fitnessToBeat;
                fittestData.net     = netToSave.Value;
                fittestData.tag     = tag;
                PostUpdateCommands.SetSharedComponent(Saved.Entities[0], fittestData);
            }
        }
        protected override void OnUpdate()
        {
            var materialReferencesEntity = GetSingletonEntity <MaterialReferences>();
            var materialReferences       = EntityManager.GetSharedComponentData <MaterialReferences>(materialReferencesEntity);

            Entities.ForEach((Entity entity, RenderMesh renderMesh, ref LabelNumber labelNumber) =>
            {
                Material newMaterial = null;

                if (labelNumber.IsVisible)
                {
                    newMaterial = materialReferences.Numbers[labelNumber.Number % 10];
                }
                else
                {
                    newMaterial = materialReferences.Empty;
                }

                if (newMaterial != renderMesh.material)
                {
                    renderMesh.material = newMaterial;
                    PostUpdateCommands.SetSharedComponent(entity, renderMesh);
                }
            });
        }
    protected unsafe override void OnUpdate()
    {
        var em = World.Active.EntityManager;

        Entities.WithAll <PhysicsCollider, ChangeColliderType, RenderMesh>().ForEach(
            (Entity entity, ref ChangeColliderType modifier) =>
        {
            modifier.LocalTime -= Time.fixedDeltaTime;

            if (modifier.LocalTime > 0.0f)
            {
                return;
            }

            modifier.LocalTime = modifier.TimeToSwap;
            var collider       = em.GetComponentData <PhysicsCollider>(entity);
            if (collider.ColliderPtr->Type == modifier.ColliderA.ColliderPtr->Type)
            {
                PostUpdateCommands.SetComponent(entity, modifier.ColliderB);
                PostUpdateCommands.SetSharedComponent(entity, em.GetSharedComponentData <RenderMesh>(modifier.EntityB));
            }
            else
            {
                PostUpdateCommands.SetComponent(entity, modifier.ColliderA);
                PostUpdateCommands.SetSharedComponent(entity, em.GetSharedComponentData <RenderMesh>(modifier.EntityA));
            }
        });
    }
 protected override void OnUpdate()
 {
     Entities.ForEach((Entity entity, RenderMesh renderMesh, ref MaterialId materialId, ref UpdateMaterialTag tag) =>
     {
         renderMesh.material = materialReferences.Materials[materialId.currentMaterialId];
         PostUpdateCommands.SetSharedComponent(entity, renderMesh);
     });
 }
        private void TakeScreenshot(Entity entity, ScreenshotResult result, ref ScreenshotRequest request)
        {
            Camera cam = request.TargetCamera != Entity.Null
                ? EntityManager.GetComponentObject <Camera>(request.TargetCamera)
                : GetMainCamera();
            int   camCullMask = cam.cullingMask;
            float camSize     = cam.orthographicSize;
            var   camPos      = cam.transform.position;
            var   clearFlags  = cam.clearFlags;
            //for screenshot with transparency on an android clearFlags must be NOT Depth or Nothing
            bool requareChangeClearFlagsForScreenshot = clearFlags == CameraClearFlags.Depth ||
                                                        clearFlags == CameraClearFlags.Nothing;

            if (requareChangeClearFlagsForScreenshot)
            {
                cam.clearFlags = CameraClearFlags.SolidColor;
            }
            cam.cullingMask = request.CullingMask;
            var screenshotSize = request.Size;
            var tempRt         = RenderTexture.GetTemporary(screenshotSize.x, screenshotSize.y, 24, RenderTextureFormat.ARGB32);

            cam.targetTexture = tempRt;
            if (request.OverridedSize > 0)
            {
                cam.orthographicSize = request.OverridedSize;
            }
            if (request.OverridePosition)
            {
                cam.transform.position = request.Position;
            }

            cam.Render();
            cam.clearFlags  = clearFlags;
            cam.cullingMask = camCullMask;
            if (request.OverridedSize > 0)
            {
                cam.orthographicSize = camSize;
            }
            if (request.OverridePosition)
            {
                cam.transform.position = camPos;
            }
            cam.targetTexture    = null;
            RenderTexture.active = tempRt;
            Texture2D screenshot = result.Texture ?? new Texture2D(screenshotSize.x, screenshotSize.y, TextureFormat.RGBA32, false);

            screenshot.ReadPixels(new Rect(0, 0, screenshot.width, screenshot.height), 0, 0);
            screenshot.Apply(false);
            GL.Clear(true, true, Color.clear);
            RenderTexture.active = null;
            RenderTexture.ReleaseTemporary(tempRt);
            if (result.Texture == null)
            {
                PostUpdateCommands.SetSharedComponent(entity, new ScreenshotResult {
                    Texture = screenshot
                });
            }
        }
Example #7
0
        private void HandleMaterials <T>(Material baseMat, Material hoverMat, Material selectedMat, Material hoverSelectedMat)
            where T : struct, IComponentData
        {
            Entities
            .WithAllReadOnly <T, Hovered, DirtyMaterial>()
            .WithNone <Selected>()
            .WithAll <RenderMesh>()
            .ForEach(entity =>
            {
                var renderMesh = EntityManager.GetSharedComponentData <RenderMesh>(entity);

                renderMesh.material = hoverMat;

                PostUpdateCommands.SetSharedComponent(entity, renderMesh);
                PostUpdateCommands.RemoveComponent <DirtyMaterial>(entity);
            });

            Entities
            .WithAllReadOnly <T, Selected, DirtyMaterial>()
            .WithNone <Hovered>()
            .WithAll <RenderMesh>()
            .ForEach(entity =>
            {
                var renderMesh = EntityManager.GetSharedComponentData <RenderMesh>(entity);

                renderMesh.material = selectedMat;

                PostUpdateCommands.SetSharedComponent(entity, renderMesh);
                PostUpdateCommands.RemoveComponent <DirtyMaterial>(entity);
            });

            Entities
            .WithAllReadOnly <T, Hovered, Selected, DirtyMaterial>()
            .WithAll <RenderMesh>()
            .ForEach(entity =>
            {
                var renderMesh = EntityManager.GetSharedComponentData <RenderMesh>(entity);

                renderMesh.material = hoverSelectedMat;

                PostUpdateCommands.SetSharedComponent(entity, renderMesh);
                PostUpdateCommands.RemoveComponent <DirtyMaterial>(entity);
            });

            Entities
            .WithAllReadOnly <T, DirtyMaterial>()
            .WithNone <Hovered, Selected>()
            .WithAll <RenderMesh>()
            .ForEach(entity =>
            {
                var renderMesh = EntityManager.GetSharedComponentData <RenderMesh>(entity);

                renderMesh.material = baseMat;

                PostUpdateCommands.SetSharedComponent(entity, renderMesh);
                PostUpdateCommands.RemoveComponent <DirtyMaterial>(entity);
            });
        }
Example #8
0
        protected override void OnUpdate()
        {
            float deltaTime = Time.deltaTime;

            for (int i = 0; i < this._group.Length; ++i)
            {
                var playerSettings = this._group.PlayerSettings[i];
                var pos            = this._group.Position[i].Value;
                var input          = this._group.Input[i];

                var movable = playerSettings.MovableAreaInstance;
                pos = new float3(MainECS_Manager.WorldMousePosision.x, 0, MainECS_Manager.WorldMousePosision.z);

                if (pos.x <= movable.xMin)
                {
                    pos.x = movable.xMin;
                }
                else if (pos.x > movable.xMax)
                {
                    pos.x = movable.xMax;
                }

                if (pos.y <= movable.yMin)
                {
                    pos.y = movable.yMin;
                }
                else if (pos.y > movable.yMax)
                {
                    pos.y = movable.yMax;
                }


                var retPos = new Position {
                    Value = pos
                };
                if (input.Fire == 1)
                {
                    input.FireCooldown = playerSettings.ShootSettingsInstance.FireCooldown;

                    PostUpdateCommands.CreateEntity(MainECS_Manager.PlayerBulletArchetype);
                    PostUpdateCommands.SetComponent(retPos);
                    PostUpdateCommands.SetComponent(
                        new BulletData
                    {
                        ShotSpeed = playerSettings.ShootSettingsInstance.ShotSpeed,
                        // 上方向固定で発射
                        ShotAngle = 90,
                        Lifespan  = playerSettings.ShootSettingsInstance.Lifespan
                    });
                    PostUpdateCommands.SetSharedComponent(MainECS_Manager.PlayerBulletLook);
                    PostUpdateCommands.SetSharedComponent(MainECS_Manager.BulletCollision);
                }

                this._group.Position[i] = retPos;
                this._group.Input[i]    = input;
            }
        }
Example #9
0
    protected override void OnUpdate()
    {
        var em = World.Active.EntityManager;

        Entities.WithAll <ChangeMotionType, RenderMesh>().ForEach(
            (Entity entity, ref ChangeMotionType modifier) =>
        {
            modifier.LocalTime -= Time.deltaTime;

            if (modifier.LocalTime > 0.0f)
            {
                return;
            }

            modifier.LocalTime = modifier.TimeToSwap;

            var renderMesh = em.GetSharedComponentData <RenderMesh>(entity);
            UnityEngine.Material material = renderMesh.material;
            switch (modifier.MotionType)
            {
            case BodyMotionType.Dynamic:
                // move to kinematic body by removing PhysicsMass component
                // note that a 'kinematic' body is really just a dynamic body with infinite mass properties
                // hence the same thing could be achieved by setting properties via PhysicsMass.CreateKinematic
                PostUpdateCommands.RemoveComponent <PhysicsMass>(entity);

                // set the new modifier type and grab the appropriate new render material
                material            = em.GetSharedComponentData <RenderMesh>(modifier.EntityKinematic).material;
                modifier.MotionType = BodyMotionType.Kinematic;
                break;

            case BodyMotionType.Kinematic:
                // move to static by removing PhysicsVelocity
                PostUpdateCommands.RemoveComponent <PhysicsVelocity>(entity);

                // set the new modifier type and grab the appropriate new render material
                material            = em.GetSharedComponentData <RenderMesh>(modifier.EntityStatic).material;
                modifier.MotionType = BodyMotionType.Static;
                break;

            case BodyMotionType.Static:
                // move to dynamic by adding PhysicsVelocity and non infinite PhysicsMass
                modifier.DynamicVelocity.Linear.y = 5.0f;
                PostUpdateCommands.AddComponent(entity, modifier.DynamicVelocity);
                PostUpdateCommands.AddComponent(entity, modifier.DynamicMass);

                // set the new modifier type and grab the appropriate new render material
                material            = em.GetSharedComponentData <RenderMesh>(modifier.EntityDynamic).material;
                modifier.MotionType = BodyMotionType.Dynamic;
                break;
            }
            // assign the new render mesh material
            renderMesh.material = material;
            PostUpdateCommands.SetSharedComponent(entity, renderMesh);
        });
    }
        protected override unsafe void OnUpdate()
        {
            using (var entities = new NativeArray <Entity>(
                       TerrainSettings.ChunkCount * TerrainSettings.ArrayChunk,
                       Allocator.Temp
                       ))
            {
                EntityManager.CreateEntity(_entityArchetypeNoise, entities);
            }

            var meshCalculationGrid = new MeshCalculationGrid
                                      (
                TerrainSettings.Resolution,
                1f / TerrainSettings.Resolution,
                TerrainSettings.TotalVertices,
                TerrainSettings.TotalTriangles
                                      );

            meshCalculationGrid.Schedule(64).Complete();
            _vertices.NativeInject(meshCalculationGrid.Vertices);
            _triangles.NativeInject(meshCalculationGrid.Triangles);

            using (var entities = new NativeArray <Entity>(TerrainSettings.ChunkCount, Allocator.Temp))
            {
                EntityManager.CreateEntity(_entityArchetypeMesh, entities);
                for (var i = 0; i < TerrainSettings.ChunkCount; i++)
                {
                    var mesh = new Mesh();
                    mesh.SetVertices(_vertices);
                    mesh.SetTriangles(_triangles, 0);
                    mesh.SetNormals(_vertices);
                    mesh.MarkDynamic();
                    _renderMesh.mesh = mesh;
                    PostUpdateCommands.SetSharedComponent(entities[i], _renderMesh);
                    PostUpdateCommands.SetComponent(entities[i], new RenderBounds
                    {
                        Value = new AABB
                        {
                            Center  = float3.zero,
                            Extents = math.float3(0.5f, 1f, 0.5f)
                        }
                    });
                }
            }

            var entity       = EntityManager.CreateEntity(EntityManager.CreateArchetype(typeof(VerticesData)));
            var verticesData = EntityManager.GetBuffer <VerticesData>(entity);

            verticesData.ResizeUninitialized(TerrainSettings.TotalVertices);
            verticesData.InjectData(meshCalculationGrid.Vertices.GetUnsafeReadOnlyPtr(), TerrainSettings.TotalVertices);

            meshCalculationGrid.Dispose();
            _triangles.Clear();
            _vertices.Clear();
        }
Example #11
0
        protected override void OnUpdate()
        {
            // EntityManager em = World.Active.GetOrCreateManager<EntityManager>();
            // NativeArray<Entity> ea = em.ent
            for (int i = 0; i < _enemy.Length; ++i)
            {
                var   entity      = _enemy.Entities[i];
                Enemy en          = _enemy.Enemies[i];
                float blink_timer = _enemy.Blinks[i].Value;
                // float blink_timer = en.HitBlinkTimer;
                // BlinkTrigger bts = _enemy.Triggers[i];

                // MeshInstanceRenderer mr = _enemy.MeshRenderer[i];
                // MeshInstanceRenderer mr = manager.GetSharedComponentData<MeshInstanceRenderer>(entity);
                // Material mat = mr.material;
                if (blink_timer > 0.0f)
                {
                    // mat.SetColor("_Color", Color.red);
                    blink_timer     -= Time.deltaTime;
                    _enemy.Blinks[i] = new BlinkTimer {
                        Value = blink_timer
                    };
                    // _enemy.Enemies[i] = en;
                    // em.SetSharedComponentData<MeshInstanceRenderer>(entity, Bootloader.OnHitOne);
                    PostUpdateCommands.SetSharedComponent(entity, Bootloader.OnHitOne);
                    // nextMat = Bootloader.OnHitOne;
                    // _enemy[i].MeshRenderer = Bootloader.OnHitOne;
                }
                else
                {
                    // mat.SetColor("_Color", DefaultColor);
                    // MeshInstanceRenderer nextMat = Bootloader.OnHitOne;
                    // em.SetSharedComponentData<MeshInstanceRenderer>(entity, Bootloader.EnemyPrefab);
                    PostUpdateCommands.SetSharedComponent(entity, Bootloader.EnemyPrefab);
                }
                // mr.material = mat;
                // _enemy.MeshRenderer[i] = mr;
            }

            for (int i = 0; i < _player.Length; ++i)
            {
                Entity     pe = _player.Entity[i];
                BlinkTimer bt = _player.Blinks[i];
                if (bt.Value > 0.0f)
                {
                    bt.Value         -= Time.deltaTime;
                    _player.Blinks[i] = bt;
                    PostUpdateCommands.SetSharedComponent(pe, Bootloader.OnHitPlayer);
                }
                else
                {
                    PostUpdateCommands.SetSharedComponent(pe, Bootloader.BounceBall);
                }
            }
        }
Example #12
0
    private void createBlock()
    {
        string entityName = "block";

        PostUpdateCommands.CreateEntity(ArchetypeFactory.Instance.getArchetypeByName(entityName));

        MeshInstanceRenderer renderer = EntityLookFactory.Instance.getLook(entityName);

        PostUpdateCommands.SetComponent(EntityFactory.getColliderInfo(renderer));
        PostUpdateCommands.SetSharedComponent(renderer);
    }
Example #13
0
        protected override void OnUpdate()
        {
            Entity gunEntity = GetSingletonEntity <GunComponent>();

            int pos = 1;

            if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
            {
                pos--;
            }

            if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
            {
                pos++;
            }

            if (Input.GetKey(KeyCode.Space) && Time.ElapsedTime >= _cooldownTimer)
            {
                GunComponent gunComponent = EntityManager.GetComponentData <GunComponent>(gunEntity);
                _cooldownTimer = Time.ElapsedTime + gunComponent.Cooldown;

                EntityQueryDesc query = new EntityQueryDesc
                {
                    None = new ComponentType[] { ComponentType.ReadOnly <IsMoving>() },
                    All  = new ComponentType[] { typeof(Translation), typeof(MovableComponent), ComponentType.ReadOnly <BulletComponent>() }
                };
                EntityQuery entityQuery = GetEntityQuery(query);
                if (!entityQuery.IsEmptyIgnoreFilter)
                {
                    NativeArray <Entity> entities = entityQuery.ToEntityArray(Allocator.Persistent);
                    Entity           entity       = entities[0];
                    float3           direction    = Quaternion.AngleAxis(60 - 30 * pos, Vector3.back) * Vector3.up;
                    MovableComponent component    = EntityManager.GetComponentData <MovableComponent>(entity);
                    component.Direction = direction;
                    PostUpdateCommands.AddComponent(entity, new IsMoving());
                    PostUpdateCommands.SetComponent(entity, component);
                    entities.Dispose();
                    GameManager.Instance.ShotFired();
                }
            }

            var materialReferencesEntity = GetSingletonEntity <MaterialReferences>();
            var materialReferences       = EntityManager.GetSharedComponentData <MaterialReferences>(materialReferencesEntity);

            RenderMesh renderMesh  = EntityManager.GetSharedComponentData <RenderMesh>(gunEntity);
            Material   newMaterial = materialReferences.GunPositions[pos];

            if (newMaterial != renderMesh.material)
            {
                renderMesh.material = newMaterial;
                PostUpdateCommands.SetSharedComponent(gunEntity, renderMesh);
            }
        }
Example #14
0
    private void CreateBarrier(MapColliderInfo colliderMap, MapTerrainInfo terrainMap, int x, int y)
    {
        if (MapColliderUtils.UnReachable(colliderMap, x, y))
        {
            return;
        }

        for (int y2 = -1 + y; y2 < (1 + y); y2++)
        {
            for (int x2 = -1 + x; x2 < (1 + x); x2++)
            {
                MapColliderUtils.AddCost(colliderMap, x2, y2, 3);
            }
        }
        MapColliderUtils.SetCostValue(colliderMap, x, y, 255);


        // Instantiate a barrier on (x, y)
        var barrierRenderer = EntityPrefabContainer.BarrierRenderer;
        var drawPos         = barrierRenderer.GetComponent <Position2DComponent> ().Value.Offset;

        drawPos += new float2(x, y);
        var heading = barrierRenderer.GetComponent <Heading2DComponent> ().Value.Value;

        PostUpdateCommands.CreateEntity(EntityPrefabContainer.BarrierArchetype);
        PostUpdateCommands.SetComponent(new Position2D()
        {
            Value  = new float2(x, y),
            Offset = drawPos - new float2(x, y)
        });
        PostUpdateCommands.SetComponent(new Heading2D()
        {
            Value = heading
        });
        PostUpdateCommands.SetComponent(new TransformMatrix
        {
            Value = MathUtils.GetTransformMatrix(drawPos, heading)
        });
        PostUpdateCommands.SetComponent(
            barrierRenderer.GetComponent <BarrierComponent> ().Value
            );
        PostUpdateCommands.SetSharedComponent(
            barrierRenderer.GetComponent <TerrainRendererComponent> ().Value
            );

        var barrierColPos = new Vector3(x, 0, y);
        var barrierCol    = Object.Instantiate(EntityPrefabContainer.BarrierColliderPrefab,
                                               barrierColPos, Quaternion.identity);

        terrainMap.Terrains[x, y] |= TerrainType.Barrier;
        MapTerrainUtils.AddCollider(terrainMap, barrierCol);
    }
 protected override void OnUpdate()
 {
     Entities.ForEach((Entity entity, ref ConditionDebugger debugger, ref Parent parent, ref NonUniformScale compositeScale) =>
     {
         if (!EntityManager.HasComponent <Condition>(parent.Value))
         {
             return;
         }
         var condition = EntityManager.GetComponentData <Condition>(parent.Value);
         if (debugger.type == ConditionType.Hunger)
         {
             if (condition.hunger > 0.01f)
             {
                 compositeScale.Value.y = condition.hunger * 0.01f * debugger.sizeMultiplyer;
             }
             else
             {
                 compositeScale.Value.y = 0f;
             }
         }
         if (debugger.type == ConditionType.LifeLine)
         {
             var rendererMesh       = EntityManager.GetSharedComponentData <RenderMesh>(entity);
             compositeScale.Value.y = condition.lifeLine * 0.01f * debugger.sizeMultiplyer;
             var selectedMaterial   = Materails.Instance.rest;
             if (condition.lifeLine < condition.maxLifeLine)
             {
                 selectedMaterial = Materails.Instance.healing;
             }
             if (condition.hurting > 0f)
             {
                 selectedMaterial = Materails.Instance.hurting;
             }
             if (condition.lifeLine < 30f)
             {
                 selectedMaterial = Materails.Instance.toLow;
             }
             if (rendererMesh.material == selectedMaterial)
             {
                 return;
             }
             PostUpdateCommands.SetSharedComponent(entity, new RenderMesh()
             {
                 material = selectedMaterial,
                 mesh     = rendererMesh.mesh
             });
         }
     });
 }
Example #16
0
    protected override void OnUpdate()
    {
        commandBuffer = ecb.CreateCommandBuffer();

        Entities.ForEach((Entity ent, ref PlayerHit playerHit, ref PowerUpSystemComponent powerup) =>
        {
            commandBuffer.RemoveComponent <PlayerHit>(ent);
            powerup.currentCharge = 0;
        });


        Entities.ForEach((Entity ent, ref PowerUpSystemComponent powerupsys, ref PowerUpTriggerComponent powerUpTriggerComponent) =>
        {
            if (powerupsys.currentCharge == powerupsys.chargeTime)
            {
                return;
            }

            if (powerupsys.currentCharge == 0)
            {
                powerUpTriggerComponent.enabled = false;

                var renderer = World.Active.EntityManager.GetSharedComponentData <RenderMesh>(ent);

                Vector2 offset = new Vector2(0.5f, 0.0f);
                renderer.material.mainTextureOffset = offset;

                PostUpdateCommands.SetSharedComponent <RenderMesh>(ent, renderer);
            }

            var deltaTime             = Time.deltaTime;
            powerupsys.currentCharge += deltaTime;

            if (powerupsys.currentCharge >= powerupsys.chargeTime)
            {
                powerupsys.currentCharge        = powerupsys.chargeTime;
                powerUpTriggerComponent.enabled = true;

                var renderer = World.Active.EntityManager.GetSharedComponentData <RenderMesh>(ent);

                Vector2 offset = new Vector2(0.0f, 0.0f);
                renderer.material.mainTextureOffset = offset;

                PostUpdateCommands.SetSharedComponent <RenderMesh>(ent, renderer);
            }
        });
    }
        protected override void OnUpdate()
        {
            var random = new Random((uint)UnityEngine.Random.Range(1, 100000));

            var job = new InfectionJob()
            {
                targetMap = InfectionHashMap.quadrantHashMap,
                deltaTime = Time.DeltaTime,
                random    = random,
            };
            var handle = job.Schedule(this);

            handle.Complete();

            Entities.ForEach((Entity entity, ref Infection infection) =>
            {
                var rendererMesh = EntityManager.GetSharedComponentData <RenderMesh>(entity);
                if (infection.infectionTime > 0.2f)
                {
                    PostUpdateCommands.SetSharedComponent(entity, new RenderMesh()
                    {
                        material = Materails.Instance.infected,
                        mesh     = rendererMesh.mesh
                    });
                }
                else
                {
                    if (infection.reverseImmunity < 1f)
                    {
                        PostUpdateCommands.SetSharedComponent(entity, new RenderMesh()
                        {
                            material = Materails.Instance.immune,
                            mesh     = rendererMesh.mesh
                        });
                    }
                    else
                    {
                        PostUpdateCommands.SetSharedComponent(entity, new RenderMesh()
                        {
                            material = Materails.Instance.notInfected,
                            mesh     = rendererMesh.mesh
                        });
                    }
                }
            });
        }
Example #18
0
 // 敵の生成
 void SpawnBullet(ref Position pos, ref BarrageSettings_CircularBullet settings)
 {
     for (int i = 0; i < settings.BulletCount; ++i)
     {
         PostUpdateCommands.CreateEntity(MainECS_Manager.EnemyBulletArchetype);
         PostUpdateCommands.SetComponent(pos);
         PostUpdateCommands.SetComponent(
             new BulletData
         {
             ShotSpeed = settings.CommonBarrageSettings.ShotSpeed,
             ShotAngle = (i / (float)settings.BulletCount) * 360f,
             Lifespan  = settings.CommonBarrageSettings.Lifespan
         });
         PostUpdateCommands.SetSharedComponent(MainECS_Manager.EnemyBulletLook);
         PostUpdateCommands.SetSharedComponent(MainECS_Manager.BulletCollision);
     }
 }
Example #19
0
    void fireProjectile(MovementComponent movementComponent, Translation translation, float3 directionToPlayer)
    {
        Vector2 dirNormalize;

        dirNormalize.x = directionToPlayer.x;
        dirNormalize.y = directionToPlayer.y;
        dirNormalize.Normalize();

        directionToPlayer.x = dirNormalize.x;
        directionToPlayer.y = dirNormalize.y;

        Entity e = PostUpdateCommands.CreateEntity(ProjectileBehaviour.GetArchetype());

        PostUpdateCommands.SetComponent(e, new ProjectileStatsComponent
        {
            SpeedModifier = 10f,
            Alive         = true,
            IsFromPlayer  = true,
            Direction     = directionToPlayer
        });
        PostUpdateCommands.SetComponent(e, new MovementComponent
        {
            currMovementDirection = movementComponent.currMovementDirection
        });
        PostUpdateCommands.SetComponent(e, new Translation
        {
            Value = translation.Value
        });
        PostUpdateCommands.SetComponent(e, new Scale
        {
            Value = 0.4f
        });
        PostUpdateCommands.SetComponent(e, new ColliderComponent
        {
            Size = .2f
        });
        PostUpdateCommands.SetSharedComponent(e, new RenderMesh
        {
            mesh     = GlobalObjects.mesh,
            material = GlobalObjects.material
        });

        projectileFired = true;
    }
Example #20
0
        // 敵の生成
        void SpawnBullet(ref Position pos, ref BarrageSettings_DirectionBullet settings)
        {
            if (this._playerGroup.Position.Length <= 0)
            {
                return;
            }

            PostUpdateCommands.CreateEntity(MainECS_Manager.EnemyBulletArchetype);
            PostUpdateCommands.SetComponent(pos);
            PostUpdateCommands.SetComponent(
                new BulletData
            {
                ShotSpeed = settings.CommonBarrageSettings.ShotSpeed,
                ShotAngle = this.Aiming(pos.Value, this._playerGroup.Position[0].Value),
                Lifespan  = settings.CommonBarrageSettings.Lifespan
            });
            PostUpdateCommands.SetSharedComponent(MainECS_Manager.EnemyBulletLook);
            PostUpdateCommands.SetSharedComponent(MainECS_Manager.BulletCollision);
        }
        /// <summary>
        /// Needs player rotation to calculate forward vector.
        /// </summary>
        void CreateNewLaserBeam(float3 playerPosition, quaternion playerRotation)
        {
            // forward vector points backwards because the spaceship is by default rotate by 180 degrees on the Z axis
            float3 forwardVector = math.mul(playerRotation, new float3(0, -1, 0));
            Entity entity        = PostUpdateCommands.CreateEntity(GameEngine.LaserBeamArchetype);

            PostUpdateCommands.SetSharedComponent(
                entity,
                new RenderMesh
            {
                mesh     = GameEngine.Instance.QuadMesh,
                material = GameEngine.Instance.LaserBeamMaterial
            });

            PostUpdateCommands.SetComponent(
                entity,
                new Translation {
                Value = playerPosition + forwardVector / 2
            });                                                                  // spawn it a bit at the front of player

            PostUpdateCommands.SetComponent(entity, new Scale {
                Value = 0.3f
            });

            PostUpdateCommands.SetComponent(
                entity,
                new MoveSpeedData
            {
                DirectionX = forwardVector.x,
                DirectionY = forwardVector.y,
                MoveSpeed  = GameEngine.LaserSpeed
            });

            PostUpdateCommands.SetComponent(
                entity,
                new CollisionTypeData {
                CollisionObjectType = CollisionType.Laser
            });

            PostUpdateCommands.SetComponent(entity, new TimeToDieData {
                Time = GameEngine.LaserLiveLength
            });
        }
Example #22
0
    private void createBreakeable()
    {
        GameObject    GameConstantsObject = GameObject.Find("GameConstants");
        GameConstants _constants          = GameConstantsObject.GetComponent <GameConstants>();

        string entityName = "breakeable";

        PostUpdateCommands.CreateEntity(ArchetypeFactory.Instance.getArchetypeByName(entityName));

        PostUpdateCommands.SetComponent(new BreakComponent
        {
            coolDown = _constants.breakTimeInSeconds,
            started  = 0
        });

        MeshInstanceRenderer renderer = EntityLookFactory.Instance.getLook(entityName);

        PostUpdateCommands.SetComponent(EntityFactory.getColliderInfo(renderer));
        PostUpdateCommands.SetSharedComponent(renderer);
    }
Example #23
0
    private void SpawnRocket(int i)
    {
        Entity rocketEntity = PostUpdateCommands.CreateEntity(RocketArchetype);

        PostUpdateCommands.SetComponent(rocketEntity, new Translation {
            Value = new float3(m_rocketDockGroup.RocketDocks[i].Value)
        });
        PostUpdateCommands.SetComponent(rocketEntity, new Rotation {
            Value = quaternion.identity
        });
        PostUpdateCommands.SetComponent(rocketEntity, new ObjectSpeed {
            Value = GameManager.instance.RocketSpeed
        });
        PostUpdateCommands.SetComponent(rocketEntity, new RocketProximityState {
            Value = 0
        });
        PostUpdateCommands.SetComponent(rocketEntity, new RocketCollision {
            Height = 1.5f, Radius = 0.2f
        });
        PostUpdateCommands.SetSharedComponent(rocketEntity, RocketRenderData);
    }
Example #24
0
    void Shoot(float3 enemyPos, float3 playerPos)
    {
        float3  directionToPlayer = playerPos - enemyPos;
        Vector2 dirNormalize;

        dirNormalize.x = directionToPlayer.x;
        dirNormalize.y = directionToPlayer.y;
        dirNormalize.Normalize();

        directionToPlayer.x = dirNormalize.x;
        directionToPlayer.y = dirNormalize.y;

        Entity e = PostUpdateCommands.CreateEntity(ProjectileBehaviour.GetArchetype());

        PostUpdateCommands.SetComponent(e, new ProjectileStatsComponent
        {
            SpeedModifier = 10f,
            Alive         = true,
            IsFromPlayer  = false,
            Direction     = directionToPlayer
        });

        PostUpdateCommands.SetComponent(e, new Translation
        {
            Value = enemyPos
        });
        PostUpdateCommands.SetComponent(e, new Scale
        {
            Value = 0.4f
        });
        PostUpdateCommands.SetComponent(e, new ColliderComponent
        {
            Size = .2f
        });
        PostUpdateCommands.SetSharedComponent(e, new RenderMesh
        {
            mesh     = GlobalObjects.mesh,
            material = GlobalObjects.material
        });
    }
    protected override void OnUpdate()
    {
        var overlappingComponents = GetComponentDataFromEntity <OverlappingTriggerVolume>();

        using (var overlappingEntities = m_OverlappingGroup.ToEntityArray(Allocator.TempJob))
        {
            foreach (var entity in overlappingEntities)
            {
                var overlapComponent = overlappingComponents[entity];
                if (overlapComponent.HasJustEntered)
                {
                    var volumeEntity = overlapComponent.VolumeEntity;

                    var volumeRenderMesh      = EntityManager.GetSharedComponentData <RenderMesh>(volumeEntity);
                    var overlappingRenderMesh = EntityManager.GetSharedComponentData <RenderMesh>(entity);
                    overlappingRenderMesh.material = volumeRenderMesh.material;

                    PostUpdateCommands.SetSharedComponent <RenderMesh>(entity, overlappingRenderMesh);
                }
            }
        }
    }
Example #26
0
    private void createZigZag()
    {
        GameObject    GameConstantsObject = GameObject.Find("GameConstants");
        GameConstants _constants          = GameConstantsObject.GetComponent <GameConstants>();

        string entityName = "zigzag";

        PostUpdateCommands.CreateEntity(ArchetypeFactory.Instance.getArchetypeByName(entityName));

        PostUpdateCommands.SetComponent(new ZigZagMoveable
        {
            Amplitude       = _constants.MoveableBlockAmplitude * _constants.blockSize,
            Speed           = _constants.MoveableBlockSpeed,
            CurrentPosition = 0,
            Direction       = 1
        });

        MeshInstanceRenderer renderer = EntityLookFactory.Instance.getLook(entityName);

        PostUpdateCommands.SetComponent(EntityFactory.getColliderInfo(renderer));
        PostUpdateCommands.SetSharedComponent(renderer);
    }
    void SpawnEntity()
    {
        var state    = m_State.S[0];
        var oldState = Random.state;

        Random.state = state.RandomState;

        state.SpawnedEntitiesCount++;

        PostUpdateCommands.CreateEntity(Bootstrap.MovableArchetype);

        var Heading = ComputeHeading();
        var Speed   = ComputeSpeed();

        PostUpdateCommands.SetComponent(new Position {
            Value = Heading * (Speed + 8)
        });

        var massColor = Random.Range(0, Bootstrap.cubeRenderData.Materials.Value.Length);


        PostUpdateCommands.SetSharedComponent(new MeshInstanceRenderer {
            mesh     = Bootstrap.cubeRenderData.Mesh.Value,
            material = Bootstrap.cubeRenderData.Materials.Value[massColor]
        });

        PostUpdateCommands.SetComponent(new Mass {
            Value = massColor + 1f
        });
        PostUpdateCommands.SetComponent(new Velocity {
            Value = Heading * (massColor + 8f)
        });

        state.RandomState = Random.state;

        m_State.S[0] = state;
        Random.state = oldState;
    }
        void CreateEntity()
        {
            var scale     = Bootstrap.Boid.scale;
            var initSpeed = Bootstrap.Param.initSpeed;

            PostUpdateCommands.CreateEntity(archetype);
            PostUpdateCommands.SetComponent(new Position {
                Value = random.NextFloat3(1f)
            });
            PostUpdateCommands.SetComponent(new Rotation {
                Value = quaternion.identity
            });
            PostUpdateCommands.SetComponent(new Scale {
                Value = new float3(scale.x, scale.y, scale.z)
            });
            PostUpdateCommands.SetComponent(new Velocity {
                Value = random.NextFloat3Direction() * initSpeed
            });
            PostUpdateCommands.SetComponent(new Acceleration {
                Value = float3.zero
            });
            PostUpdateCommands.SetSharedComponent(renderer);
        }
        protected override void OnUpdate()
        {
            var mapConfig          = ProgramConfig.config.mapConfigs[0];
            var groundConfigs      = mapConfig.groundTypes;
            var groundConfigsCount = groundConfigs.Length;
            var itemsConfigs       = mapConfig.mapItems;
            var itemsConfigsCount  = itemsConfigs.Length;

            for (int i = 0; i < chunkGroup.Length; i++)
            {
                var chunkEntity = chunkGroup.entity[i];
                PostUpdateCommands.RemoveComponent <GenerateMapRequest>(chunkEntity);

                var request = chunkGroup.request[i];
                var chunk   = chunkGroup.chunk[i];

                var chunkSize     = chunk.size;
                var cellsCount    = chunkSize.x * chunkSize.y;
                var chunkPosition = chunk.position;
                var noiseScale    = request.noiseScale;
                var gridSize      = chunkSize;
                var mapHeight     = 255;
                var seaLevel      = request.seaLevel;

                // dispose old data
                var oldHeightmap     = chunkGroup.heightmap[i];
                var oldGroundmap     = chunkGroup.groundmap[i];
                var oldBordermap     = chunkGroup.bordermap[i];
                var oldWatermap      = chunkGroup.watermap[i];
                var oldItemsmap      = chunkGroup.itemsmap[i];
                var oldTransformsmap = chunkGroup.itemsTransformmap[i];

                if (oldHeightmap.height10.IsCreated)
                {
                    oldHeightmap.height10.Dispose();
                }
                if (oldHeightmap.height00.IsCreated)
                {
                    oldHeightmap.height00.Dispose();
                }
                if (oldHeightmap.height01.IsCreated)
                {
                    oldHeightmap.height01.Dispose();
                }
                if (oldHeightmap.height11.IsCreated)
                {
                    oldHeightmap.height11.Dispose();
                }
                if (oldHeightmap.center.IsCreated)
                {
                    oldHeightmap.center.Dispose();
                }

                if (oldWatermap.height00.IsCreated)
                {
                    oldWatermap.height00.Dispose();
                }
                if (oldWatermap.height01.IsCreated)
                {
                    oldWatermap.height01.Dispose();
                }
                if (oldWatermap.height11.IsCreated)
                {
                    oldWatermap.height11.Dispose();
                }
                if (oldWatermap.height10.IsCreated)
                {
                    oldWatermap.height10.Dispose();
                }
                if (oldWatermap.center.IsCreated)
                {
                    oldWatermap.center.Dispose();
                }

                if (oldGroundmap.west.IsCreated)
                {
                    oldGroundmap.west.Dispose();
                }
                if (oldGroundmap.north.IsCreated)
                {
                    oldGroundmap.north.Dispose();
                }
                if (oldGroundmap.east.IsCreated)
                {
                    oldGroundmap.east.Dispose();
                }
                if (oldGroundmap.south.IsCreated)
                {
                    oldGroundmap.south.Dispose();
                }

                if (oldBordermap.west.IsCreated)
                {
                    oldBordermap.west.Dispose();
                }
                if (oldBordermap.north.IsCreated)
                {
                    oldBordermap.north.Dispose();
                }
                if (oldBordermap.east.IsCreated)
                {
                    oldBordermap.east.Dispose();
                }
                if (oldBordermap.south.IsCreated)
                {
                    oldBordermap.south.Dispose();
                }

                if (oldItemsmap.value.IsCreated)
                {
                    oldItemsmap.value.Dispose();
                }

                if (oldTransformsmap.matrix.IsCreated)
                {
                    oldTransformsmap.matrix.Dispose();
                }
                if (oldTransformsmap.position.IsCreated)
                {
                    oldTransformsmap.position.Dispose();
                }
                if (oldTransformsmap.rotation.IsCreated)
                {
                    oldTransformsmap.rotation.Dispose();
                }
                if (oldTransformsmap.scale.IsCreated)
                {
                    oldTransformsmap.scale.Dispose();
                }

                // create new data
                var heightmap = new Heightmap
                {
                    height01 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    height10 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    height00 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    height11 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    center   = new NativeArray <float>(cellsCount, Allocator.Persistent),
                };
                var watermap = new Watermap
                {
                    height11 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    height00 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    height01 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    height10 = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    center   = new NativeArray <float>(cellsCount, Allocator.Persistent),
                };
                var bordermap = new Bordermap
                {
                    east  = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    west  = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    north = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    south = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                };
                var groundmap = new Groundmap
                {
                    east  = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    west  = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    north = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                    south = new NativeArray <byte>(cellsCount, Allocator.Persistent),
                };
                var itemsmap = new Itemsmap
                {
                    value = new NativeArray <int>(cellsCount, Allocator.Persistent),
                };
                var itemsTransformmap = new ItemsTransformmap
                {
                    position = new NativeArray <float3>(cellsCount, Allocator.Persistent),
                    rotation = new NativeArray <float3>(cellsCount, Allocator.Persistent),
                    scale    = new NativeArray <float3>(cellsCount, Allocator.Persistent),
                    matrix   = new NativeArray <Matrix4x4>(cellsCount, Allocator.Persistent),
                };

                // fill data with values
                for (int y = 0; y < chunkSize.y; y++)
                {
                    for (int x = 0; x < chunkSize.x; x++)
                    {
                        var coord     = new int2(x, y) + chunkPosition;
                        var cellIndex = y * gridSize.x + x;

                        // set heights
                        float fHeight00 = seaLevel + 2;
                        float fHeight01 = seaLevel + 2;
                        float fHeight11 = seaLevel + 2;
                        float fHeight10 = seaLevel + 2;

                        if (request.isFlatMap != Booleans.True)
                        {
                            var noiseSeed00   = new float2(coord.x * noiseScale.x, coord.y * noiseScale.y) + new float2(0f, 0f);
                            var noiseResult00 = noise.cnoise(noiseSeed00);
                            var noiseSeed01   = new float2(coord.x * noiseScale.x, coord.y * noiseScale.y) + new float2(0f, noiseScale.y / 2f);
                            var noiseResult01 = noise.cnoise(noiseSeed01);
                            var noiseSeed11   = new float2(coord.x * noiseScale.x, coord.y * noiseScale.y) + new float2(noiseScale.x / 2f, noiseScale.y / 2f);
                            var noiseResult11 = noise.cnoise(noiseSeed11);
                            var noiseSeed10   = new float2(coord.x * noiseScale.x, coord.y * noiseScale.y) + new float2(noiseScale.x / 2f, 0f);
                            var noiseResult10 = noise.cnoise(noiseSeed10);

                            fHeight00 = noiseResult00 * mapHeight / 2f + mapHeight / 2f;
                            fHeight01 = noiseResult01 * mapHeight / 2f + mapHeight / 2f;
                            fHeight11 = noiseResult11 * mapHeight / 2f + mapHeight / 2f;
                            fHeight10 = noiseResult10 * mapHeight / 2f + mapHeight / 2f;
                        }

                        float fHeightCenter = (fHeight00 + fHeight11 + fHeight01 + fHeight10) / 4f;
                        float minHeight     = math.min(fHeight00, math.min(fHeight01, math.min(fHeight10, fHeight11)));

                        heightmap.height00[cellIndex] = (byte)fHeight00;
                        heightmap.height01[cellIndex] = (byte)fHeight01;
                        heightmap.height11[cellIndex] = (byte)fHeight11;
                        heightmap.height10[cellIndex] = (byte)fHeight10;
                        heightmap.center[cellIndex]   = fHeightCenter;

                        // set water
                        float wHeight00 = math.max(0, seaLevel - fHeight00);
                        float wHeight01 = math.max(0, seaLevel - fHeight01);
                        float wHeight11 = math.max(0, seaLevel - fHeight11);
                        float wHeight10 = math.max(0, seaLevel - fHeight10);

                        watermap.height01[cellIndex] = (byte)fHeight00;
                        watermap.height11[cellIndex] = (byte)fHeight01;
                        watermap.height10[cellIndex] = (byte)fHeight11;
                        watermap.height00[cellIndex] = (byte)fHeight10;

                        // set ground id
                        var groundIdNorth = Random.Range(0, groundConfigsCount);
                        var groundIdEast  = Random.Range(0, groundConfigsCount);
                        var groundIdSouth = Random.Range(0, groundConfigsCount);
                        var groundIdWest  = Random.Range(0, groundConfigsCount);

                        groundmap.north[cellIndex] = (byte)groundIdNorth;
                        groundmap.east[cellIndex]  = (byte)groundIdEast;
                        groundmap.south[cellIndex] = (byte)groundIdSouth;
                        groundmap.west[cellIndex]  = (byte)groundIdWest;

                        // set borders
                        byte borderIdNorth = 0;
                        byte borderIdEast  = 0;
                        byte borderIdSouth = 0;
                        byte borderIdWest  = 0;

                        bordermap.north[cellIndex] = borderIdNorth;
                        bordermap.south[cellIndex] = borderIdSouth;
                        bordermap.east[cellIndex]  = borderIdEast;
                        bordermap.west[cellIndex]  = borderIdWest;

                        // set item
                        var itemId = 0;
                        if (minHeight > seaLevel)
                        {
                            if (Random.Range(0, 100) < 30)
                            {
                                itemId = Random.Range(0, itemsConfigsCount) + 1; // item can't be 0, cause 0 means no item
                                itemsmap.value[cellIndex] = itemId;

                                // set item transform
                                itemsTransformmap.position[cellIndex] = new float3();
                                itemsTransformmap.rotation[cellIndex] = new float3();
                                itemsTransformmap.scale[cellIndex]    = new float3();
                                itemsTransformmap.matrix[cellIndex]   = Matrix4x4.identity;
                            }
                        }
                    }
                }

                // save data
                PostUpdateCommands.SetSharedComponent(chunkEntity, heightmap);
                PostUpdateCommands.SetSharedComponent(chunkEntity, watermap);
                PostUpdateCommands.SetSharedComponent(chunkEntity, groundmap);
                PostUpdateCommands.SetSharedComponent(chunkEntity, bordermap);
                PostUpdateCommands.SetSharedComponent(chunkEntity, itemsmap);
                PostUpdateCommands.SetSharedComponent(chunkEntity, itemsTransformmap);

                // mark as dirty
                if (EntityManager.HasComponent <GroundmeshDirty>(chunkEntity))
                {
                    PostUpdateCommands.AddComponent(chunkEntity, new GroundmeshDirty {
                    });
                }
                if (EntityManager.HasComponent <WatermeshDirty>(chunkEntity))
                {
                    PostUpdateCommands.AddComponent(chunkEntity, new WatermeshDirty {
                    });
                }
                if (EntityManager.HasComponent <BordermeshDirty>(chunkEntity))
                {
                    PostUpdateCommands.AddComponent(chunkEntity, new BordermeshDirty {
                    });
                }
                if (EntityManager.HasComponent <ItemsTransformsDirty>(chunkEntity))
                {
                    PostUpdateCommands.AddComponent(chunkEntity, new ItemsTransformsDirty {
                    });
                }
            }
        }
Example #30
0
        protected override void OnUpdate()
        {
            var entities = m_ComponentGroup.ToEntityArray(Allocator.TempJob);
            List <SpriteSkin>      spriteSkinComponents = new List <SpriteSkin>();
            List <SpriteComponent> spriteComponents     = new List <SpriteComponent>();

            Entities.ForEach((SpriteSkin spriteSkin) => { spriteSkinComponents.Add(spriteSkin); });
            Entities.ForEach((SpriteComponent sprite) => { spriteComponents.Add(sprite); });
            var worldToLocalComponents = m_ComponentGroup.ToComponentDataArray <WorldToLocal>(Allocator.TempJob);

            for (var i = 0; i < entities.Length; ++i)
            {
                var    vertexBuffer        = EntityManager.GetBuffer <Vertex>(entities[i]);
                var    boneTransformBuffer = EntityManager.GetBuffer <BoneTransform>(entities[i]);
                var    currentSprite       = spriteComponents[i].Value;
                var    currentWorldToLocal = worldToLocalComponents[i];
                Sprite sprite     = null;
                var    entity     = entities[i];
                var    spriteSkin = spriteSkinComponents[i];

                if (spriteSkin == null)
                {
                    continue;
                }

                var spriteRenderer = spriteSkin.spriteRenderer;
                var isValid        = spriteRenderer.enabled && spriteSkin.isValid;
                var isVisible      = spriteRenderer.isVisible || spriteSkin.ForceSkinning;

                if (!isValid)
                {
                    SpriteRendererDataAccessExtensions.DeactivateDeformableBuffer(spriteRenderer);
                }
                else if (isVisible)
                {
                    spriteSkin.ForceSkinning = false;
                    sprite = spriteRenderer.sprite;
                    float4x4 worldToLocal = spriteSkin.transform.worldToLocalMatrix;

                    if (vertexBuffer.Length != sprite.GetVertexCount())
                    {
                        vertexBuffer = PostUpdateCommands.SetBuffer <Vertex>(entity);
                        vertexBuffer.ResizeUninitialized(sprite.GetVertexCount());
                    }

                    InternalEngineBridge.SetDeformableBuffer(spriteRenderer, vertexBuffer.Reinterpret <Vector3>().AsNativeArray());

                    if (boneTransformBuffer.Length != spriteSkin.boneTransforms.Length)
                    {
                        boneTransformBuffer = PostUpdateCommands.SetBuffer <BoneTransform>(entity);
                        boneTransformBuffer.ResizeUninitialized(spriteSkin.boneTransforms.Length);
                    }

                    for (var j = 0; j < boneTransformBuffer.Length; ++j)
                    {
                        boneTransformBuffer[j] = new BoneTransform()
                        {
                            Value = spriteSkin.boneTransforms[j].localToWorldMatrix
                        }
                    }
                    ;

                    PostUpdateCommands.SetComponent <WorldToLocal>(entity, new WorldToLocal()
                    {
                        Value = worldToLocal
                    });
                }

                if (currentSprite != sprite)
                {
                    PostUpdateCommands.SetSharedComponent <SpriteComponent>(entity, new SpriteComponent()
                    {
                        Value = sprite
                    });
                }

                if (!spriteRenderer.enabled)
                {
                    spriteSkin.ForceSkinning = true;
                }
            }

            entities.Dispose();
            worldToLocalComponents.Dispose();
        }
    }