JobHandle ProcessViewEntities(bool mapRegenerated, DynamicBuffer <MapTiles> map, MapData mapData, JobHandle inputDeps)
        {
            // Process Entities with only a view and no memory
            return(Entities
                   .WithReadOnly(map)
                   .WithChangeFilter <Position>()
                   .WithNone <TilesInMemory>()
                   .ForEach((ref DynamicBuffer <TilesInView> view, in Position pos, in ViewRange range) =>
            {
                if (view.Length != map.Length || mapRegenerated)
                {
                    view.ResizeUninitialized(map.Length);
                }

                // Always reset view before rebuilding
                for (int i = 0; i < view.Length; ++i)
                {
                    view[i] = false;
                }

                var visibility = new VisibilityMap(
                    mapData.width,
                    mapData.height,
                    map.Reinterpret <TileType>().AsNativeArray(),
                    view.Reinterpret <bool>().AsNativeArray()
                    );

                FOV.Compute(pos, range, visibility);
            }).Schedule(inputDeps));
Ejemplo n.º 2
0
 public static int PosToIndex(int2 p, MapData mapData) => p.y * mapData.width + p.x;
Ejemplo n.º 3
0
 public void OnFrameBegin()
 {
     _mapEntity = _mapQuery.GetSingletonEntity();
     _map       = EntityManager.GetBuffer <MapTiles>(_mapEntity);
     _mapData   = EntityManager.GetComponentData <MapData>(_mapEntity);
 }