public void SHOULD_recognize_addition() { var sut = new ChunkFactory(); var result = sut.ParseString("LX"); Assert.That(result.First(), Is.InstanceOf <AdditionChunk>()); }
public override void Run(RunPayload payload) { Main.Logger.Log($"[AddDialogueChunk] Adding encounter structure"); EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData; DialogueChunkGameLogic dialogChunk = ChunkFactory.CreateDialogueChunk($"Chunk_Dialog_{dialogChunkName}"); dialogChunk.encounterObjectGuid = System.Guid.NewGuid().ToString(); dialogChunk.notes = debugDescription; DialogueGameLogic dialogueGameLogic; if (fromDialogueBucket) { dialogueGameLogic = DialogueFactory.CreateBucketDialogLogic(dialogChunk.gameObject, dialogChunkName, dialogueBucketId); } else if (dialogueOverride != null) { dialogueGameLogic = DialogueFactory.CreateDialogLogic(dialogChunk.gameObject, dialogChunkName, dialogueOverride); } else { dialogueGameLogic = DialogueFactory.CreateDialogLogic(dialogChunk.gameObject, dialogChunkName, cameraTargetGuid, presetDialog, castDef); } dialogueGameLogic.encounterObjectGuid = dialogueGuid; }
public void SHOULD_recognize_main_letter_of_subtraction() { var sut = new ChunkFactory(); var result = sut.ParseString("IX"); Assert.That(result.First().MainLetter, Is.EqualTo(Letters.X)); }
public void WHEN_provided_single_letter_THEN_returns_SingleLetterChunk() { var sut = new ChunkFactory(); var result = sut.ParseString("L"); Assert.That(result.First(), Is.InstanceOf <SingleLetterChunk>()); }
private GameObject BuildDialogueChunk() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'BuildDialogueChunk' Chunk"); DialogueChunkGameLogic dialogueChunk = ChunkFactory.CreateDialogueChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); SetupChunk(dialogueChunk); return(dialogueChunk.gameObject); }
private GameObject BuildPlacementChunk() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'BuildPlacementChunk' Chunk"); SwapPlacementChunkLogic swapPlacementChunk = ChunkFactory.CreateSwapPlacementChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); SetupChunk(swapPlacementChunk); return(swapPlacementChunk.gameObject); }
private GameObject BuildLanceChunk() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'BuildLanceChunk' (Container) Chunk"); LanceChunkGameLogic lanceChunk = ChunkFactory.CreateLanceChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); SetupChunk(lanceChunk); return(lanceChunk.gameObject); }
private GameObject BuildDestroyWholeLanceChunk() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'DestroyWholeLance' Chunk"); DestroyWholeLanceChunk destroyWholeLanceChunkGameLogic = ChunkFactory.CreateDestroyWholeLanceChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); SetupChunk(destroyWholeLanceChunkGameLogic); return(destroyWholeLanceChunkGameLogic.gameObject); }
private GameObject BuildEncounterBoundary() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'BuildEncounterBoundary' Chunk"); EncounterBoundaryChunkGameLogic encounterBoundaryChunkLogic = ChunkFactory.CreateEncounterBondaryChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); SetupChunk(encounterBoundaryChunkLogic); return(encounterBoundaryChunkLogic.gameObject); }
public void SHOULD_recognize_double_addition() { var sut = new ChunkFactory(); var result = sut.ParseString("LXX").ToList(); Assert.That(result.First(), Is.InstanceOf <AdditionChunk>()); Assert.That(result.Count, Is.EqualTo(1)); }
public void WHEN_multiple_single_letters_THEN_should_return_in_preserved_order() { var sut = new ChunkFactory(); var result = sut.ParseString("CLI"); var letters = result.Select(c => c.MainLetter); CollectionAssert.AreEqual(new[] { Letters.C, Letters.L, Letters.I }, letters); }
public void WHEN_provided_letter_is_invalid_THEN_throws_exception() { var invalidLetter = "Z"; var sut = new ChunkFactory(); Assert.Throws <ArgumentException>(() => sut.ParseString(invalidLetter).ToList()); }
public Riff(UInt32 size, Byte [] data) { Int32 pos = 0; m_chunkID = Encoding.ASCII.GetString(data, pos, 4); pos += 4; m_chunkSize = BitConverter.ToUInt32(data, pos); pos += 4; m_format = Encoding.ASCII.GetString(data, pos, 4); pos += 4; if ("RIFF" != m_chunkID) { MessageBox.Show("Unsupported header format \"" + m_chunkID + "\". Quitting.", "Error!", MessageBoxButtons.OK); Application.Exit(); } if ("WAVE" != m_format) { MessageBox.Show("Unsupported data format \"" + m_format + "\". Quitting.", "Error!", MessageBoxButtons.OK); Application.Exit(); } while (pos < m_chunkSize) { string chunkType = Encoding.ASCII.GetString(data, pos, 4); pos += 4; UInt32 chunkSize = BitConverter.ToUInt32(data, pos); pos += 4; if (chunkSize % 2 == 1) { pos += 1; } if (m_chunkSize < pos) { break; } Byte[] chunkData = new Byte[chunkSize]; Array.Copy(data, pos, chunkData, 0, chunkSize); Chunk nextChunk = ChunkFactory.CreateChunk(chunkType, chunkSize, chunkData); if (nextChunk != null) { m_chunkCollection.Add(nextChunk); } pos += (Int32)chunkSize; } }
public override void Run(RunPayload payload) { Main.Logger.Log($"[AddDestroyWholeUnitChunk] Adding encounter structure"); EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData; DestroyWholeLanceChunk destroyWholeChunk = ChunkFactory.CreateDestroyWholeLanceChunk(); destroyWholeChunk.encounterObjectGuid = System.Guid.NewGuid().ToString(); this.objectiveLabel = MissionControl.Instance.CurrentContract.Interpolate(this.objectiveLabel).ToString(); bool spawnOnActivation = true; LanceSpawnerGameLogic lanceSpawner = LanceSpawnerFactory.CreateLanceSpawner( destroyWholeChunk.gameObject, spawnerName, lanceGuid, teamGuid, spawnOnActivation, SpawnUnitMethodType.InstantlyAtSpawnPoint, unitGuids ); LanceSpawnerRef lanceSpawnerRef = new LanceSpawnerRef(lanceSpawner); bool showProgress = true; DestroyLanceObjective objective = ObjectiveFactory.CreateDestroyLanceObjective( objectiveGuid, destroyWholeChunk.gameObject, lanceSpawnerRef, lanceGuid, objectiveLabel, showProgress, ProgressFormat.PERCENTAGE_COMPLETE, "The primary objective to destroy the enemy lance", priority, displayToUser, ObjectiveMark.AttackTarget, contractObjectiveGameLogicGuid, Main.Settings.ActiveAdditionalLances.GetRewards() ); if (isPrimary) { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objective, true); } else { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objective, false); } DestroyLanceObjectiveRef destroyLanceObjectiveRef = new DestroyLanceObjectiveRef(); destroyLanceObjectiveRef.encounterObject = objective; destroyWholeChunk.lanceSpawner = lanceSpawnerRef; destroyWholeChunk.destroyObjective = destroyLanceObjectiveRef; }
private void ReloadMesh(GameObject previewRendererObject, BlockType block) { if (previewRendererObject == null) { return; } var mesh = ChunkFactory.Build(block); previewRendererObject.GetComponent <MeshFilter>().mesh = mesh; }
public static IChunk ReadChunk(this Stream stream, int chunkSize, byte[] buffer) { var bytesRead = stream.Read(buffer, 0, chunkSize); if (bytesRead < chunkSize) { buffer = buffer.Take(bytesRead).ToArray(); } return(ChunkFactory.GetNew(buffer, 0)); }
private GameObject BuildPlacementChunk() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'BuildPlacementChunk' Chunk"); SwapPlacementChunkLogic swapPlacementChunk = ChunkFactory.CreateSwapPlacementChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); swapPlacementChunk.encounterObjectGuid = this.guid; if (controlledByContract) { swapPlacementChunk.startingStatus = EncounterObjectStatus.ControlledByContract; } return(swapPlacementChunk.gameObject); }
private GameObject BuildDestroyWholeLanceChunk() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'DestroyWholeLance' Chunk"); DestroyWholeLanceChunk destroyWholeLanceChunkGameLogic = ChunkFactory.CreateDestroyWholeLanceChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); destroyWholeLanceChunkGameLogic.encounterObjectGuid = this.guid; if (controlledByContract) { destroyWholeLanceChunkGameLogic.startingStatus = EncounterObjectStatus.ControlledByContract; } return(destroyWholeLanceChunkGameLogic.gameObject); }
private GameObject BuildEncounterBoundary() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'BuildEncounterBoundary' Chunk"); EncounterBoundaryChunkGameLogic encounterBoundaryChunkLogic = ChunkFactory.CreateEncounterBondaryChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); encounterBoundaryChunkLogic.encounterObjectGuid = this.guid; if (controlledByContract) { encounterBoundaryChunkLogic.startingStatus = EncounterObjectStatus.ControlledByContract; } return(encounterBoundaryChunkLogic.gameObject); }
private GameObject BuildDialogueChunk() { Main.LogDebug($"[ChunkTypeBuilder.{contractTypeBuilder.ContractTypeKey}] Building 'BuildDialogueChunk' Chunk"); DialogueChunkGameLogic dialogueChunk = ChunkFactory.CreateDialogueChunk(this.name, contractTypeBuilder.EncounterLayerGo.transform); dialogueChunk.encounterObjectGuid = this.guid; if (controlledByContract) { dialogueChunk.startingStatus = EncounterObjectStatus.ControlledByContract; } return(dialogueChunk.gameObject); }
private IChunk GetNextHeaderLenghtChunk() { var currentDataPartSize = ReadNextChunkSize(); if (currentDataPartSize == 0) { return(ChunkFactory.GetNull()); } var buffer = _memManager.GetArrayWhenHasMemory(currentDataPartSize); return(_stream.ReadChunk(currentDataPartSize, buffer));; }
public void Edit(Vector3Int coord, BlockType type) { if (!Blocks.Contains(coord.x, coord.y, coord.z) || Blocks.Blocks[coord.x, coord.y, coord.z] == type) { return; } Blocks.Blocks[coord.x, coord.y, coord.z] = type; var mesh = ChunkFactory.Build(Blocks); Mesh = mesh; meshFilter.mesh = mesh; }
public bool TryTake(out IChunk item) { lock (_orderedList) { if (Count > 0) { item = _orderedList.TakeFirst(); Interlocked.Decrement(ref _count); return(true); } } item = ChunkFactory.GetNull(); return(false); }
public static IEnumerable<Chunk> CreateChunks(byte* cur, byte* end, ChunkFactory factory) { var chunks = new List<Chunk>(); while (cur < end) { var header = (ChunkHeader*)cur; var chunk = factory(header); if (chunk != null) { chunks.Add(chunk); } cur = header->NextChunk(cur); } return chunks; }
public static IEnumerable <Chunk> CreateChunks(byte *cur, byte *end, ChunkFactory factory) { var chunks = new List <Chunk>(); while (cur < end) { var header = (ChunkHeader *)cur; var chunk = factory(header); if (chunk != null) { chunks.Add(chunk); } cur = header->NextChunk(cur); } return(chunks); }
public async Task HasNext_False() { // Arrange string chunkPath = "chunkPath"; Mock <BlobContainerClient> containerClient = new Mock <BlobContainerClient>(MockBehavior.Strict); Mock <BlobClient> blobClient = new Mock <BlobClient>(MockBehavior.Strict); Mock <AvroReaderFactory> avroReaderFactory = new Mock <AvroReaderFactory>(MockBehavior.Strict); Mock <AvroReader> avroReader = new Mock <AvroReader>(MockBehavior.Strict); Mock <LazyLoadingBlobStreamFactory> lazyLoadingBlobStreamFactory = new Mock <LazyLoadingBlobStreamFactory>(MockBehavior.Strict); Mock <LazyLoadingBlobStream> lazyLoadingBlobStream = new Mock <LazyLoadingBlobStream>(MockBehavior.Strict); containerClient.Setup(r => r.GetBlobClient(It.IsAny <string>())).Returns(blobClient.Object); lazyLoadingBlobStreamFactory.Setup(r => r.BuildLazyLoadingBlobStream( It.IsAny <BlobClient>(), It.IsAny <long>(), It.IsAny <long>())) .Returns(lazyLoadingBlobStream.Object); avroReaderFactory.Setup(r => r.BuildAvroReader(It.IsAny <Stream>())).Returns(avroReader.Object); avroReader.Setup(r => r.HasNext()).Returns(false); avroReader.Setup(r => r.Initalize(It.IsAny <bool>(), It.IsAny <CancellationToken>())).Returns(Task.CompletedTask); long?maxTransferSize = 256 * Constants.MB; ChunkFactory chunkFactory = new ChunkFactory( containerClient.Object, lazyLoadingBlobStreamFactory.Object, avroReaderFactory.Object, maxTransferSize); Chunk chunk = await chunkFactory.BuildChunk( IsAsync, chunkPath); // Act bool hasNext = chunk.HasNext(); // Assert Assert.IsFalse(hasNext); containerClient.Verify(r => r.GetBlobClient(chunkPath)); lazyLoadingBlobStreamFactory.Verify(r => r.BuildLazyLoadingBlobStream( blobClient.Object, 0, maxTransferSize.Value)); avroReaderFactory.Verify(r => r.BuildAvroReader(lazyLoadingBlobStream.Object)); avroReader.Verify(r => r.HasNext()); }
private void Start() { radius = new Vector3Int(16, 3, 16); chunks = new Space3D <Chunk>(); generators = new Space3D <ChunkGenerator>(); chunkBlocks = new Space3D <ChunkBlocks>(); factory = new ChunkFactory(); var chunk = player.Chunk(); generators.Set(MathHelper.Anchor(chunk.x, chunk.y, chunk.z, REGION), start); Ping(player.Chunk()); for (int i = 0; i < STARTUP_PROCESSED_CHUNKS; i++) { factory.Process(player.Chunk()); } }
public override void Run(RunPayload payload) { Main.Logger.Log($"[AddCustomPlayerLanceSpawnChunk] Adding encounter structure"); EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData; EmptyCustomChunkGameLogic emptyCustomChunk = ChunkFactory.CreateEmptyCustomChunk("Chunk_Lance"); emptyCustomChunk.encounterObjectGuid = System.Guid.NewGuid().ToString(); emptyCustomChunk.notes = debugDescription; // Auto select Player or Employer based on the lance configurator if (teamGuid == null) { SpawnableUnit[] lanceUnits = MissionControl.Instance.CurrentContract.Lances.GetLanceUnits(EncounterRules.PLAYER_TEAM_ID); if (lanceUnits.Length > 4) { teamGuid = EncounterRules.PLAYER_TEAM_ID; } else { teamGuid = EncounterRules.EMPLOYER_TEAM_ID; } } // Guard: Don't do anything if there are no employer units and employer mode is on SpawnableUnit[] employerLanceUnits = MissionControl.Instance.CurrentContract.Lances.GetLanceUnits(EncounterRules.EMPLOYER_TEAM_ID); Main.Logger.Log($"[AddCustomPlayerLanceExtraSpawnPoints] '{employerLanceUnits.Length}' employer lance units are being sent to Mission Control by Bigger Drops."); if (employerLanceUnits.Length <= 0) { return; } bool spawnOnActivation = true; CustomPlayerLanceSpawnerGameLogic lanceSpawner = LanceSpawnerFactory.CreateCustomPlayerLanceSpawner( emptyCustomChunk.gameObject, spawnerName, lanceGuid, teamGuid, spawnOnActivation, SpawnUnitMethodType.ViaLeopardDropship, unitGuids ); lanceSpawner.transform.position = Vector3.zero; }
// Start is called before the first frame update void Start() { Chunk c = ChunkFactory.GenerateChunk(40, 10, 3, 1); GameObject baseTile = (GameObject)Instantiate(Resources.Load("grass_center")); for (int y = 0; y < Chunk.CHUNK_HEIGHT; y++) { for (int x = 0; x < Chunk.CHUNK_WIDTH; x++) { if (c.tempGrid[x, y] == 1) { GameObject tile = (GameObject)Instantiate(baseTile, this.transform); tile.transform.position = new Vector2(x, -y); } } } Destroy(baseTile); }
public void HasNext_False() { // Arrange string chunkPath = "chunkPath"; Mock <BlobContainerClient> containerClient = new Mock <BlobContainerClient>(MockBehavior.Strict); Mock <BlobClient> blobClient = new Mock <BlobClient>(MockBehavior.Strict); Mock <AvroReaderFactory> avroReaderFactory = new Mock <AvroReaderFactory>(MockBehavior.Strict); Mock <AvroReader> avroReader = new Mock <AvroReader>(MockBehavior.Strict); Mock <LazyLoadingBlobStreamFactory> lazyLoadingBlobStreamFactory = new Mock <LazyLoadingBlobStreamFactory>(MockBehavior.Strict); Mock <LazyLoadingBlobStream> lazyLoadingBlobStream = new Mock <LazyLoadingBlobStream>(MockBehavior.Strict); containerClient.Setup(r => r.GetBlobClient(It.IsAny <string>())).Returns(blobClient.Object); lazyLoadingBlobStreamFactory.Setup(r => r.BuildLazyLoadingBlobStream( It.IsAny <BlobClient>(), It.IsAny <long>(), It.IsAny <long>())) .Returns(lazyLoadingBlobStream.Object); avroReaderFactory.Setup(r => r.BuildAvroReader(It.IsAny <Stream>())).Returns(avroReader.Object); avroReader.Setup(r => r.HasNext()).Returns(false); ChunkFactory chunkFactory = new ChunkFactory( containerClient.Object, lazyLoadingBlobStreamFactory.Object, avroReaderFactory.Object); Chunk chunk = chunkFactory.BuildChunk( chunkPath); // Act bool hasNext = chunk.HasNext(); // Assert Assert.IsFalse(hasNext); containerClient.Verify(r => r.GetBlobClient(chunkPath)); lazyLoadingBlobStreamFactory.Verify(r => r.BuildLazyLoadingBlobStream( blobClient.Object, 0, Constants.ChangeFeed.ChunkBlockDownloadSize)); avroReaderFactory.Verify(r => r.BuildAvroReader(lazyLoadingBlobStream.Object)); avroReader.Verify(r => r.HasNext()); }
public override void Run(RunPayload payload) { if (!state.GetBool("Chunk_Withdraw_Exists")) { Main.Logger.Log($"[AddWithdrawChunk] Adding encounter structure"); string playerSpawnerGuid = GetPlayerSpawnGuid(); EmptyCustomChunkGameLogic emptyCustomChunk = ChunkFactory.CreateEmptyCustomChunk("Chunk_Withdraw"); GameObject escapeChunkGo = emptyCustomChunk.gameObject; emptyCustomChunk.encounterObjectGuid = chunkGuid; emptyCustomChunk.startingStatus = EncounterObjectStatus.Inactive; emptyCustomChunk.notes = debugDescription; RegionFactory.CreateRegion(escapeChunkGo, regionGameLogicGuid, objectiveGuid, "Region_Withdraw", "regionDef_EvacZone"); bool useDropship = true; OccupyRegionObjective occupyRegionObjective = ObjectiveFactory.CreateOccupyRegionObjective( objectiveGuid, escapeChunkGo, null, playerSpawnerGuid, regionGameLogicGuid, "Withdraw", "Get to the Evac Zone", $"with {ProgressFormat.UNITS_OCCUPYING_SO_FAR}/{ProgressFormat.NUMBER_OF_UNITS_TO_OCCUPY} unit(s)", "The objective for the player to withdraw and complete, or withdraw, the mission", 0, 0, useDropship, new string[] { MissionControl.Instance.IsCustomContractType ? "Player 1" : "player_unit" }, new string[] { "opposing_unit" } ); ObjectiveFactory.CreateContractObjective(occupyRegionObjective); } else { Main.Logger.Log($"[AddWithdrawChunk] 'Chunk_Withdraw' already exists in map. No need to recreate."); } }