public void AppendChunk(PasswordChunk pChunk) { if ((pChunk != null) && (pChunk.ChunkType != PasswordChunkType.None) && (!string.IsNullOrEmpty(pChunk.Text))) { Chunks.Add(pChunk); } }
private void GenerateChunk(Vector3 position) { var chunk = WorldGenerator.GenerateChunk(position, this); Chunks.Add(position, chunk); World.LightChunk(chunk); }
private void ProcessFileUpload(System.Uri uri , System.IO.FileInfo fileInfo , System.ComponentModel.BackgroundWorker worker , System.ComponentModel.DoWorkEventArgs e) { using (FileStream stream = fileInfo.OpenRead()) { int i = 0; bool finished = false; while (!finished) { MemoryStream chunk = new MemoryStream(); Chunk chunkToAdd = new Chunk() { FileName = uniqueFileNameNonUI, Number = i, Size = 1 }; currentDispatcher.BeginInvoke(() => { Chunks.Add(chunkToAdd); }); //Compress to get a 3MB Chunk of file finished = CreateZippedChunk(stream, chunk, 4096, 3000000, "zip" + i.ToString(), chunkToAdd); //Upload Chunk UploadChunk(uri, chunk, worker, e, i, finished, chunkToAdd); i++; } } }
protected override void Visit(ConditionNode conditionNode) { var conditionChunk = new ConditionalChunk { Condition = conditionNode.Code, Type = ConditionalType.If, Position = Locate(conditionNode) }; Chunks.Add(conditionChunk); if (_sendAttributeOnce != null) { conditionChunk.Body.Add(_sendAttributeOnce); } if (_sendAttributeIncrement != null) { conditionChunk.Body.Add(_sendAttributeIncrement); } using (new Frame(this, conditionChunk.Body)) { Accept(conditionNode.Nodes); } }
public void LoadChunk(Vector3Int pos, int lifetime = 15) { GameObject gameObject; if (LoadedChunkObjects.ContainsKey(pos)) { ChunkWrapper wrapper = LoadedChunkObjects[pos]; wrapper.lifetimeRemaining = lifetime; gameObject = wrapper.chunkObject.gameObject; } else { gameObject = Instantiate(ChunkPrefab, pos * ChunkSize, transform.rotation); LoadedChunkObjects.Add(pos, new ChunkWrapper(gameObject, lifetime)); } ChunkBehaviour chunkBehavior = gameObject.GetComponent <ChunkBehaviour>(); chunkBehavior.Interacted += ChunkBehavior_Interacted; if (Chunks.ContainsKey(pos)) //get from recycled { Chunk tChunk = Chunks[pos]; chunkBehavior.Chunk = tChunk; } else { chunkBehavior.Chunk = mapProvider.GetChunk(pos, ChunkSize); Chunks.Add(pos, chunkBehavior.Chunk); } gameObject.name = pos.ToString(); }
private async Task SaveVirtualDiskChunkAsync( Stream sourceStream, int chunkIndex, HashSet <string> existingChunkHashes, IBackupLocationFactory targetLocationFactory, string targetLocation, byte[] buffer) { await sourceStream.ReadAsync(buffer); var sha = SHA256.Create(); byte[] hashBytes = sha.ComputeHash(buffer); string hash = Convert.ToBase64String(hashBytes); Chunk chunk = Chunk.CreateNew(chunkIndex, hash); Chunks.Add(chunk); if (!existingChunkHashes.Contains(chunk.Hash)) { Stream targetStream = targetLocationFactory.Open(chunk, targetLocation); await targetStream.WriteAsync(buffer); targetStream.Close(); existingChunkHashes.Add(chunk.Hash); } }
private void VisitVar(SpecialNode specialNode, SpecialNodeInspector inspector) { Frame frame = null; if (!specialNode.Element.IsEmptyElement) { var scope = new ScopeChunk { Position = Locate(specialNode.Element) }; Chunks.Add(scope); frame = new Frame(this, scope.Body); } var typeAttr = inspector.TakeAttribute("type"); var type = typeAttr != null?AsCode(typeAttr) : (Snippets)"var"; foreach (var attr in inspector.Attributes) { Chunks.Add(new LocalVariableChunk { Type = type, Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) }); } Accept(specialNode.Body); if (frame != null) { frame.Dispose(); } }
private void VisitElse(SpecialNodeInspector inspector) { if (!SatisfyElsePrecondition()) { throw new CompilerException("An 'else' may only follow an 'if' or 'elseif'."); } var ifAttr = inspector.TakeAttribute("if"); if (ifAttr == null) { var elseChunk = new ConditionalChunk { Type = ConditionalType.Else, Position = Locate(inspector.OriginalNode) }; Chunks.Add(elseChunk); using (new Frame(this, elseChunk.Body)) Accept(inspector.Body); } else { var elseIfChunk = new ConditionalChunk { Type = ConditionalType.ElseIf, Condition = AsCode(ifAttr), Position = Locate(inspector.OriginalNode) }; Chunks.Add(elseIfChunk); using (new Frame(this, elseIfChunk.Body)) Accept(inspector.Body); } }
protected override void Visit(StatementNode node) { //REFACTOR: what is UnarmorCode doing at this point? Chunks.Add(new CodeStatementChunk { Code = node.Code, Position = Locate(node) }); }
public void Update() { var playerChunk = new Vector2(Mathf.Floor(player.position.x / Grid), Mathf.Floor(player.position.z / Grid)); for (int x = -ViewDistance; x < ViewDistance; x++) { for (int y = -ViewDistance; y < ViewDistance; y++) { var position = new Vector2(playerChunk.x + x, playerChunk.y + y); if (!Chunks.ContainsKey(position)) { var chunk = new Chunk(position, Grid); chunk.Active = true; Generator.CreateChunk(chunk); if (chunk.GameObject == null) { GameObjectGenerator.CreateGameObject(chunk); } Chunks.Add(position, chunk); } else { Chunks[position].Active = true; } } } }
public void Register(FloorChunk Chunk) { if (!Chunks.ContainsKey(Chunk.Id)) { Chunks.Add(Chunk.Id, Chunk); } }
public IChunk GetChunk(Grid grid) { Chunks.TryGetValue(grid, out var chunk); if (chunk != default) { return(chunk); } chunk = new Chunk(grid, this); Chunks.Add(grid, chunk); /*foreach (var neighborGrid in GridHelper.NeighborGrids(grid)) * { * if (!Chunks.TryGetValue(neighborGrid + chunk.Id, out var neighborChunk)) * { * continue; * } * * neighborChunk.RegisterChunk(chunk); * chunk.RegisterChunk(neighborChunk); * }*/ return(chunk); }
internal void LocalLoadChunks() { foreach (var chunk in DatabaseClient.GetChunks(Id)) { Chunks.Add(chunk); } }
Chunk createNewChunk(Vector2 target) { Rect rect = new Rect(Mathf.FloorToInt(target.x / chunkSize) * chunkSize, (Mathf.FloorToInt(target.y / chunkSize)) * chunkSize, chunkSize, chunkSize); Chunk newChunk = new Chunk(rect); Chunks.Add(newChunk); return(newChunk); }
/// <summary> /// Sets the chunk at the specified local position to the given value. /// </summary> public void SetChunk(Vector3 position, Chunk chunk) { if (!Chunks.ContainsKey(position)) { Chunks.Add(position, chunk); } Chunks[position] = chunk; }
public FileData(DepotManifest.FileData sourceData) : this() { FileName = sourceData.FileName; sourceData.Chunks.ForEach(c => Chunks.Add(new ChunkData(c))); Flags = sourceData.Flags; TotalSize = sourceData.TotalSize; FileHash = sourceData.FileHash; }
private void VisitSet(SpecialNodeInspector inspector) { foreach (var attr in inspector.Attributes) { Chunks.Add(new AssignVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) }); } }
public void GenerateChunk(Coordinates2D position) { var globalPosition = (Position * new Coordinates2D(Width, Depth)) + position; var chunk = World.ChunkProvider.GenerateChunk(World, globalPosition); chunk.IsModified = true; chunk.Coordinates = globalPosition; Chunks.Add(position, (IChunk)chunk); }
/// <summary> /// Sets the chunk at the specified local position to the given value. /// </summary> public void SetChunk(Coordinates2D position, IChunk chunk) { if (!Chunks.ContainsKey(position)) { Chunks.Add(position, chunk); } chunk.IsModified = true; Chunks[position] = chunk; }
public async Task <Chunk> GetOrAddSpecificChunk(string languageCode, PropertyType propertyType, string propertyName, string innerIdentifier) { var result = await Chunks .Include(x => x.Abbreviations) .FirstOrDefaultAsync(x => x.LanguageCode == languageCode && x.Name == propertyName && x.Type == propertyType && x.InnerIdentifier == innerIdentifier); if (result != null) { return(result); } result = await Chunks .Include(x => x.Abbreviations) .FirstOrDefaultAsync(x => x.LanguageCode == "en-US" && x.Type == propertyType && x.Name == propertyName && x.InnerIdentifier == innerIdentifier); var otherlang = await Languages.FirstOrDefaultAsync(x => x.Code == languageCode); var newChunk = new Chunk { Abbreviations = new List <Abbreviation>(), Name = propertyName, InnerIdentifier = innerIdentifier, Language = otherlang, LanguageCode = languageCode, Type = propertyType, Text = "Translated Text Here " + languageCode }; for (var i = 0; i < result.Abbreviations.Count; i++) { var abbr = result.Abbreviations[i]; newChunk.Abbreviations.Add(new Abbreviation { Description = abbr.Description, Name = abbr.Name, Parent = newChunk, ParentType = newChunk.Type, ParentIdentifier = newChunk.InnerIdentifier, ParentName = newChunk.Name, ParentLanguageCode = otherlang.Code, Position = abbr.Position }); } Chunks.Add(newChunk); await SaveChangesAsync(); return(newChunk); }
private static void AddChunk(Vector3 chunkPosition) { Chunk newChunk = new Chunk(chunkPosition); Chunks.Add(chunkPosition, newChunk); MapGenerator.RenderChunk(newChunk); CheckNeighbors(chunkPosition); }
public void GenerateChunk(Coordinates2D position) { var globalPosition = (Position * new Coordinates2D(Width, Depth)) + position; var chunk = World.WorldGenerator.GenerateChunk(globalPosition); chunk.IsModified = true; chunk.X = globalPosition.X; chunk.Z = globalPosition.Z; Chunks.Add(position, chunk); }
protected override void Visit(ExpressionNode node) { Chunks.Add(new SendExpressionChunk { Code = node.Code, Position = Locate(node), SilentNulls = node.SilentNulls, AutomaticallyEncode = node.AutomaticEncoding }); }
private void AddKillingWhitespace(Chunk chunk) { var sendLiteral = Chunks.LastOrDefault() as SendLiteralChunk; if (sendLiteral != null && sendLiteral.Text.Trim() == string.Empty) { Chunks.Remove(sendLiteral); } Chunks.Add(chunk); }
protected override void Visit(ExtensionNode extensionNode) { var extensionChunk = new ExtensionChunk { Extension = extensionNode.Extension, Position = Locate(extensionNode) }; Chunks.Add(extensionChunk); using (new Frame(this, extensionChunk.Body)) extensionNode.Extension.VisitNode(this, extensionNode.Body, Chunks); }
private void VisitMarkdown(SpecialNode specialNode, SpecialNodeInspector inspector) { var markdownChunk = new MarkdownChunk(); Chunks.Add(markdownChunk); using (new Frame(this, markdownChunk.Body)) { Accept(inspector.Body); } }
public EditorMap(bool interior, ChunkTemplate template) : base(interior) { AlwaysPlaceEntities = true; Chunk = new Chunk(0, 0, template, this); Chunks.Add(Chunk); Chunk.PostWorldInitialize(true); }
public void GenerateChunk(Coordinates2D position) { var globalPosition = (Position * new Coordinates2D(Width, Depth)) + position; var chunk = World.ChunkProvider.GenerateChunk(World, globalPosition); chunk.IsModified = true; chunk.Coordinates = globalPosition; Chunks.Add(position, chunk); World.OnChunkGenerated(new ChunkLoadedEventArgs(chunk)); }
/// <summary> /// Retrieves the requested chunk from the region, or /// generates it if a world generator is provided. /// </summary> /// <param name="position">The position of the requested local chunk coordinates.</param> public Chunk GetChunk(Vector3 position) { // TODO: This could use some refactoring lock (Chunks) { if (!Chunks.ContainsKey(position)) { if (regionFile != null) { // Search the stream for that region lock (regionFile) { var chunkData = GetChunkFromTable(position); if (chunkData == null) { if (WorldGenerator == null) { throw new ArgumentException("The requested chunk is not loaded.", "position"); } GenerateChunk(position); return(Chunks[position]); } regionFile.Seek(chunkData.Item1, SeekOrigin.Begin); int length = new MinecraftStream(regionFile).ReadInt32(); // TODO: Avoid making new objects here, and in the WriteInt32 int compressionMode = regionFile.ReadByte(); switch (compressionMode) { case 1: // gzip break; case 2: // zlib var nbt = new NbtFile(); nbt.LoadFromStream(regionFile, NbtCompression.ZLib, null); var chunk = Chunk.FromNbt(position, nbt); chunk.ParentRegion = this; Chunks.Add(position, chunk); break; default: throw new InvalidDataException("Invalid compression scheme provided by region file."); } } } else if (WorldGenerator == null) { throw new ArgumentException("The requested chunk is not loaded.", "position"); } else { Chunks.Add(position, WorldGenerator.GenerateChunk(position, this)); } } return(Chunks[position]); } }
/// <summary> /// Instantiates a chunk to the specified coordinate /// </summary> /// <param name="chunkCoordinate">The chunk's coordinate</param> /// <returns>The instantiated chunk</returns> private SimulationChunk CreateChunk(int3 chunkCoordinate) { SimulationChunk chunk = Instantiate(ChunkPrefab, (chunkCoordinate * ChunkSize).ToVectorInt(), Quaternion.identity).GetComponent <SimulationChunk>(); chunk.name = $"Chunk_{chunkCoordinate.x}_{chunkCoordinate.y}_{chunkCoordinate.z}"; chunk.World = this; chunk.Initialize(ChunkSize, Isolevel, chunkCoordinate, CubeSize); Chunks.Add(chunkCoordinate, chunk); return(chunk); }