/// <summary> /// On inspector GUI /// </summary> public override void OnInspectorGUI() { base.OnInspectorGUI(); if (target is IBlocksPrefabObject blocks_prefab) { blocks_prefab.Initialize(); WorldManagerScript world_manager = WorldManagerScript.Instance; if (world_manager && world_manager.FollowTransformController) { bool is_showing_grid = (world_manager.ShowingBlocksPrefab == blocks_prefab); if (GUILayout.Toggle(is_showing_grid, "Show grid")) { world_manager.ShowingBlocksPrefab = blocks_prefab; } else if (is_showing_grid) { world_manager.ShowingBlocksPrefab = null; } if (GUILayout.Button("Spawn in world")) { BlockID blockID = world_manager.FollowTransformController.BlockID; world_manager.SetBlocks(new BlockID(blockID.X + blocks_prefab.Offset.x, blockID.Y + blocks_prefab.Offset.y, blockID.Z + blocks_prefab.Offset.z), blocks_prefab.Size, blocks_prefab.Blocks, ESetBlocksOperation.FillEmpty); } if (GUILayout.Button("Save from world")) { // TODO } } } serializedObject.ApplyModifiedProperties(); }
// Start is called before the first frame update void Start() { PLT = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerLocationTracker>(); WMS = GameObject.FindGameObjectWithTag("WorldManager").GetComponent <WorldManagerScript>(); EnvironmentObjects = transform.parent.parent.parent.GetChild(1).gameObject; CurrentTerain = transform.parent.parent.parent.gameObject; }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } filePath = Application.persistentDataPath + "/Savedata/"; Application.targetFrameRate = 120; worldObjects = Resources.LoadAll <GameObject>("WorldObjects"); }
/// <summary> /// On GUI /// </summary> private void OnGUI() { WorldManagerScript world_manager = WorldManagerScript.Instance; if (world_manager) { chunkID = (ChunkID)(EditorGUILayout.Vector3IntField("Chunk ID", (Vector3Int)chunkID)); if (GUILayout.Button("Find discrepencies")) { fileBlocksTask = world_manager.IO.CreateReadChunkBlocksTask(chunkID); generatedBlocksTask = world_manager.GetGeneratedBlocksTask(chunkID); } GUILayout.Label($"File blocks task status: { ((fileBlocksTask == null) ? "Not running" : fileBlocksTask.Status.ToString()) }"); GUILayout.Label($"Generated blocks task status: { ((generatedBlocksTask == null) ? "Not running" : generatedBlocksTask.Status.ToString()) }"); if ((fileBlocksTask != null) && (generatedBlocksTask != null)) { if (fileBlocksTask.IsCompleted && generatedBlocksTask.IsCompleted) { StringBuilder output_string_builder = new StringBuilder(); BlockData[] file_blocks = fileBlocksTask.Result; BlockData[] generated_blocks = generatedBlocksTask.Result; fileBlocksTask = null; generatedBlocksTask = null; output_string_builder.AppendLine($"File block count: { file_blocks.Length }"); output_string_builder.AppendLine($"Generated block count: { generated_blocks.Length }"); if (file_blocks.Length == generated_blocks.Length) { for (int index = 0; index < file_blocks.Length; index++) { BlockData file_block = file_blocks[index]; BlockData generated_block = generated_blocks[index]; if (file_block != generated_block) { output_string_builder.AppendLine($"File block is { (file_block.IsABlock ? file_block.Block.Key : "nothing") } with { file_block.Health } health but generated block is { (generated_block.IsABlock ? generated_block.Block.Key : "nothing") } with { generated_block.Health } health."); } } output_string_builder.Append("Finished comparing all blocks."); } else { output_string_builder.Append("File blocks count does not match generated block count."); } output = output_string_builder.ToString(); output_string_builder.Clear(); } } GUILayout.TextArea(output); } }
// Start is called before the first frame update void Start() { locationList.Add(new int[] { 0, 0 }); WMScript = GameObject.Find("WorldManager").GetComponent <WorldManagerScript>(); WMScript.AddTile(GameObject.FindGameObjectWithTag("StartTile")); }