1
0
Fork 0
This commit is contained in:
me4tw 2024-03-14 21:50:53 +10:00
commit a6915e68b4
7 changed files with 1678 additions and 0 deletions

29
FullscreenToggler.gd Normal file
View File

@ -0,0 +1,29 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
#InputMap.action_get_events()
var hotkey = ProjectSettings.get_setting("input/HotKey_ToggleFullscreen")
print(InputMap.action_get_events("character_forwards"))
print(InputMap.action_get_events("HotKey_ToggleFullscreen"))
if hotkey == null:
print("PLEASE GO Project->Project Settings... , Input Map, and add HotKey_ToggleFullscreen")
InputMap.add_action("HotKey_ToggleFullscreen")
#InputMap.action_add_event()
print(hotkey)
var temporarl_deadzone : float = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
#Returns true when the user has started pressing the action event in the current frame or physics tick. It will only return true on the frame or tick that the user pressed down the button.
#This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
if Input.is_action_just_pressed("HotKey_ToggleFullscreen") and temporarl_deadzone <= 0.0:
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
temporarl_deadzone = 0.5
if temporarl_deadzone > 0.0:
temporarl_deadzone -= delta

5
InteractToggleVisible.gd Normal file
View File

@ -0,0 +1,5 @@
extends Node3D
class_name InteractToggle
func interact():
visible = not visible

58
InteractiveItems.gd Normal file
View File

@ -0,0 +1,58 @@
extends Node
class_name InteractiveItems
# Emits the node with the `item_group_name` group set.
signal item_clicked(node: Node)
@export var item_group_name: String = "item"
@export var call_interact: bool = true
@export var show_debug_label: bool = true
var label
var current_object
func find_interactive():
return get_tree().get_nodes_in_group(item_group_name)
func list_nodes(node: Node, parent: bool = true) -> Array[Node]:
var res: Array[Node] = [node]
if parent and node.get_parent(): res.append(node.get_parent())
res.append_array(node.get_children())
return res
func get_collision(mesh: MeshInstance3D) -> CollisionObject3D:
for node in list_nodes(mesh):
if node is CollisionObject3D: return node
mesh.create_convex_collision()
return mesh.get_child(mesh.get_child_count() - 1)
func _on_mouse_entered(node: Node3D, entered: bool):
current_object = node if entered else null
if label: label.text = node.name if entered else &""
func do_interact(node: Node):
for child in list_nodes(node, false):
if child.has_method("interact"):
child.call("interact")
return
func setup_label():
if not show_debug_label: return
label = Label.new()
label.position = Vector2(20, 20)
add_child(label)
func _ready():
setup_label()
for item in find_interactive():
var col := get_collision(item)
col.input_ray_pickable = true # make sure Input.Ray Pickable is Off for invisible walls
col.connect("mouse_entered", _on_mouse_entered.bind(item, true))
col.connect("mouse_exited", _on_mouse_entered.bind(item, false))
func _unhandled_input(event):
if event.is_action_pressed("ui_accept"):
if current_object:
#print(current_object)
if call_interact: do_interact(current_object)
item_clicked.emit(current_object)

1
icon.svg Normal file
View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

37
icon.svg.import Normal file
View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cm4qv3vu7yn2n"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
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/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

38
project.godot Normal file
View File

@ -0,0 +1,38 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="LgdgExampleProject"
run/main_scene="res://thirdPerson.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg"
[input]
ui_accept={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(903, 27),"global_position":Vector2(911, 107),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
HotKey_ToggleFullscreen={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":true,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":true,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

1510
thirdPerson.tscn Normal file

File diff suppressed because one or more lines are too long