public void Execute <TCtx>(TCtx ctx) where TCtx : IGraphInstance { var entity = ctx.ReadEntity(GameObject); if (entity != Entity.Null) { if (ctx.EntityManager.HasComponent <NonUniformScale>(entity)) { NonUniformScale t = ctx.EntityManager.GetComponentData <NonUniformScale>(entity); ctx.Write(Value, t.Value); } else if (ctx.EntityManager.HasComponent <Scale>(entity)) { Scale t = ctx.EntityManager.GetComponentData <Scale>(entity); ctx.Write(Value, new float3(t.Value, t.Value, t.Value)); } else if (ctx.EntityManager.HasComponent <CompositeScale>(entity)) { CompositeScale compositeScale = ctx.EntityManager.GetComponentData <CompositeScale>(entity); float4x4 floatMatrix = compositeScale.Value; ctx.Write(Value, new float3(floatMatrix.c0.x, floatMatrix.c1.y, floatMatrix.c2.z)); } else { ctx.Write(Value, new float3(1, 1, 1)); } } }
private void DealWithOrdinaryBrick(PlayerStates playerStates, Entity headedBlock, MovableBlockStates movableBlockStates, EntityCommandBuffer commandBuffer, float3 position) { if (playerStates.Level == PlayerLevel.Default) { EntityManager.SetComponentData(headedBlock, movableBlockStates); return; } var scoreData = GetComponentDataFromEntity<ScoreData>()[headedBlock]; commandBuffer.DestroyEntity(headedBlock); GameEntry.Instance.PlayerData.AddScores(scoreData.BaseScore, position, AddScoreType.OrdinaryBrick); var brickFragmentsGeneratorQuery = GetEntityQuery(typeof(BrickFragmentsGeneratorData)); var brickFragmentsGeneratorData = brickFragmentsGeneratorQuery.GetSingleton<BrickFragmentsGeneratorData>(); var config = GameEntry.Instance.Config.Global.BrickFragments; for (int i = 0; i < BrickFragmentCount; i++) { var brickFragmentEntity = EntityManager.Instantiate(brickFragmentsGeneratorData.PrefabEntity); var prefabPosition = GetComponentDataFromEntity<Translation>()[brickFragmentsGeneratorData.PrefabEntity].Value; var prefabScale = brickFragmentsGeneratorData.PrefabEntity.GetScale(GetComponentDataFromEntity<CompositeScale>(), GetComponentDataFromEntity<Scale>()); EntityManager.SetComponentData(brickFragmentEntity, new Translation { Value = new float3(position.x + config.OffsetXs[i], position.y + config.OffsetYs[i], prefabPosition.z), }); EntityManager.SetComponentData(brickFragmentEntity, new MovementData { Velocity = new float3(config.HorizontalVelocities[i], config.VerticalVelocities[i], 0), }); var compositeScale = new CompositeScale { Value = MathUtility.ScaleToMatrix(new float3(config.ScaleXs[i] * prefabScale.x, prefabScale.y, prefabScale.z)), }; if (GetComponentDataFromEntity<CompositeScale>().HasComponent(brickFragmentEntity)) { EntityManager.SetComponentData(brickFragmentEntity, compositeScale); } else { EntityManager.AddComponentData(brickFragmentEntity, compositeScale); } } }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { GameObjectConversionSettings settings = GameObjectConversionSettings.FromWorld(dstManager.World, conversionSystem.BlobAssetStore); Entity brickPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(m_brick.gameObject, settings); float3 startingPos = startingPosition.position; CompositeScale scale = dstManager.GetComponentData <CompositeScale>(brickPrefab); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Entity brick = dstManager.Instantiate(brickPrefab); dstManager.SetComponentData <Translation>(brick, new Translation() { Value = startingPos + new float3(i * 1.5f, j * 0.75f, 0) }); } } }