private void Load(GrassPatch node) { UnityEngine.Profiling.Profiler.BeginSample("Load"); if (_jobDataPool.Count == 0) { Debug.LogError("JobData pool is empty (shouldn't happen)"); return; } JobData jobData = _jobDataPool.Dequeue(); node.JobData = jobData; node.SnowAltitude = _terrain.TerrainConfiguration.SnowAltitude; var job = _jobManager.CreateJob(node) .AddTask(_loadTerrainFunc, JobTaskType.AsyncIo) .AddTask(_generateMeshFunc, JobTaskType.Async) .AddTask(_completeMeshFunc, JobTaskType.UnityThread) .OnCancel(_onJobCanceled); var disposeJob = _jobManager.StartJob(job); node.RunningJob = disposeJob; node.State = NodeState.Loading; UnityEngine.Profiling.Profiler.EndSample(); }
public CommandResponse Handle(CommandRequest request) { if (string.IsNullOrEmpty(request.Target)) { return(CommandResponse.Create(false)); } var groupName = new StitchGroupName(request.Target); var job = _jobManager.CreateJob("Command=" + request.Command); var stitches = _data.GetStitchesInGroup(groupName); foreach (var stitch in stitches) { var subtask = job.CreateSubtask(CommandType, stitch.Id, _nodeId); if (stitch.NodeId == _nodeId) { SendLocal(job, subtask, stitch); } else { SendRemote(job, subtask, stitch); } } // Save the job to get an Id _jobManager.Save(job); return(CommandResponse.Started(job.Id)); }
public void CreateJobTest( [PexAssumeUnderTest] JobManager target, Job protoJob, Tile tile, float amountDone ) { target.CreateJob(protoJob, tile, amountDone); // TODO: add assertions to method JobManagerTest.CreateJobTest(JobManager, Job, Tile, Single) }
/// <summary> /// Called when a [selection is selected]. /// </summary> /// <param name="selectedTiles">The selected tiles.</param> private void OnSelectionSelected(Dictionary <Rectangle, Texture2D> selectedTiles) { // If the name of the element that was passed through OnBuildWall is build wood/brick/stone if (_buildSelectionName == GameText.BuildMenu.BUILDWOODWALL || _buildSelectionName == GameText.BuildMenu.BUILDBRICKWALL || _buildSelectionName == GameText.BuildMenu.BUILDSTONEWALL) { // For each rectangle in selected tiles rectangle foreach (var rectangle in selectedTiles.Keys) { // Get the tile by selecting the start position of the rectangle Tile tile = ChunkManager.TileAtWorldPosition(rectangle.X, rectangle.Y); if (tile != null) { Wall wall; if (_buildSelectionName == GameText.BuildMenu.BUILDWOODWALL) { wall = new Wall(tile.Position, LinkedSpriteType.WoodWall); _jobManager.CreateJob(wall, tile); } else if (_buildSelectionName == GameText.BuildMenu.BUILDBRICKWALL) { wall = new Wall(tile.Position, LinkedSpriteType.BrickWall); _jobManager.CreateJob(wall, tile); } else if (_buildSelectionName == GameText.BuildMenu.BUILDSTONEWALL) { wall = new Wall(tile.Position, LinkedSpriteType.StoneWall); _jobManager.CreateJob(wall, tile); } } } } _selectingType = SelectingAreaType.None; GameState.State = GameStateType.PLAYING; }
public void Run() { while (true) { string[] input = Console.ReadLine().Split(); string command = input[0]; if (command == "End") { return; } switch (command) { case "Job": string jobName = input[1]; int hours = int.Parse(input[2]); string employeeName = input[3]; IEmployee employee = this.employees.FirstOrDefault(e => e.Name == employeeName); jobManager.CreateJob(jobName, hours, employee); break; case "StandardEmployee": employeeName = input[1]; IEmployee newEmployee = new StandardEmployee(employeeName); this.employees.Add(newEmployee); break; case "PartTimeEmployee": employeeName = input[1]; newEmployee = new PartTimeEmployee(employeeName); this.employees.Add(newEmployee); break; case "Pass": jobManager.PassWeek(); break; case "Status": jobManager.GetStats(); break; default: break; } } }
private CommandResponse HandleRemote(CommandRequest request, StitchSummary stitch) { string nodeId = stitch.NodeId; var node = _data.Get <NodeStatus>(nodeId); if (node == null) { return(CommandResponse.Create(false)); } // Create a job to track status var job = _jobManager.CreateJob("Command=" + request.Command); var subtask = job.CreateSubtask(request.Command, request.Target, stitch.NodeId); // Create the message and send it over the backplane _sender.SendCommandRequest(node.NetworkNodeId, request, job, subtask); _jobManager.Save(job); return(CommandResponse.Started(job.Id)); }
public CommandResponse Handle(CommandRequest request) { string nodeId = request.Target; if (nodeId == _nodeId) { return(CommandResponse.Create(true)); } var node = _data.Get <NodeStatus>(nodeId); if (node == null) { return(CommandResponse.Create(false)); } var job = _jobManager.CreateJob("Command=Ping"); var subtask = job.CreateSubtask(request.Command, request.Target, nodeId); // Create the message and send it over the backplane _sender.SendCommandRequest(node.NetworkNodeId, request, job, subtask); _jobManager.Save(job); return(CommandResponse.Started(job.Id)); }