예제 #1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var damageHandle = new DamageJob
            {
                Chunks                  = this._healthGroup.CreateArchetypeChunkArray(Allocator.TempJob),
                EntityType              = this.GetArchetypeChunkEntityType(),
                HealthComponentType     = this.GetArchetypeChunkComponentType <HealthComponent>(),
                InCutsceneComponentType = this.GetArchetypeChunkComponentType <InCutsceneComponent>()
            }.Schedule(this, inputDeps);

            var cleanUphandle = new CleanUpJob
            {
                CommandBuffer = this._endFrameBarrier.CreateCommandBuffer().ToConcurrent(),
            }.Schedule(this, damageHandle);

            this._endFrameBarrier.AddJobHandleForProducer(cleanUphandle);
            return(cleanUphandle);
        }
예제 #2
0
        static void Main(string[] args)
        {
            // Disbale useTheading when debuging
            bool useThreading =
#if DEBUG
                false;
#else
                true;
#endif
            // Init site information DB repository
            string connectionString = ConfigurationManager.ConnectionStrings["default"].ConnectionString;
            var    dbRepository     = new GovernanceDbRepository(connectionString);

            // Step thru each SharePoint site collection,
            // synchronize the latest status to site information DB
            var syncJob = new SynchronizationJob(dbRepository, TenantUrl);
            syncJob.UseThreading = useThreading;
            syncJob.SetEnumerationCredentials(User, Password);
            syncJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            syncJob.Run();

            // Step thru each site information DB record,
            // delete all out-dated ones, of which the related SharePoint site collection has been deleted
            var cleanupJob = new CleanUpJob(dbRepository, TenantUrl);
            cleanupJob.UseThreading = useThreading;
            cleanupJob.SetEnumerationCredentials(User, Password);
            cleanupJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            cleanupJob.Run();

            // Detect broadly accessible HBI webs and log large security group information in DB repository
            var hbiBroadAccessJob = new GovernancePreprocessJob(dbRepository, TenantUrl, new HbiBroadAccessPolicy());
            hbiBroadAccessJob.UseThreading = useThreading;
            hbiBroadAccessJob.SetEnumerationCredentials(User, Password);
            hbiBroadAccessJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            hbiBroadAccessJob.Run();

            // Query all incomlpiant site information records based on the governance policies checking logic (defined in ISitePolicy.NoncompliancePredictor),
            // then run the enforcement logic for each site.
            var governanceJob = new GovernanceJob(dbRepository, TenantUrl);
            governanceJob.UseThreading = useThreading;
            governanceJob.SetEnumerationCredentials(User, Password);
            governanceJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            governanceJob.Run();
        }
예제 #3
0
파일: Program.cs 프로젝트: Calisto1980/PnP
        static void Main(string[] args)
        {
            // Disbale useTheading when debuging
            bool useThreading = 
#if DEBUG
                false;
#else
                true;
#endif
            // Init site information DB repository
            string connectionString = ConfigurationManager.ConnectionStrings["default"].ConnectionString;
            var dbRepository = new GovernanceDbRepository(connectionString);

            // Step thru each SharePoint site collection,
            // synchronize the latest status to site information DB
            var syncJob = new SynchronizationJob(dbRepository, TenantUrl);
            syncJob.UseThreading = useThreading;
            syncJob.SetEnumerationCredentials(User, Password);
            syncJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            syncJob.Run();

            // Step thru each site information DB record,
            // delete all out-dated ones, of which the related SharePoint site collection has been deleted
            var cleanupJob = new CleanUpJob(dbRepository, TenantUrl);
            cleanupJob.UseThreading = useThreading;
            cleanupJob.SetEnumerationCredentials(User, Password);
            cleanupJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            cleanupJob.Run();

            // Detect broadly accessible HBI webs and log large security group information in DB repository
            var hbiBroadAccessJob = new GovernancePreprocessJob(dbRepository, TenantUrl, new HbiBroadAccessPolicy());
            hbiBroadAccessJob.UseThreading = useThreading;
            hbiBroadAccessJob.SetEnumerationCredentials(User, Password);
            hbiBroadAccessJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            hbiBroadAccessJob.Run();

            // Query all incomlpiant site information records based on the governance policies checking logic (defined in ISitePolicy.NoncompliancePredictor),
            // then run the enforcement logic for each site.
            var governanceJob = new GovernanceJob(dbRepository, TenantUrl);
            governanceJob.UseThreading = useThreading;
            governanceJob.SetEnumerationCredentials(User, Password);
            governanceJob.UseAppOnlyAuthentication(ClientId, ClientSecret);
            governanceJob.Run();
        }
