private static bool DrawItem(Rect position, OCBlock block, bool selected, int index) { Rect texturePosition = position; texturePosition.height = texturePosition.width; Rect labelPosition = position; labelPosition.yMin += texturePosition.height; if (selected) { EditorGUIUtils.FillRect(labelPosition, new Color(61 / 255f, 128 / 255f, 223 / 255f)); } if (block != null) { block.DrawPreview(texturePosition); GUI.Label(labelPosition, block.GetName()); } else { EditorGUIUtils.FillRect(texturePosition, Color.grey); GUI.Label(labelPosition, "Null"); } if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) { Event.current.Use(); return(true); } return(false); }
public static void DrawBlockEditor(OCBlock block, OCBlockSet blockSet) { UnityEngine.GUILayout.BeginVertical(UnityEngine.GUI.skin.box); { string name = EditorGUILayout.TextField("Name", block.GetName()); block.SetName(FixNameString(name)); if (block is OCGlassBlock) { OCGlassBlock glass = (OCGlassBlock)block; UnityEngine.GameObject interior = (UnityEngine.GameObject)EditorGUILayout.ObjectField("Interior", glass.GetInterior(), typeof(UnityEngine.GameObject), true, null); glass.SetInterior(interior); } int atlas = BlockEditorUtils.Popup("Atlas", block.AtlasID, blockSet.Atlases); block.AtlasID = atlas; int light = EditorGUILayout.IntField("Light", block.GetLight()); block.SetLight(light); } UnityEngine.GUILayout.EndVertical(); UnityEngine.Texture texture = block.GetTexture(); if (texture != null) { FieldInfo field = DrawFacesList(block, texture); int face = (int)field.GetValue(block); DrawFaceEditor(ref face, block.Atlas, ref atlasMatrix); field.SetValue(block, face); } }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Private Member Functions //--------------------------------------------------------------------------- private static void Build(OpenCog.Map.OCChunk chunk, bool onlyLight) { OpenCog.Map.OCMap map = chunk.GetMap(); _meshData.Clear(); for (int z = 0; z < OpenCog.Map.OCChunk.SIZE_Z; z++) { for (int y = 0; y < OpenCog.Map.OCChunk.SIZE_Y; y++) { for (int x = 0; x < OpenCog.Map.OCChunk.SIZE_X; x++) { OCBlockData blockData = chunk.GetBlock(x, y, z); if (blockData != null) { OCBlock block = blockData.block; if (block != null) { Vector3i localPos = new Vector3i(x, y, z); Vector3i worldPos = OpenCog.Map.OCChunk.ToWorldPosition(chunk.GetPosition(), localPos); if (worldPos.y > 0) { block.Build(localPos, worldPos, map, _meshData, onlyLight); } } } } } } }
void Awake() { UnityEngine.Debug.Log("OCWorldGenerator::Awake!"); map = GetComponent <OpenCog.Map.OCMap>(); if (MapName != string.Empty) { //Debug.Log ("In WorldGenerator, MapName defined"); OCFileTerrainGenerator fileTerrainGenerator = new OCFileTerrainGenerator(map, MapName); fileTerrainGenerator.LoadLevel(); } else { terrainGenerator = new OCTerrainGenerator(map); OCBlock[] woodBlocks = map.GetBlockSet().GetBlocks("Wood"); OCBlock[] leavesBlocks = map.GetBlockSet().GetBlocks("Leaves"); treeGenerator = new OCTreeGenerator[Math.Max(woodBlocks.Length, leavesBlocks.Length)]; for (int i = 0; i < treeGenerator.Length; i++) { OCBlock wood = woodBlocks[i % woodBlocks.Length]; OCBlock leaves = leavesBlocks[i % leavesBlocks.Length]; treeGenerator[i] = new OCTreeGenerator(map, wood, leaves); } } }
//NOTE: this function pulls the weight of actually destroying blocks for us. It is applied to the OCActions of a character; not to blocks themselves. public void DestroyBlock(Vector3i?point) { if (point.HasValue) { OCMap map = OCMap.Instance; //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault(); //for updating goal controllers after deletion. OCBlock blockType = map.GetBlock(point.Value).block; OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController)); //actually sets the block to null and recomputes the chunk. Debug.Log(OCLogSymbol.DEBUG + "DeleteSelectedVoxel called from CreateBlockEffect"); GameManager.world.voxels.DeleteSelectedVoxel(point.Value); //re-update goals concerned with this block type foreach (OCGoalController goalController in goalControllers) { if (goalController.GoalBlockType == blockType) { goalController.FindGoalBlockPositionInChunks(map.GetChunks()); } } blocksDestroyed++; } }
private static OCBlock ReadBlock(XmlNode node) { System.Type type = System.Type.GetType("OpenCog.BlockSet.BaseBlockSet." + node.Name); // if (type == null) // { // Debug.Log("Failed to get a type for block '" + node.Name + "', attempting lookup with unqualified name..."); // // type = System.Type.GetType(node.Name); // // if (type == null) // Debug.Log("Nope, that failed too...type is still null..."); // else // Debug.Log("Wahey, that actually worked!"); // } // // // // // if (type != null) // Debug.Log("Reading block, name = " + node.Name + ", type = " + type.ToString()); // else // Debug.Log("Reading block, name = " + node.Name + ", type == null"); OCBlock block = (OCBlock)ScriptableObject.CreateInstance(type); foreach (XmlNode childNode in node) { ReadField(childNode, block); } return(block); }
//TEST THE INITIALIZATION OF THESE VARIABLES public bool TestInitialization() { //OTHER EMBODIMENT STUFF //<none> //OTHER BATTERY STUFF //calculate the place of the battery int hudPos = (int)this.batteryBlockOnHUD.x + (int)this.batteryBlockOnHUD.y * 8; batteryBlock = OCMap.Instance.GetBlockSet().GetBlock(hudPos); //create the fun iterator which will make coding this easy List <object>[] needsInit = new List <object> [numTests]; //btw we have to init this too... for (int i = 0; i < numTests; i++) { needsInit[i] = new List <object>(); } //EMBODIMENT test stuff needsInit[(int)TestTypes.EMBODIMENT].Add(embodimentPrefab); //BATTERY test stuff needsInit[(int)TestTypes.BATTERY].Add(batteryBlock); //FOR THE PLAN //<none> //FOR THE SECOND PLAN //<none> bool initResult = true; //now iterate through every test (represented above in the List by []) for (uint i = 0; i < numTests; i++) { //checkout each mandatory object we added to the list foreach (object o in needsInit[i]) { //if it's null, complain loudly if (o == null) { Debug.LogError("Disabling test " + testConfigNames[i] + "owed to null parameters. Check the inspector. Unit test will automatically fail."); //turn off the test so we don't hurt ourselves configurations[i] = false; //and automatically fail the unit test, cause something be borked. results[i] = false; result = false; //since result could have been set strangely prior to this, we'll be returning a kosher variable instead initResult = false; } } } return(initResult); }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Private Member Functions //--------------------------------------------------------------------------- private static bool IsFaceVisible(OpenCog.Map.OCMap map, Vector3i nearPos) { OCBlockData blockData = map.GetBlock(nearPos); if (blockData == null) { return(false); } OCBlock block = blockData.block; return(!(block is OCCubeBlock) || block.IsAlpha()); }
private static void Insert(IList <OCBlock> items, int newIndex, int oldIndex) { List <OCBlock> list = new List <OCBlock>(items); OCBlock block = list[oldIndex]; list.RemoveAt(oldIndex); list.Insert(newIndex, block); for (int i = 0; i < items.Count; i++) { items[i] = list[i]; } }
private void DrawBlockSet(OCBlockSet blockSet) { GUILayout.BeginVertical(GUI.skin.box); int oldSelectedBlock = selectedBlock; // Next line pushes the blockSet to BlockSetViewer selectedBlock = OpenCog.BlockSetViewer.SelectionGrid(blockSet, selectedBlock, GUILayout.MinHeight(200), GUILayout.MaxHeight(300)); if (selectedBlock != oldSelectedBlock) { GUIUtility.keyboardControl = 0; } EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); foreach (Type type in blockTypes) { string name = type.Name; if (name.EndsWith("Block")) { name = name.Substring(0, name.Length - 5); } if (GUILayout.Button(name)) { OCBlock newBlock = (OCBlock)CreateInstance(type); newBlock.SetName("New " + type.ToString()); newBlock.Init(blockSet); OCBlock[] blocks = blockSet.Blocks; ArrayUtility.Add <OCBlock>(ref blocks, newBlock); blockSet.Blocks = blocks; selectedBlock = blocks.Length - 1; EditorGUIUtility.keyboardControl = 0; GUI.changed = true; } } GUILayout.EndHorizontal(); if (GUILayout.Button("Remove")) { OCBlock[] blocks = blockSet.Blocks; ArrayUtility.RemoveAt <OCBlock>(ref blocks, selectedBlock); blockSet.Blocks = blocks; selectedBlock = Mathf.Clamp(selectedBlock, 0, blocks.Length - 1); GUI.changed = true; } GUILayout.EndVertical(); }
void Awake() { UnityEngine.Debug.Log("OCWorldGenerator::Awake!"); map = GetComponent <OpenCog.Map.OCMap>(); //map = OCMap.Instance; if (MapName != string.Empty) { //Debug.Log ("In WorldGenerator, MapName defined"); OCFileTerrainGenerator fileTerrainGenerator = new OCFileTerrainGenerator(map, MapName); fileTerrainGenerator.LoadLevel(); } else { terrainGenerator = new OCTerrainGenerator(map); OCBlock[] woodBlocks = map.GetBlockSet().GetBlocks("Wood"); OCBlock[] leavesBlocks = map.GetBlockSet().GetBlocks("Leaves"); treeGenerator = new OCTreeGenerator[Math.Max(woodBlocks.Length, leavesBlocks.Length)]; for (int i = 0; i < treeGenerator.Length; i++) { OCBlock wood = woodBlocks[i % woodBlocks.Length]; OCBlock leaves = leavesBlocks[i % leavesBlocks.Length]; treeGenerator[i] = new OCTreeGenerator(map, wood, leaves); } } TextAsset configFile = (TextAsset)Resources.Load("embodiment"); if (configFile != null) { OCConfig.Instance.LoadFromTextAsset(configFile); } OCConfig.Instance.LoadFromCommandLine(); string testValue = OCConfig.Instance.get("test"); string quitValue = OCConfig.Instance.get("quit"); if (testValue == "internal_XGA") { Screen.SetResolution(1024, 768, false); Console.WriteLine("Level Loaded..."); } if (quitValue == "true") { Application.Quit(); } }
private static List <FieldInfo> GetFaces(OCBlock block) { FieldInfo[] fields = block.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); List <FieldInfo> list = new List <FieldInfo>(); foreach (FieldInfo field in fields) { if (field.FieldType == typeof(int)) { list.Add(field); } } return(list); }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Accessors and Mutators //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Public Member Functions //--------------------------------------------------------------------------- public void CreateBlock(Vector3i?point) { if (point.HasValue) { OCMap map = (OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault(); OCBlock block = map.GetBlockSet().GetBlock(_BlockType); //block.SetDirection(GetDirection(-gameObject.transform.forward)); OCBlockData blockData = new OCBlockData(block, VectorUtil.Vector3ToVector3i(point.Value)); map.SetBlockAndRecompute(blockData, point.Value); } }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Public Member Functions //--------------------------------------------------------------------------- public IEnumerator Start() { _map = (OCMap)GameObject.FindObjectOfType(typeof(OCMap)); _goalBlockType = _map.GetBlockSet().GetBlock(_blockType); while (Application.isPlaying) { yield return(new WaitForSeconds(1.0f)); UpdateGoal(); } }
private static XmlNode WriteBlock(OCBlock block, XmlDocument document) { XmlNode node = document.CreateElement(block.GetType().Name); FieldInfo[] fields = GetFields(block.GetType()); foreach (FieldInfo field in fields) { XmlNode childNode = WriteField(field, block, document); if (childNode != null) { node.AppendChild(childNode); } } return(node); }
private static bool IsFaceVisible(OpenCog.Map.OCMap map, OpenCog.BlockSet.BaseBlockSet.OCCubeBlock.CubeFace face, Vector3i nearPos) { if (face == OpenCog.BlockSet.BaseBlockSet.OCCubeBlock.CubeFace.Bottom || face == OpenCog.BlockSet.BaseBlockSet.OCCubeBlock.CubeFace.Top) { OCBlock block = map.GetBlock(nearPos).block; if (block is OCCubeBlock && !block.IsAlpha()) { return(false); } if (block is OCCactusBlock) { return(false); } } return(true); }
private static FieldInfo DrawFacesList(OCBlock block, UnityEngine.Texture texture) { List <FieldInfo> fields = GetFaces(block); UnityEngine.Rect[] faces = new UnityEngine.Rect[fields.Count]; string[] names = new string[fields.Count]; for (int i = 0; i < fields.Count; i++) { int pos = (int)fields[i].GetValue(block); faces[i] = block.ToRect(pos); names[i] = FixNameString(fields[i].Name); } selectedFace = UnityEngine.Mathf.Clamp(selectedFace, 0, fields.Count - 1); selectedFace = DrawFacesList(texture, faces, names, selectedFace); return(fields[selectedFace]); }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Public Member Functions //--------------------------------------------------------------------------- public IEnumerator Start() { _map = OCMap.Instance; //(OCMap)GameObject.FindObjectOfType (typeof(OCMap)); _goalBlockType = _map.GetBlockSet().GetBlock(_blockType); List3D <OCChunk> chunks = _map.GetChunks(); // Since this is probably bogging down the gameplay, switch it to block creation only. FindGoalBlockPositionInChunks(chunks); while (Application.isPlaying) { yield return(new WaitForSeconds(1.0f)); UpdateGoal(); } // yield return 0; }
//--------------------------------------------------------------------------- #region Private Member Data //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Accessors and Mutators //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Public Member Functions //--------------------------------------------------------------------------- public void DestroyBlock(Vector3i?point) { if (point.HasValue) { OCMap map = OCMap.Instance; //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault(); OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController)); OCBlock blockType = map.GetBlock(point.Value).block; map.SetBlockAndRecompute(OCBlockData.CreateInstance <OCBlockData>().Init(null, point.Value), point.Value); foreach (OCGoalController goalController in goalControllers) { if (goalController.GoalBlockType == blockType) { goalController.FindGoalBlockPositionInChunks(map.GetChunks()); } } } }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Public Member Functions //--------------------------------------------------------------------------- public void CreateBlock(Vector3i?point) { if (point.HasValue) { OCMap map = OCMap.Instance; //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault(); OCBlock block = map.GetBlockSet().GetBlock(_BlockType); OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController)); foreach (OCGoalController goalController in goalControllers) { if (goalController.GoalBlockType == block) { goalController.FindGoalBlockPositionInChunks(map.GetChunks()); } } Debug.Log(OCLogSymbol.DEBUG + "AddSelectedVoxel called from CreateBlockEffect"); GameManager.world.voxels.AddSelectedVoxel(point.Value, -transform.forward, block); } }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Public Member Functions //--------------------------------------------------------------------------- public void CreateBlock(Vector3i?point) { if (point.HasValue) { OCMap map = OCMap.Instance; //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault(); OCBlock block = map.GetBlockSet().GetBlock(_BlockType); OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController)); foreach (OCGoalController goalController in goalControllers) { if (goalController.GoalBlockType == block) { goalController.FindGoalBlockPositionInChunks(map.GetChunks()); } } //block.SetDirection(GetDirection(-gameObject.transform.forward)); OCBlockData blockData = OCBlockData.CreateInstance <OCBlockData>().Init(block, VectorUtil.Vector3ToVector3i(point.Value)); map.SetBlockAndRecompute(blockData, point.Value); } }
/// <summary> /// This function is responsible for adding a voxel to the map. Because our voxel engine is about to change, this function will take two approaches /// to reducing later refactoring, we try to pass only OCBlock (We would have had to written a lot of code to get around that) and /// we wrap a protected AddSelectedVoxelPixelland to mentally remind ourselves that we want to replace this in the future, /// and we should not be doing a lot of 'work' here. /// </summary> public void AddSelectedVoxel(Vector3 location, Vector3 direction, OCBlock type) { AddSelectedVoxelPixelland(location, direction, type); }
protected void AddSelectedVoxelPixelland(Vector3 location, Vector3 direction, OCBlock type) { //create a block to fill with dataz OCBlockData block = OCBlockData.CreateInstance <OCBlockData>(); //get the location in vector3i form Vector3i location3i = VectorUtil.Vector3ToVector3i(location); //initialize the block block.Init(type, location3i); //set its direction (which should be calculated using GetDirection on -transform.forward) block.SetDirection(direction); //and set the block map.SetBlockAndRecompute(block, location3i); }
//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Private Member Functions //--------------------------------------------------------------------------- private static bool IsFaceVisible(OpenCog.Map.OCMap map, Vector3i nearPos) { OCBlock block = map.GetBlock(nearPos).block; return(!(block is OCCubeBlock) || block.IsAlpha()); }
public void LoadLevel() { int verticalOffset = 85; Debug.Log("About to load level folder: " + _fullMapPath + "."); Substrate.AnvilWorld mcWorld = Substrate.AnvilWorld.Create(_fullMapPath); Substrate.AnvilRegionManager mcAnvilRegionManager = mcWorld.GetRegionManager(); OpenCog.BlockSet.OCBlockSet blockSet = _map.GetBlockSet(); //_map.GetSunLightmap().SetSunHeight(20, 4, 4); int createCount = 0; System.Collections.Generic.Dictionary <int, int> unmappedBlockTypes = new System.Collections.Generic.Dictionary <int, int>(); //Debug.Log("In LoadLevel, there are " + blockSet.BlockCount + " blocks available."); foreach (Substrate.AnvilRegion mcAnvilRegion in mcAnvilRegionManager) { // Loop through x-axis of chunks in this region for (int iMCChunkX = 0; iMCChunkX < mcAnvilRegion.XDim; iMCChunkX++) { // Loop through z-axis of chunks in this region. for (int iMCChunkZ = 0; iMCChunkZ < mcAnvilRegion.ZDim; iMCChunkZ++) { // Retrieve the chunk at the current position in our 2D loop... Substrate.ChunkRef mcChunkRef = mcAnvilRegion.GetChunkRef(iMCChunkX, iMCChunkZ); if (mcChunkRef != null) { if (mcChunkRef.IsTerrainPopulated) { // Ok...now to stick the blocks in... int iMCChunkY = 0; OCChunk chunk = null; //new OCChunk(_map, new Vector3i(iMCChunkX, iMCChunkY, iMCChunkZ)); OCChunk lastChunk = null; Vector3i chunkPos = new Vector3i(mcAnvilRegion.ChunkGlobalX(iMCChunkX), iMCChunkY + verticalOffset, mcAnvilRegion.ChunkGlobalZ(iMCChunkZ)); Vector3i lastChunkPos = Vector3i.zero; chunk = _map.GetChunkInstance(chunkPos); for (int iMCChunkInternalY = 0; iMCChunkInternalY < mcChunkRef.Blocks.YDim; iMCChunkInternalY++) { if (iMCChunkInternalY / OCChunk.SIZE_Y > iMCChunkY) { lastChunk = chunk; lastChunkPos = chunkPos; chunkPos = new Vector3i(mcAnvilRegion.ChunkGlobalX(iMCChunkX), (iMCChunkInternalY + verticalOffset) / OCChunk.SIZE_Y, mcAnvilRegion.ChunkGlobalZ(iMCChunkZ)); chunk = _map.GetChunkInstance(chunkPos); } for (int iMCChunkInternalX = 0; iMCChunkInternalX < mcChunkRef.Blocks.XDim; iMCChunkInternalX++) { for (int iMCChunkInternalZ = 0; iMCChunkInternalZ < mcChunkRef.Blocks.ZDim; iMCChunkInternalZ++) { int iBlockID = mcChunkRef.Blocks.GetID(iMCChunkInternalX, iMCChunkInternalY, iMCChunkInternalZ); if (iBlockID != 0) { Vector3i blockPos = new Vector3i(iMCChunkInternalX, iMCChunkInternalY % OCChunk.SIZE_Y, iMCChunkInternalZ); int ourBlockID = -1; // switch (iBlockID) // { // case 3: // Dirt to first grass // ourBlockID = 1; // break; // case 12: // Grass to grass // ourBlockID = 1; // break; // case 13: // Gravel to stone // ourBlockID = 4; // break; // case 1: // Stone to second stone // ourBlockID = 5; // break; // case 16: // Coal ore to fungus // ourBlockID = 17; // break; // case 15: // Iron ore to pumpkin // ourBlockID = 20; // break; // case 9: // Water to water // ourBlockID = 8; // //Debug.Log ("Creating some water at [" + blockPos.x + ", " + blockPos.y + ", " + blockPos.z + "]"); // break; //// case 2: //// iBlockID = 16; //// break; //// case 4: //// iBlockID = 16; //// break; //// case 18: //// iBlockID = 16; //// break; // default: // { // //Debug.Log ("Unmapped BlockID: " + iBlockID); // // if (!unmappedBlockTypes.ContainsKey (iBlockID)) // { // unmappedBlockTypes.Add (iBlockID, 1); // } // else // { // unmappedBlockTypes[iBlockID] += 1; // } // // break; // } // } if (mcToOCBlockDictionary.ContainsKey(iBlockID)) { ourBlockID = mcToOCBlockDictionary[iBlockID]; } else { if (!unmappedBlockTypes.ContainsKey(iBlockID)) { unmappedBlockTypes.Add(iBlockID, 1); } else { unmappedBlockTypes[iBlockID] += 1; } } if (ourBlockID != -1) { OCBlock newBlock = blockSet.GetBlock(ourBlockID); //OCBlockData block = new OpenCog.Map.OCBlockData(newBlock, blockPos); OCBlockData block = (OCBlockData)OCScriptableObject.CreateInstance <OCBlockData>(); block.Init(newBlock, blockPos); chunk.SetBlock(block, blockPos); OpenCog.Map.Lighting.OCLightComputer.RecomputeLightAtPosition(_map, blockPos); if (block.block.GetName() == "Battery") { GameObject batteryPrefab = OCMap.Instance.BatteryPrefab; if (batteryPrefab == null) { UnityEngine.Debug.Log("OCBuilder::Update, batteryPrefab == null"); } else { GameObject battery = (GameObject)GameObject.Instantiate(batteryPrefab); battery.transform.position = blockPos; battery.name = "Battery"; battery.transform.parent = OCMap.Instance.BatteriesSceneObject.transform; } } if (block.block.GetName() == "Hearth") { GameObject hearthPrefab = OCMap.Instance.HearthPrefab; if (hearthPrefab == null) { UnityEngine.Debug.Log("OCBuilder::Update, hearthPrefab == null"); } else { GameObject hearth = (GameObject)GameObject.Instantiate(hearthPrefab); hearth.transform.position = blockPos; hearth.name = "Hearth"; hearth.transform.parent = OCMap.Instance.HearthsSceneObject.transform; } } createCount += 1; } } } // End for (int iMCChunkInternalZ = 0; iMCChunkInternalZ < mcChunkRef.Blocks.ZDim; iMCChunkInternalZ++) } // End for (int iMCChunkInternalY = 0; iMCChunkInternalY < mcChunkRef.Blocks.YDim; iMCChunkInternalY++) string chunkCoord = chunkPos.x + ", " + chunkPos.z; if (!chunkList.ContainsKey(chunkCoord)) { chunkList.Add(chunkCoord, chunkPos); } if (iMCChunkY < iMCChunkInternalY / OCChunk.SIZE_Y) { _map.Chunks.AddOrReplace(lastChunk, lastChunkPos); _map.UpdateChunkLimits(lastChunkPos); _map.SetDirty(lastChunkPos); iMCChunkY = iMCChunkInternalY / OCChunk.SIZE_Y; } } // End for (int iMCChunkInternalX = 0; iMCChunkInternalX < mcChunkRef.Blocks.XDim; iMCChunkInternalX++) } // End if (mcChunkRef.IsTerrainPopulated) } // End if (mcChunkRef != null) } // End for (int iMCChunkZ = 0; iMCChunkZ < mcAnvilRegion.ZDim; iMCChunkZ++) } // End for (int iMCChunkX = 0; iMCChunkX < mcAnvilRegion.XDim; iMCChunkX++) } // End foreach( Substrate.AnvilRegion mcAnvilRegion in mcAnvilRegionManager ) foreach (Vector3i chunkToLight in chunkList.Values) { OpenCog.Map.Lighting.OCChunkSunLightComputer.ComputeRays(_map, chunkToLight.x, chunkToLight.z); OpenCog.Map.Lighting.OCChunkSunLightComputer.Scatter(_map, null, chunkToLight.x, chunkToLight.z); } foreach (System.Collections.Generic.KeyValuePair <int, int> unmappedBlockData in unmappedBlockTypes) { UnityEngine.Debug.Log("Unmapped BlockID '" + unmappedBlockData.Key + "' found " + unmappedBlockData.Value + " times."); } Debug.Log("Loaded level: " + _fullMapPath + ", created " + createCount + " blocks."); _map.AddColliders(); } // End public void LoadLevel()