//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Private Member Functions //--------------------------------------------------------------------------- private void DoInventoryWindow(int windowID) { OpenCog.BlockSet.BaseBlockSet.OCBlock selected = _builder.SelectedBlock; selected = DrawInventory(_blockSet, ref scrollPosition, selected); _builder.SelectedBlock = selected; GameManager.world.voxels.selectedBlock = selected; }
private void BuildBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block) { renderer.material = block.Atlas.Material; MeshFilter filter = GetComponent <MeshFilter>(); block.Build().ToMesh(filter.mesh); }
// TODO: May need to be re-enabled...hope not, since all blockdata that gets instantiated should get its coordinates too. // public BlockData(Block block) { // this.block = block; // direction = BlockDirection.Z_PLUS; // } public OCBlockData(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i globalPosition) { this.block = block; this._globalX = globalPosition.x; this._globalY = globalPosition.y; this._globalZ = globalPosition.z; direction = OCBlockDirection.Z_PLUS; }
// TODO: May need to be re-enabled...hope not, since all blockdata that gets instantiated should get its coordinates too. // public BlockData(Block block) { // this.block = block; // direction = BlockDirection.Z_PLUS; // } // public OCBlockData() // { // } public OCBlockData Init(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i globalPosition) { this.block = block; this._globalX = globalPosition.x; this._globalY = globalPosition.y; this._globalZ = globalPosition.z; direction = OCBlockDirection.Z_PLUS; return this; }
private static OpenCog.BlockSet.BaseBlockSet.OCBlock DrawInventory(OpenCog.BlockSet.OCBlockSet blockSet, ref UnityEngine.Vector2 scrollPosition, OpenCog.BlockSet.BaseBlockSet.OCBlock selected) { scrollPosition = GUILayout.BeginScrollView(scrollPosition); for (int i = 0, y = 0; i < blockSet.BlockCount; y++) { GUILayout.BeginHorizontal(); for (int x = 0; x < 8; x++, i++) { OpenCog.BlockSet.BaseBlockSet.OCBlock block = blockSet.GetBlock(i); if (DrawBlock(block, block == selected && selected != null)) { selected = block; } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); return(selected); }
private static bool DrawBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, bool selected) { UnityEngine.Rect rect = GUILayoutUtility.GetAspectRect(1f); if (selected) { GUI.Box(rect, GUIContent.none); } UnityEngine.Vector3 center = rect.center; rect.width -= 8; rect.height -= 8; rect.center = center; if (block != null) { return(block.DrawPreview(rect)); } return(false); }
private static bool DrawItem(OpenCog.BlockSet.BaseBlockSet.OCBlock block, bool selected) { Rect position = GUILayoutUtility.GetRect(0, 40, GUILayout.ExpandWidth(true)); if (selected) { GUI.Box(position, GUIContent.none); } GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.alignment = TextAnchor.MiddleLeft; Rect texRect = new Rect(position.x + 4, position.y + 4, position.height - 8, position.height - 8); block.DrawPreview(texRect); Rect labelRect = position; labelRect.xMin = texRect.xMax + 4; GUI.Label(labelRect, block.GetName(), labelStyle); return(Event.current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)); }
public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, int x, int y, int z) { SetBlock(OCBlockData.CreateInstance <OCBlockData>().Init(block, new Vector3i(x, y, z)), x, y, z); }
public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i pos) { SetBlock(OCBlockData.CreateInstance <OCBlockData>().Init(block, pos), pos); }
public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, int x, int y, int z) { SetBlock(new OCBlockData(block, new Vector3i(x, y, z)), x, y, z); }
public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i pos) { SetBlock(new OCBlockData(block, pos), pos); }