working on command blocks

This commit is contained in:
Clevertop 2024-08-10 19:26:53 +10:00
parent 685d9642dc
commit 8cceafb10c
10 changed files with 112 additions and 26 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

26
Commands/command_block.gd Normal file
View file

@ -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

View file

@ -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")

12
Commands/tool.gd Normal file
View file

@ -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

View file

@ -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"]

View file

@ -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")