public void EnsureFullyGenerated() { if (blockTypes == null) { blockTypes = ScriptableObject.CreateInstance <BlockTypeList>(); } }
/// <summary> /// Called when the BlockWorld behaviour is enabled. /// </summary> private void OnEnable() { if (m_WorldContainer != null) { return; // Already enabled } var chunkSize = new GridSize(4); var world = new World(chunkSize); var blockList = new BlockTypeList(); var remesh = new RemeshHandler(); var database = new WorldDatabase("/home/thedudefromci/Bones3/TestWorld"); remesh.AddDistributor(new StandardDistributor()); m_WorldContainer = new WorldContainer(world, remesh, blockList, database); m_WorldContainer.BlockContainerProvider.OnBlockContainerCreated += OnChunkCreated; m_WorldContainer.BlockContainerProvider.OnBlockContainerDestroyed += OnChunkDestroyed; m_WorldContainer.RemeshHandler.OnRemeshFinish += OnRemeshFinished; #if UNITY_EDITOR if (!Application.isPlaying) { UnityEditor.EditorApplication.update += Update; } #endif }
private void AddToCumulative(TargetType type, BlockTypeList blocks) { if (blocks == null) { return; } Log.DebugLog("adding to type: " + type + ", count: " + blocks.BlockNamesContain.Length); if (type == TargetType.AllGrid) { AddToCumulative(TargetType.SmallGrid, blocks); AddToCumulative(TargetType.LargeGrid, blocks); AddToCumulative(TargetType.Station, blocks); return; } BlockTypeList targetBlocks; if (m_cumulative_targeting.TryGetValue(type, out targetBlocks)) { m_cumulative_targeting[type] = BlockTypeList.Union(targetBlocks, blocks); } else { m_cumulative_targeting[type] = blocks; } }
public void AddBlock_WrongID_Error() { var list = new BlockTypeList(); Assert.Throws <ArgumentException>(() => list.AddBlockType(new BlockBuilder(5).Build())); }
/// <summary> /// Creates a new block type preview object. /// </summary> /// <param name="blockTypes">The block type list to reference when rendering.</param> public BlockTypesPreview(BlockTypeList blockTypes) { this.blockTypes = blockTypes; EditorUtility.SetCameraAnimateMaterials(previewUtility.camera, true); remeshHandler = new RemeshHandler(); remeshHandler.AddDistributor(new StandardDistributor()); remeshHandler.OnRemeshFinish += OnRemeshFinish; }
public void RemoveProtectedBlockType_Error() { var list = new BlockTypeList(); Assert.Throws <AccessViolationException>(() => list.RemoveBlockType(list.GetBlockType(0))); Assert.Throws <AccessViolationException>(() => list.RemoveBlockType(list.GetBlockType(1))); }
public void RemoveBlock() { var list = new BlockTypeList(); var block = new BlockBuilder(list.NextBlockID) .Build(); list.AddBlockType(block); list.RemoveBlockType(block); Assert.AreEqual(2, list.Count); }
public void RemoveBlock_Null() { var list = new BlockTypeList(); var block = new BlockBuilder(list.NextBlockID) .Name("Iron") .Build(); list.AddBlockType(block); list.RemoveBlockType(null); Assert.AreEqual(3, list.Count); }
public void AddBlock() { var list = new BlockTypeList(); var block = new BlockBuilder(list.NextBlockID) .Name("Coal") .Build(); list.AddBlockType(block); Assert.AreEqual(3, list.Count); Assert.AreEqual(2, block.ID); Assert.AreEqual(block, list.GetBlockType(2)); }
/// <summary> /// Called when the BlockWorld behaviour is enabled. /// </summary> private void OnEnable() { var chunkSize = new GridSize(4); var world = new World(chunkSize); var blockList = new BlockTypeList(); var remesh = new RemeshHandler(); var database = new WorldDatabase("/home/thedudefromci/Bones3/TestWorld"); remesh.AddDistributor(new StandardDistributor()); WorldContainer = new WorldContainer(world, remesh, blockList, database); WorldContainer.BlockContainerProvider.OnBlockContainerCreated += OnChunkCreated; WorldContainer.BlockContainerProvider.OnBlockContainerDestroyed += OnChunkDestroyed; WorldContainer.RemeshHandler.OnRemeshFinish += OnRemeshFinished; }
public ProgrammableBlock(IMyCubeBlock block) : base(block) { m_logger = new Logger(GetType().Name, block); m_progBlock = block as Ingame.IMyProgrammableBlock; m_networkClient = new RelayClient(block, HandleMessage); byte index = 0; m_handleDetectedTerminal_ev = new EntityValue<bool>(block, index++, UpdateVisual); m_blockCountList_ev = new EntityStringBuilder(block, index++, () => { UpdateVisual(); m_blockCountList_btl = new BlockTypeList(m_blockCountList_sb.ToString().LowerRemoveWhitespace().Split(',')); }); Registrar.Add(block, this); }
public void DefaultBlockTypes() { var list = new BlockTypeList(); Assert.AreEqual(2, list.Count); Assert.AreEqual("Ungenerated", list.GetBlockType(0).Name); Assert.AreEqual(0, list.GetBlockType(0).ID); Assert.IsFalse(list.GetBlockType(0).IsSolid); Assert.IsFalse(list.GetBlockType(0).IsVisible); Assert.AreEqual("Air", list.GetBlockType(1).Name); Assert.AreEqual(1, list.GetBlockType(1).ID); Assert.IsFalse(list.GetBlockType(1).IsSolid); Assert.IsFalse(list.GetBlockType(1).IsVisible); }
public void CleanupRemesh() { // Clear references to avoid memory leaks chunk = null; filter = null; render = null; collider = null; materialArray = null; blockTypes = null; // Clear lists to prepare for next pool use materialsUsed.Clear(); toSort.Clear(); // Mark object as unused in pool activeInPool = false; }
public void Initalize(Transform player, Chunk chunk) { this.chunk = chunk; render = chunk.GetComponent <Renderer>(); collider = chunk.GetComponent <MeshCollider>(); filter = chunk.GetComponent <MeshFilter>(); blockTypes = chunk.BlockTypes; Array.Copy(chunk.GetBlocksRaw(), blocks, blocks.Length); Array.Copy(chunk.GetBlockStatesRaw(), blockStates, blockStates.Length); Chunk side; for (int i = 0; i < 6; i++) { side = chunk.GetNearbyChunk(i); if (side == null) { for (int j = 0; j < 4096; j++) { nearbyBlocks[i * 4096 + j] = 0; nearbyBlockStates[i * 4096 + j] = 0; } } else { Array.Copy(side.GetBlocksRaw(), 0, nearbyBlocks, i * 4096, 4096); Array.Copy(side.GetBlockStatesRaw(), 0, nearbyBlockStates, i * 4096, 4096); } } chunkX = chunk.chunkX; chunkY = chunk.chunkY; chunkZ = chunk.chunkZ; emptyChunk = chunk.EmptyChunk; }
private void AddToCumulative(TargetType type, BlockTypeList blocks) { m_logger.debugLog("adding to type: " + type + ", count: " + blocks.BlockNamesContain.Length); if (type == TargetType.AllGrid) { AddToCumulative(TargetType.SmallGrid, blocks); AddToCumulative(TargetType.LargeGrid, blocks); AddToCumulative(TargetType.Station, blocks); return; } BlockTypeList targetBlocks; if (m_cumulative_targeting.TryGetValue(type, out targetBlocks)) m_cumulative_targeting[type] = BlockTypeList.Union(targetBlocks, blocks); else m_cumulative_targeting[type] = blocks; }
public void OnObjectCloned() { // Clone block types blockTypes = BlockTypes.Copy(); }