public CommanderViewModel(string commanderName, List <string> logs, Languages languages) { CommanderName = commanderName; var entryDatas = JsonConvert.DeserializeObject <List <EntryData> >(IOUtils.GetEntryDatasJson()); var converter = new ItemNameConverter(entryDatas); State = new State(entryDatas, languages); journalEntryConverter = new JournalEntryConverter(converter, State.Cargo, languages); blueprintConverter = new BlueprintConverter(State.Cargo); LoadBlueprints(); languages.PropertyChanged += (o, e) => OnPropertyChanged(nameof(Filters)); LoadState(logs); var datas = State.Cargo.Select(c => c.Value.Data); var ingredientUsed = Blueprints.SelectMany(blueprint => blueprint.Ingredients); var ingredientUsedNames = ingredientUsed.Select(ingredient => ingredient.Entry.Data.Name).Distinct(); var unusedIngredients = datas.Where(data => !ingredientUsedNames.Contains(data.Name)); foreach (var data in unusedIngredients) { data.Unused = true; } }
public CommanderViewModel(string commanderName, IEnumerable <string> logs, Languages languages, List <EntryData> entryDatas) { CommanderName = commanderName; var converter = new ItemNameConverter(entryDatas); State = new State(entryDatas, languages, SettingsManager.Comparer); commanderNotifications = new CommanderNotifications(State); journalEntryConverter = new JournalEntryConverter(converter, State.Cargo, languages); blueprintConverter = new BlueprintConverter(State.Cargo); LoadBlueprints(languages); languages.PropertyChanged += (o, e) => OnPropertyChanged(nameof(Filters)); LoadState(logs); var datas = State.Cargo.Select(c => c.Value.Data); var ingredientUsed = State.Blueprints.SelectMany(blueprint => blueprint.Ingredients); var ingredientUsedNames = ingredientUsed.Select(ingredient => ingredient.Entry.Data.Name).Distinct(); var unusedIngredients = datas.Where(data => !ingredientUsedNames.Contains(data.Name)); foreach (var data in unusedIngredients) { data.Unused = true; } }
public void Spawn(float dis, float gap, int count, int pos) { MainConstruct mainConstruct = BlueprintConverter.Convert(bp, ConversionDamageMode.IgnoreDamage, false); Team_id = IsKing ? InstanceSpecification.i.Factions.Factions.Find(f => f.FactionSpec.AbreviatedName == "K").Id : InstanceSpecification.i.Factions.Factions.Find(f => f.FactionSpec.AbreviatedName == "C").Id; BlueprintConverter.Initiate(mainConstruct, PlanetList.MainFrame.FramePositionToUniversalPosition(VLoc(gap, count, pos, dis)), VDir(), Team_id, null, SpawnPositioning.OriginOrCentre); }
public MainWindowViewModel() { State = new State(); journalEntryConverter = new JournalEntryConverter(State.Cargo); blueprintConverter = new BlueprintConverter(State.Cargo); LoadBlueprints(); Filters = new BlueprintFilters(Blueprints); LoadState(); }
public MainWindowViewModel() { var entryDatas = JsonConvert.DeserializeObject <List <EntryData> >(IOManager.GetEntryDatasJson()); var converter = new ItemNameConverter(entryDatas); State = new State(entryDatas); journalEntryConverter = new JournalEntryConverter(converter, State.Cargo); blueprintConverter = new BlueprintConverter(State.Cargo); LoadBlueprints(); LoadState(); }
public BuildController( AppDbContext dbContext, BlueprintConverter blueprintConverter, BuildService buildService, FollowerService followerService, ImageService imageService) { _dbContext = dbContext; _blueprintConverter = blueprintConverter; _buildService = buildService; _followerService = followerService; _imageService = imageService; }
public PayloadController( AppDbContext dbContext, ImageService imageService, BuildService buildService, BlueprintConverter blueprintConverter, SlugService slugService) { _dbContext = dbContext; _imageService = imageService; _buildService = buildService; _blueprintConverter = blueprintConverter; _slugService = slugService; }
// Blueprinted board generation public Board(string blueprint) { Tiles = new Dictionary <int[], Tile>(new ArrayEqualityComparer()); Dictionary <int[], bool> coordsAndTerrain = BlueprintConverter.Convert(blueprint); foreach (KeyValuePair <int[], bool> pair in coordsAndTerrain) { AddTile(pair.Key); if (pair.Value) { AddTerrain(pair.Key); } } }
public CommanderViewModel(string commanderName, List <string> logs) { CommanderName = commanderName; var entryDatas = JsonConvert.DeserializeObject <List <EntryData> >(IOUtils.GetEntryDatasJson()); var converter = new ItemNameConverter(entryDatas); State = new State(entryDatas); journalEntryConverter = new JournalEntryConverter(converter, State.Cargo); blueprintConverter = new BlueprintConverter(State.Cargo); LoadBlueprints(); LoadState(logs); }
public CommanderViewModel(string commanderName, List<string> logs, Languages languages) { CommanderName = commanderName; var entryDatas = JsonConvert.DeserializeObject<List<EntryData>>(IOUtils.GetEntryDatasJson()); var converter = new ItemNameConverter(entryDatas); State = new State(entryDatas, languages); journalEntryConverter = new JournalEntryConverter(converter, State.Cargo, languages); blueprintConverter = new BlueprintConverter(State.Cargo); LoadBlueprints(); languages.PropertyChanged += (o, e) => OnPropertyChanged(nameof(Filters)); LoadState(logs); }
public async Task <Payload> EnsureInitialized(FactorioApi.BlueprintEnvelope envelope) { if (TryGetValue(envelope, out var payload)) { return(payload); } var converter = new BlueprintConverter(); var encoded = await converter.Encode(envelope); payload = new Payload( Hash.Compute(encoded), converter.ParseType(envelope.Entity.Item), converter.DecodeGameVersion(envelope.Entity.Version), encoded); TryAdd(envelope, payload); return(payload); }
public DevDataSeeder( ILogger <DevDataSeeder> logger, IOptions <AppConfig> appConfig, AppDbContext dbContext, HttpClient httpClient, BuildService buildService, BlueprintConverter blueprintConverter, ImageService imageService, BuildTags buildTags) { _logger = logger; _appConfig = appConfig.Value; _dbContext = dbContext; _httpClient = httpClient; _buildService = buildService; _blueprintConverter = blueprintConverter; _imageService = imageService; _buildTags = buildTags; }
public void Spawn(float dis, float gap, float gap2, int count, int pos) { MainConstruct val = BlueprintConverter.Convert(bp, SpawnInstructions.None); /*val.Drone.myJustLoadedDrones.Clear(); * foreach (MainConstruct m in val.MainArrayBasics.SVList) * { * m.GenUniqueID(); * val.Drone.myJustLoadedDrones.Add(m); * }*/ team_id = (IsKing ? InstanceSpecification.i.Factions.Factions.Find((InstanceFaction f) => f.FactionSpec.Name == "KING").Id : InstanceSpecification.i.Factions.Factions.Find((InstanceFaction f) => f.FactionSpec.Name == "CHAL").Id); //BrilliantSkies.Core.Types.Vector3d vector3D = new BrilliantSkies.Core.Types.Vector3d(VLoc(gap, count, pos, dis)); //vector3D.y += offset; BlueprintInitialisation bpinit = new BlueprintInitialisation(val); bpinit.Positioning = new BlueprintPositioning(PlanetList.MainFrame.FramePositionToUniversalPosition(VLoc(gap, gap2, count, pos, dis, offset)), VDir()); bpinit.Run(team_id); //BlueprintConverter.Initiate(val, PlanetList.MainFrame.FramePositionToUniversalPosition(VLoc(gap, gap2, count, pos, dis, offset)), VDir(), team_id, null, 0); }
private async Task <IAssetCachedData> GenerateCachableData(AssetType type, IAssetMetadata metadata, string path) { try { switch (type) { case AssetType.Blueprint: var blueprint = BlueprintConverter.DeserializeFromFile(path); return(new AssetCachedData { Name = blueprint.Header.Name }); case AssetType.Mod: if (metadata?.Id == null) { return(new AssetWithImageCachedData()); } var asset = await _website.API.GetAsset(metadata.Id); using (var memoryStream = new MemoryStream()) { try { using (var image = await asset.Image.Data.Get()) { if (image == null) { return(new AssetWithImageCachedData { ImageBase64 = null }); } image.Save(memoryStream, ImageFormat.Png); return(new AssetWithImageCachedData { ImageBase64 = Convert.ToBase64String(memoryStream.ToArray()) }); } } catch (Exception e) { _log.WriteLine("Failed to load image!"); _log.WriteException(e); return(new AssetWithImageCachedData()); } } case AssetType.Savegame: var savegame = SavegameConverter.DeserializeFromFile(path); using (var stream = new MemoryStream()) { using (var thumbnail = savegame.Screenshot) { thumbnail.Save(stream, ImageFormat.Png); } return(new AssetWithImageCachedData { Name = savegame.Header.Name, ImageBase64 = Convert.ToBase64String(stream.ToArray()) }); } default: throw new Exception("Unsupported type"); } } catch (Exception e) { _log.WriteException(e); return(new AssetCachedData { Name = "Failed to open image for " + path }); } }