// Getting image for build-ons and steps public async Task <byte[]> GetImageForBuildOnAsync(string buildOnId) { BuildOn buildOn = await GetBuildOn(buildOnId); if (buildOn == null || buildOn.ImageId == null) { return(null); } return((await _filesService.GetFile(buildOn.ImageId)).Data); }
private async Task <BuildOn> CreateBuildOnAsync(int index, BuildOnManageModel buildOnManageModel) { BuildOn buildOn = new BuildOn() { Index = index, Name = buildOnManageModel.Name, Description = buildOnManageModel.Description }; await _buildOns.InsertOneAsync(buildOn); // We directly update the build-on to save the image buildOn = await UpdateBuildOnAsync(buildOn.Id, index, buildOnManageModel); return(buildOn); }
public void Parse(DataReader reader) { cost = reader.ReadInt(); research_time = reader.ReadInt(); model = reader.ReadString(13); reader.ReadByte(); icon = reader.ReadString(13); name = reader.ReadString(25); description = reader.ReadString(200); group = reader.ReadByte(); zero = reader.ReadByte(); techtree = new Techtree(reader); reader.Assert((ushort)0xCDCD, 0, name, "Station", "Techtree"); stats_s1 = reader.ReadFloat(); stats_s2 = reader.ReadFloat(); stats_s3 = reader.ReadFloat(); stats_s4 = reader.ReadFloat(); stats_s5 = reader.ReadFloat(); stats_s6 = reader.ReadFloat(); stats_income = reader.ReadInt(); stats_s7 = reader.ReadFloat(); techtreelocal = new BitArray(reader.ReadBytes(50)); // // uid = reader.ReadUShort(); overriding_uid = reader.ReadShort(); ACHull = reader.ReadByte(); ACShld = reader.ReadByte(); AbilityBitMask = new BitArray(reader.ReadBytes(2)); buildon = (BuildOn)Enum.Parse(typeof(BuildOn), reader.ReadUShort().ToString()); type = reader.ReadByte(); reader.Assert((byte)0xCD, uid, name, "Station", "Type"); stats_ss0 = reader.ReadUShort(); for (int i = 0; i < 13; i++) { sounds[i] = reader.ReadUShort(); } uk3 = reader.ReadBytes(13); constructor = reader.ReadString(25); }
private async Task IncrementProjectBuildOnStep(Project project) { // We need the Builder for the future notification User builderUser = await _buildersService.GetUserFromAdminAsync(project.BuilderId); if (builderUser == null) { throw new Exception("The builder of this project doesn't exist..."); } List <BuildOn> buildOns = await GetAllAsync(); if (buildOns.Count < 1) { throw new Exception("Build-up have no build-ons yet..."); } string newBuildOnId; string newBuildOnStepId; if (project.CurrentBuildOn == null) { newBuildOnId = buildOns.First().Id; var buildOnSteps = await GetAllStepsAsync(buildOns.First().Id); if (buildOnSteps.Count < 1) { return; } newBuildOnStepId = buildOnSteps[1].Id; } else { BuildOn currentBuildOn = await GetBuildOn(project.CurrentBuildOn); BuildOnStep currentStep = await GetBuildOnStep(project.CurrentBuildOnStep); List <BuildOnStep> currentBuildOnSteps = await GetAllStepsAsync(currentBuildOn.Id); // Case 1: we are at the last step of the current build-on if (currentStep.Index == currentBuildOnSteps.Count - 1) { // If we are at the last build-on, no need to continue if (currentBuildOn.Index == buildOns.Count - 1) { newBuildOnId = null; newBuildOnStepId = null; } else { BuildOn newBuildOn = buildOns[currentBuildOn.Index + 1]; List <BuildOnStep> newSteps = await GetAllStepsAsync(newBuildOn.Id); if (newSteps.Count < 1) { return; } newBuildOnId = newBuildOn.Id; newBuildOnStepId = newSteps.First().Id; } } // Case 2: we wan't the next from the current build-on else { newBuildOnId = currentBuildOn.Id; newBuildOnStepId = currentBuildOnSteps[currentStep.Index + 1].Id; } } await _projectsService.UpdateProjectBuildOnStep(project.Id, newBuildOnId, newBuildOnStepId); await _notificationService.NotifyBuildonStepValidated(project.BuilderId, builderUser.Email); }