예제 #4
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var boardChunks = this._boardGroup.CreateArchetypeChunkArray(Allocator.TempJob);

            for (var chunkIndex = 0; chunkIndex < boardChunks.Length; chunkIndex++)
            {
                var chunk         = boardChunks[chunkIndex];
                var boardEntities = chunk.GetNativeArray(this.GetArchetypeChunkEntityType());
                var boards        = chunk.GetNativeArray(this.GetArchetypeChunkComponentType <BoardComponent>());
                for (var i = 0; i < chunk.Count; i++)
                {
                    var board       = boards[i];
                    var boardEntity = boardEntities[i];
                    var random      = new Random(board.RandomSeed);

                    if (this.CurrentPhase == 0)
                    {
                        var roomCount = board.RoomCount;

                        this.Tiles          = new NativeArray <TileType>(board.Size.x * board.Size.y, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
                        this.RoomsQueue     = new NativeQueue <RoomComponent>(Allocator.TempJob);
                        this.CorridorsQueue = new NativeQueue <CorridorComponent>(Allocator.TempJob);
                        var firstCorridors = new NativeArray <CorridorComponent>(4, Allocator.TempJob);
                        for (var j = 0; j < this.Tiles.Length; j++)
                        {
                            this.Tiles[j] = TileType.Wall;
                        }

                        // setup fist room and corridors to all 4 directions
                        var firstRoom = CreateRoom(board, ref random);
                        this.RoomsQueue.Enqueue(firstRoom);
                        for (var c = 0; c < 4; c++)
                        {
                            firstCorridors[c] = this.CreateCorridor(firstRoom, board, ref random, c);
                            this.CorridorsQueue.Enqueue(firstCorridors[c]);
                        }

                        inputDeps = new CreateRoomsAndCorridorsJob
                        {
                            Board          = board,
                            Rooms          = this.RoomsQueue.AsParallelWriter(),
                            Corridors      = this.CorridorsQueue.AsParallelWriter(),
                            FirstCorridors = firstCorridors,
                            RoomCount      = roomCount / 4,
                            RandomSeed     = random.NextInt()
                        }.Schedule(4, 1, inputDeps);
                    }
                    else if (this.CurrentPhase == 1)
                    {
                        var roomsCount     = this.RoomsQueue.Count;
                        var corridorsCount = this.CorridorsQueue.Count;
                        var roomsArray     = new NativeArray <RoomComponent>(roomsCount, Allocator.TempJob);
                        var corridorsArray = new NativeArray <CorridorComponent>(corridorsCount, Allocator.TempJob);

                        var roomsQueueToArrayJobHandle = new RoomsQueueToArrayJob
                        {
                            RoomsQueue = this.RoomsQueue,
                            RoomsArray = roomsArray
                        }.Schedule(inputDeps);

                        var corridorsQueueToArrayJobHandle = new CorridorsQueueToArrayJob
                        {
                            CorridorsQueue = this.CorridorsQueue,
                            CorridorsArray = corridorsArray
                        }.Schedule(inputDeps);

                        var setRoomTilesJobHandle = new SetRoomTilesJob
                        {
                            Roms       = roomsArray,
                            Tiles      = Tiles,
                            TileStride = board.Size.x
                        }.Schedule(roomsCount, 1, roomsQueueToArrayJobHandle);

                        var setCorridorTilesJobHandle = new SetCorridorTilesJob
                        {
                            Corridors  = corridorsArray,
                            Tiles      = Tiles,
                            TileStride = board.Size.x
                        }.Schedule(corridorsCount, 1, corridorsQueueToArrayJobHandle);

                        var removeThinWallsJobHandle = new RemoveThinWallsJob
                        {
                            Board = board,
                            Tiles = Tiles
                        }.Schedule(JobHandle.CombineDependencies(setRoomTilesJobHandle, setCorridorTilesJobHandle));

                        inputDeps = new CloseBordersJob
                        {
                            Board = board,
                            Tiles = Tiles
                        }.Schedule(removeThinWallsJobHandle);
                    }
                    else if (this.CurrentPhase == 2)
                    {
                        this.CorridorsQueue.Dispose();
                        this.RoomsQueue.Dispose();

                        inputDeps = new TagBoardDoneJob
                        {
                            CommandBuffer  = this._endFrameBarrier.CreateCommandBuffer(),
                            BoardEntity    = boardEntity,
                            Tiles          = Tiles,
                            BoardComponent = board,
                            TileStride     = board.Size.x,
                            RandomSeed     = random.NextInt()
                        }.Schedule(inputDeps);
                        this._endFrameBarrier.AddJobHandleForProducer(inputDeps);
                    }
                }
            }
            this.CurrentPhase = (this.CurrentPhase + 1) % 3;
            var cleanUpJobHandle = new CleanUpJob
            {
                Chunks = boardChunks
            }.Schedule(inputDeps);

            return(cleanUpJobHandle);
        }
