protected override void OnUpdate() { HighlightCellPrefab highlightPrefab = GetSingleton <HighlightCellPrefab>(); EntityCommandBuffer ecb = barrier.CreateCommandBuffer(); NativeArray <Entity> highlightedCells = HighlightCell.List(); Entities .WithoutBurst() .ForEach(( Entity entity, in HexCoordinates coordinates, in CommandRemoveHighlight commandRemoveHighlight ) => { foreach (var highlightedCell in highlightedCells) { HexCoordinates highlightedCoordinates = EntityManager.GetComponentData <HexCoordinates>(highlightedCell); if (coordinates == highlightedCoordinates) { ecb.DestroyEntity(highlightedCell); } } ecb.DestroyEntity(entity); }).Run();
public static void Create(EntityCommandBuffer ecb, HighlightCellPrefab highlightPrefab, HexCoordinates coordinates) { Entity highlight = ecb.Instantiate(highlightPrefab.Value); float3 position = HexCellService.GetTranslationComponentByHexCoordinates(coordinates); ecb.SetComponent <Translation>(highlight, new Translation { Value = position }); ecb.AddComponent <HexCoordinates>(highlight, coordinates); ecb.AddComponent <HighlightTag>(highlight, new HighlightTag { }); }
protected override void OnUpdate() { HighlightCellPrefab highlightPrefab = GetSingleton <HighlightCellPrefab>(); EntityCommandBuffer ecb = barrier.CreateCommandBuffer(); Entities .WithoutBurst() .ForEach(( Entity entity, in CommandCreateHighlight commandCreateHighlight, in HexCoordinates coordinates ) => { HighlightCell.Create(ecb, highlightPrefab, coordinates); ecb.DestroyEntity(entity); }).Run();