Initial commit.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
@tool
|
||||
class_name ProtoInteractArea
|
||||
extends Area3D
|
||||
|
||||
@export_tool_button("Generate Nodes") var initialize_nodes := func() -> void:
|
||||
for c in get_children(): c.free()
|
||||
|
||||
if mesh:
|
||||
var mesh_instance := MeshInstance3D.new()
|
||||
var box_mesh := BoxMesh.new()
|
||||
box_mesh.size = Vector3.ONE
|
||||
mesh_instance.mesh = box_mesh
|
||||
Proto.add_node(self, mesh_instance)
|
||||
|
||||
var col := CollisionShape3D.new()
|
||||
|
||||
var box_shape := BoxShape3D.new()
|
||||
box_shape.size = Vector3.ONE
|
||||
col.shape = box_shape
|
||||
|
||||
Proto.add_node(self, col)
|
||||
|
||||
interact_label = Label3D.new()
|
||||
interact_label.text = "Interact"
|
||||
interact_label.position.y = 1.0
|
||||
interact_label.billboard = BaseMaterial3D.BILLBOARD_ENABLED
|
||||
Proto.add_node(self, interact_label)
|
||||
|
||||
position.y = 0.5
|
||||
|
||||
Proto.proto_print("Interactable nodes configured")
|
||||
|
||||
@export var load_on_ready := true
|
||||
@export var mesh := true
|
||||
@export var interact_label: Label3D
|
||||
|
||||
var proto_game: Node
|
||||
var interact_tween: Tween
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint():
|
||||
if load_on_ready:
|
||||
if get_child_count() == 0: initialize_nodes.call()
|
||||
|
||||
return
|
||||
|
||||
proto_game = Proto.get_autoload(self, "ProtoGame")
|
||||
|
||||
if proto_game:
|
||||
proto_game.signal_hub.interact.connect(on_interact)
|
||||
|
||||
if interact_label:
|
||||
interact_label.hide()
|
||||
|
||||
func on_interact(source: Node, target: Node) -> void:
|
||||
if target != self: return
|
||||
|
||||
interact_label.text = "Interact (%s)" % target.name
|
||||
interact_label.show()
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
interact_label.hide()
|
||||
@@ -0,0 +1 @@
|
||||
uid://rcs8mnmasa4y
|
||||
@@ -0,0 +1,53 @@
|
||||
@tool
|
||||
class_name ProtoInteractForcePush
|
||||
extends RigidBody3D
|
||||
|
||||
@export_tool_button("Generate Nodes") var initialize_nodes := func() -> void:
|
||||
for c in get_children(): c.free()
|
||||
|
||||
if mesh:
|
||||
var mesh_instance := MeshInstance3D.new()
|
||||
var box_mesh := BoxMesh.new()
|
||||
box_mesh.size = Vector3.ONE
|
||||
mesh_instance.mesh = box_mesh
|
||||
Proto.add_node(self, mesh_instance)
|
||||
|
||||
var col := CollisionShape3D.new()
|
||||
|
||||
var box_shape := BoxShape3D.new()
|
||||
box_shape.size = Vector3.ONE
|
||||
col.shape = box_shape
|
||||
|
||||
area_3d = Area3D.new()
|
||||
var col_2 := col.duplicate()
|
||||
Proto.add_node(self, area_3d)
|
||||
Proto.add_node(area_3d, col_2)
|
||||
|
||||
Proto.add_node(self, col)
|
||||
|
||||
position.y = 0.5
|
||||
|
||||
Proto.proto_print("Interactable force push generated")
|
||||
|
||||
@export var load_on_ready := true
|
||||
@export var mesh := true
|
||||
@export var force_strength := 5.0
|
||||
@export var area_3d: Area3D
|
||||
|
||||
var proto_game: Node
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint():
|
||||
if load_on_ready:
|
||||
if get_child_count() == 0: initialize_nodes.call()
|
||||
return
|
||||
|
||||
proto_game = Proto.get_autoload(self, "ProtoGame")
|
||||
if proto_game:
|
||||
proto_game.signal_hub.interact.connect(on_interact)
|
||||
|
||||
func on_interact(source: Node3D, target: Node3D) -> void:
|
||||
if target != area_3d: return
|
||||
|
||||
var direction := source.global_position.direction_to(target.global_position)
|
||||
apply_central_impulse(force_strength * direction)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bb7cpovba4gjj
|
||||
@@ -0,0 +1,35 @@
|
||||
@tool
|
||||
class_name ProtoSimpleFloor
|
||||
extends StaticBody3D
|
||||
|
||||
@export_tool_button("Generate Nodes") var initialize_nodes := func() -> void:
|
||||
for c in get_children(): c.free()
|
||||
|
||||
var mesh_instance := MeshInstance3D.new()
|
||||
var box_mesh := BoxMesh.new()
|
||||
box_mesh.size = Vector3(size, 1, size)
|
||||
mesh_instance.mesh = box_mesh
|
||||
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.albedo_color = Color(Color.BLACK)
|
||||
|
||||
mesh_instance.set_surface_override_material(0, mat)
|
||||
Proto.add_node(self, mesh_instance)
|
||||
|
||||
var collision := CollisionShape3D.new()
|
||||
var box_shape := BoxShape3D.new()
|
||||
box_shape.size = Vector3(size, 1, size)
|
||||
collision.shape = box_shape
|
||||
Proto.add_node(self, collision)
|
||||
|
||||
position.y = -0.5
|
||||
|
||||
Proto.proto_print("Simple floor nodes configured")
|
||||
|
||||
@export var size := 1000.0
|
||||
@export var load_on_ready := true
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint():
|
||||
if load_on_ready:
|
||||
if get_child_count() == 0: initialize_nodes.call()
|
||||
@@ -0,0 +1 @@
|
||||
uid://cwvfopl16l1gp
|
||||
Reference in New Issue
Block a user