protected override JobHandle OnUpdate(JobHandle inputDependencies) { LbBoard board = m_BoardQuery.GetSingleton <LbBoard>(); var sRand = new System.Random(); var job = new MovePlayerCursorJob { Seed = sRand.Next(int.MaxValue), Size = board.SizeY, CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent() }.Schedule(m_PlayerQuery, inputDependencies); m_EntityCommandBufferSystem.AddJobHandleForProducer(job); return(job); }
public void Execute() { var entity = CommandBuffer.CreateEntity(); CommandBuffer.AddComponent(entity, new LbMap()); var board = new LbBoard() { SizeX = Generator.SizeX, SizeY = Generator.SizeY, }; CommandBuffer.AddComponent(entity, board); var dirMapBuffer = CommandBuffer.AddBuffer <LbDirectionMap>(entity); for (int i = 0; i < DirectionMap.Length; ++i) { dirMapBuffer.Add(DirectionMap[i]); } var arrowDirbuffer = CommandBuffer.AddBuffer <LbArrowDirectionMap>(entity); for (int i = 0; i < Generator.SizeX * Generator.SizeY; ++i) { arrowDirbuffer.Add(new LbArrowDirectionMap()); } var catMapbuffer = CommandBuffer.AddBuffer <LbCatMap>(entity); var bitsInWord = sizeof(int) * 8; var bufferCountInWords = (Generator.SizeX * Generator.SizeY + (bitsInWord - 1)) / bitsInWord; for (int i = 0; i < bufferCountInWords; i++) { catMapbuffer.Add(new LbCatMap()); } }