From 8cceafb10c6f449f783009af5d45976ffbfacfb9 Mon Sep 17 00:00:00 2001 From: Clevertop Date: Sat, 10 Aug 2024 19:26:53 +1000 Subject: [PATCH] working on command blocks --- Assets/Materials/baseCommand.tres | 12 ++++++++++ Assets/Textures/cobalt_stone_4.png.import | 13 ++++++----- Assets/Textures/crystal_floor_0.png.import | 13 ++++++----- Assets/Textures/crystal_wall_2.png.import | 13 ++++++----- Assets/Textures/ice_0_old.png.import | 13 ++++++----- Commands/command_block.gd | 26 ++++++++++++++++++++++ Commands/command_block.tscn | 22 ++++++++++++++++++ Commands/tool.gd | 12 ++++++++++ Levels/StartingRoom.tscn | 9 +++++++- Scripts/Player.gd | 5 ++++- 10 files changed, 112 insertions(+), 26 deletions(-) create mode 100644 Assets/Materials/baseCommand.tres create mode 100644 Commands/command_block.gd create mode 100644 Commands/command_block.tscn create mode 100644 Commands/tool.gd diff --git a/Assets/Materials/baseCommand.tres b/Assets/Materials/baseCommand.tres new file mode 100644 index 0000000..8198982 --- /dev/null +++ b/Assets/Materials/baseCommand.tres @@ -0,0 +1,12 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://2i80f5wutvco"] + +[ext_resource type="Texture2D" uid="uid://contqwyu7r114" path="res://icon.svg" id="1_ecwuj"] + +[resource] +albedo_texture = ExtResource("1_ecwuj") +emission = Color(1, 1, 1, 1) +subsurf_scatter_strength = 1.0 +uv1_scale = Vector3(3, 2, 1) +uv1_triplanar_sharpness = 0.0583145 +uv2_triplanar_sharpness = 0.170755 +texture_filter = 0 diff --git a/Assets/Textures/cobalt_stone_4.png.import b/Assets/Textures/cobalt_stone_4.png.import index 93dd73c..e694ccd 100644 --- a/Assets/Textures/cobalt_stone_4.png.import +++ b/Assets/Textures/cobalt_stone_4.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://dd150xco2ee5q" -path="res://.godot/imported/cobalt_stone_4.png-2f556b8c80fb9db7f21adb51a7786967.ctex" +path.s3tc="res://.godot/imported/cobalt_stone_4.png-2f556b8c80fb9db7f21adb51a7786967.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Textures/cobalt_stone_4.png" -dest_files=["res://.godot/imported/cobalt_stone_4.png-2f556b8c80fb9db7f21adb51a7786967.ctex"] +dest_files=["res://.godot/imported/cobalt_stone_4.png-2f556b8c80fb9db7f21adb51a7786967.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 diff --git a/Assets/Textures/crystal_floor_0.png.import b/Assets/Textures/crystal_floor_0.png.import index ee6de93..8a31e2f 100644 --- a/Assets/Textures/crystal_floor_0.png.import +++ b/Assets/Textures/crystal_floor_0.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://cuxfe4lobcjrd" -path="res://.godot/imported/crystal_floor_0.png-b744e33cb5e930747430f06e80744c94.ctex" +path.s3tc="res://.godot/imported/crystal_floor_0.png-b744e33cb5e930747430f06e80744c94.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Textures/crystal_floor_0.png" -dest_files=["res://.godot/imported/crystal_floor_0.png-b744e33cb5e930747430f06e80744c94.ctex"] +dest_files=["res://.godot/imported/crystal_floor_0.png-b744e33cb5e930747430f06e80744c94.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 diff --git a/Assets/Textures/crystal_wall_2.png.import b/Assets/Textures/crystal_wall_2.png.import index 34c6873..544829a 100644 --- a/Assets/Textures/crystal_wall_2.png.import +++ b/Assets/Textures/crystal_wall_2.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://dc23iehev1s8w" -path="res://.godot/imported/crystal_wall_2.png-43c04d21b06c37d08c09bdfa81be4afe.ctex" +path.s3tc="res://.godot/imported/crystal_wall_2.png-43c04d21b06c37d08c09bdfa81be4afe.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Textures/crystal_wall_2.png" -dest_files=["res://.godot/imported/crystal_wall_2.png-43c04d21b06c37d08c09bdfa81be4afe.ctex"] +dest_files=["res://.godot/imported/crystal_wall_2.png-43c04d21b06c37d08c09bdfa81be4afe.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 diff --git a/Assets/Textures/ice_0_old.png.import b/Assets/Textures/ice_0_old.png.import index 1bd0b94..b4ca700 100644 --- a/Assets/Textures/ice_0_old.png.import +++ b/Assets/Textures/ice_0_old.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://c1fesrqdpjloa" -path="res://.godot/imported/ice_0_old.png-7cda17758c5aa18a266b9d5b33aba6c0.ctex" +path.s3tc="res://.godot/imported/ice_0_old.png-7cda17758c5aa18a266b9d5b33aba6c0.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Textures/ice_0_old.png" -dest_files=["res://.godot/imported/ice_0_old.png-7cda17758c5aa18a266b9d5b33aba6c0.ctex"] +dest_files=["res://.godot/imported/ice_0_old.png-7cda17758c5aa18a266b9d5b33aba6c0.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 diff --git a/Commands/command_block.gd b/Commands/command_block.gd new file mode 100644 index 0000000..2c78a34 --- /dev/null +++ b/Commands/command_block.gd @@ -0,0 +1,26 @@ +#@tool +extends RigidBody3D +class_name Command_Block + +@export var command_name : String +@export var command_sprite : Texture2D: + set(new_texture): + if command_sprite != null: + command_sprite.changed.disconnect(on_texture_changed) + command_sprite = new_texture + command_sprite.changed.connect(on_texture_changed) + +# Called when the node enters the scene tree for the first time. +func _ready(): + $MeshInstance3D.material_override.albedo_texture = command_sprite + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func on_texture_changed(): + print("meow") + $MeshInstance3D.material_override = $MeshInstance3D.material_override.duplicate() + $MeshInstance3D.material_override.albedo_texture = command_sprite diff --git a/Commands/command_block.tscn b/Commands/command_block.tscn new file mode 100644 index 0000000..8c210b5 --- /dev/null +++ b/Commands/command_block.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=6 format=3 uid="uid://dqvq4ybcpws87"] + +[ext_resource type="Material" uid="uid://2i80f5wutvco" path="res://Assets/Materials/baseCommand.tres" id="1_ksvsv"] +[ext_resource type="Script" path="res://Commands/command_block.gd" id="1_ra6j6"] +[ext_resource type="Script" path="res://Commands/tool.gd" id="3_lrl7m"] + +[sub_resource type="BoxMesh" id="BoxMesh_572kf"] +size = Vector3(0.5, 0.5, 0.5) + +[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_mmdx7"] +points = PackedVector3Array(0.25, 0.25, 0.25, 0.25, 0.25, -0.25, -0.25, 0.25, 0.25, 0.25, -0.25, 0.25, 0.25, -0.25, -0.25, -0.25, 0.25, -0.25, -0.25, -0.25, 0.25, -0.25, -0.25, -0.25) + +[node name="BaseCommand" type="RigidBody3D"] +script = ExtResource("1_ra6j6") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +material_override = ExtResource("1_ksvsv") +mesh = SubResource("BoxMesh_572kf") +script = ExtResource("3_lrl7m") + +[node name="CollisionShape3D3" type="CollisionShape3D" parent="."] +shape = SubResource("ConvexPolygonShape3D_mmdx7") diff --git a/Commands/tool.gd b/Commands/tool.gd new file mode 100644 index 0000000..a8b7a54 --- /dev/null +++ b/Commands/tool.gd @@ -0,0 +1,12 @@ +#@tool +extends Node + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/Levels/StartingRoom.tscn b/Levels/StartingRoom.tscn index 5a834d0..f8274ba 100644 --- a/Levels/StartingRoom.tscn +++ b/Levels/StartingRoom.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=14 format=3 uid="uid://bojbawyoy11i4"] +[gd_scene load_steps=16 format=3 uid="uid://bojbawyoy11i4"] [ext_resource type="Script" path="res://Scripts/ChronoManager.gd" id="1_5b2rd"] [ext_resource type="Material" uid="uid://cr4ra7ijk1uec" path="res://Assets/Materials/floor.tres" id="2_0aj3l"] [ext_resource type="PackedScene" uid="uid://d34smep2ukq7w" path="res://player.tscn" id="2_hsi55"] [ext_resource type="PackedScene" uid="uid://bnlexkofp68gv" path="res://gui.tscn" id="3_60lfp"] +[ext_resource type="PackedScene" uid="uid://dqvq4ybcpws87" path="res://Commands/command_block.tscn" id="5_81jk1"] +[ext_resource type="Texture2D" uid="uid://contqwyu7r114" path="res://icon.svg" id="6_feqb2"] [sub_resource type="BoxMesh" id="BoxMesh_21vdj"] material = ExtResource("2_0aj3l") @@ -74,4 +76,9 @@ shape = SubResource("ConcavePolygonShape3D_mfjp6") [node name="MeshInstance3D" type="MeshInstance3D" parent="Terminal"] mesh = SubResource("BoxMesh_u6v2s") +[node name="BaseCommand" parent="." instance=ExtResource("5_81jk1")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.76166, 1, -1.59377) +command_name = "jump" +command_sprite = ExtResource("6_feqb2") + [connection signal="object_clicked" from="Player" to="." method="_on_player_object_clicked"] diff --git a/Scripts/Player.gd b/Scripts/Player.gd index c4ff2de..4c4eca9 100644 --- a/Scripts/Player.gd +++ b/Scripts/Player.gd @@ -34,7 +34,10 @@ func _physics_process(delta): # interact with stuff if Input.is_action_just_pressed("interact"): if "name" in raycast.get_collider(): - print(raycast.get_collider().name) + if "command_name" in raycast.get_collider(): + print(raycast.get_collider().command_name) + else: + print(raycast.get_collider().name) object_clicked.emit(raycast.get_collider()) else: print("womp womp")