예제 #5
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var boardChunks = this._boardGroup.CreateArchetypeChunkArray(Allocator.TempJob);

            for (var chunkIndex = 0; chunkIndex < boardChunks.Length; chunkIndex++)
            {
                var chunk         = boardChunks[chunkIndex];
                var boardEntities = chunk.GetNativeArray(this.GetArchetypeChunkEntityType());
                var boards        = chunk.GetNativeArray(this.GetArchetypeChunkComponentType <BoardComponent>());
                for (var i = 0; i < chunk.Count; i++)
                {
                    var board       = boards[i];
                    var boardEntity = boardEntities[i];
                    var random      = new Random(board.RandomSeed);
                    if (this.CurrentPhase == 0)
                    {
                        this.Tiles = new NativeArray <TileType>(board.Size.x * board.Size.y, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
                        for (var j = 0; j < this.Tiles.Length; j++)
                        {
                            this.Tiles[j] = TileType.Wall;
                        }

                        var bspTree = new BSPTree(board.Size.x, board.Size.y, board.MinRoomSize, ref random);
                        this.TreeArray      = bspTree.ToNativeArray();
                        this.CorridorsQueue = new NativeQueue <CorridorComponent>(Allocator.TempJob);
                        var concurrentQueue = this.CorridorsQueue.AsParallelWriter();

                        inputDeps = new CreateRoomsJob
                        {
                            TreeArray  = TreeArray,
                            RandomSeed = random.NextInt(),
                            Board      = board
                        }.Schedule(this.TreeArray.Length, 1, inputDeps);

                        for (var level = bspTree.Height - 1; level >= 0; level--)
                        {
                            var nodesAmount = (int)math.pow(2, level - 1);
                            inputDeps = new FindCorridorsForLevelJob
                            {
                                TreeArray  = TreeArray,
                                RandomSeed = random.NextInt(),
                                StartIndex = nodesAmount - 1,
                                Corridors  = concurrentQueue,
                            }.Schedule(nodesAmount, 1, inputDeps);
                        }
                    }
                    else if (this.CurrentPhase == 1)
                    {
                        var corridorsArray = new NativeArray <CorridorComponent>(this.CorridorsQueue.Count, Allocator.TempJob);

                        var corridorsQueueToArrayJobHandle = new CorridorsQueueToArrayJob
                        {
                            CorridorsArray = corridorsArray,
                            CorridorsQueue = this.CorridorsQueue
                        }.Schedule(inputDeps);

                        var createCorridorsJobHandle = new CreateCorridorsJob
                        {
                            Tiles      = Tiles,
                            Corridors  = corridorsArray,
                            TileStride = board.Size.x
                        }.Schedule(corridorsArray.Length, 1, corridorsQueueToArrayJobHandle);

                        var setRoomTilesJobHandle = new SetRoomTilesJob
                        {
                            TreeArray  = TreeArray,
                            Tiles      = Tiles,
                            TileStride = board.Size.x
                        }.Schedule(this.TreeArray.Length, 1, inputDeps);

                        inputDeps = new RemoveThinWallsJob
                        {
                            Board = board,
                            Tiles = Tiles
                        }.Schedule(JobHandle.CombineDependencies(setRoomTilesJobHandle, createCorridorsJobHandle));
                    }
                    else if (this.CurrentPhase == 2)
                    {
                        this.CorridorsQueue.Dispose();

                        inputDeps = new TagBoardDoneJob
                        {
                            CommandBuffer  = this._endFrameBarrier.CreateCommandBuffer(),
                            BoardEntity    = boardEntity,
                            BoardComponent = board,
                            TreeArray      = TreeArray,
                            Tiles          = Tiles,
                            RandomSeed     = random.NextInt()
                        }.Schedule(inputDeps);
                        this._endFrameBarrier.AddJobHandleForProducer(inputDeps);
                    }
                }
            }

            this.CurrentPhase = (this.CurrentPhase + 1) % 3;
            var cleanUpJobHandle = new CleanUpJob
            {
                Chunks = boardChunks
            }.Schedule(inputDeps);

            return(cleanUpJobHandle);
        }