Compare commits
No commits in common. "3fa504f25a3bf9bfbd93f922913134df56499e33" and "86b29ec4768e11c758cc1f74acdfec99bf63ef4f" have entirely different histories.
3fa504f25a
...
86b29ec476
|
@ -7,47 +7,25 @@ var target: Targetable = null
|
|||
@export var charge_time := 1.7
|
||||
@export var min_charge := 0.2
|
||||
|
||||
var camera_tweening = false
|
||||
|
||||
func _ready():
|
||||
set_target(initial_target, false)
|
||||
ControllerEventBus.billiard_touched_billiard.connect(_on_billiard_touched_billiard)
|
||||
|
||||
func _on_billiard_touched_billiard(who: Billiard, touched: Billiard):
|
||||
var who_target = Targetable.is_targetable(who)
|
||||
if who_target != target or who.can_hit:
|
||||
return
|
||||
set_target(touched)
|
||||
ControllerEventBus.new_target.emit(touched)
|
||||
|
||||
set_target(initial_target)
|
||||
|
||||
func get_charge():
|
||||
return %radial_ui.charge_amount
|
||||
|
||||
func _input(event):
|
||||
var billiard := target.get_billiard()
|
||||
if camera_tweening:
|
||||
return
|
||||
if event is InputEventMouseMotion and MouseControl.mouse_is_locked() and get_charge() == 0.0 :
|
||||
if event is InputEventMouseMotion and MouseControl.mouse_is_locked() and get_charge() == 0.0:
|
||||
rotate_view(event.relative*sensitivity)
|
||||
if event.is_action_released("charge") and not billiard.can_hit and charge_tween != null:
|
||||
release()
|
||||
if event.is_action_pressed("charge") and billiard.can_hit and charge_tween == null:
|
||||
charge(event.get_action_strength("charge"))
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta):
|
||||
transform.origin = target.global_position
|
||||
%camera_spot.look_at(target.global_position)
|
||||
if not camera_tweening:
|
||||
camera.global_transform = %camera_spot.global_transform
|
||||
else:
|
||||
camera.global_position = lerp(camera.global_position, %camera_spot.global_position, 0.00000000001)
|
||||
camera.global_rotation = lerp(camera.global_rotation, %camera_spot.global_rotation, 0.00000000001)
|
||||
var epsilon: float = 0.0001
|
||||
if (camera.global_position - %camera_spot.global_position).length() <= epsilon and (camera.global_rotation - %camera_spot.global_rotation).length() <= epsilon:
|
||||
camera_tweening = false
|
||||
|
||||
|
||||
camera.global_position = %camera_spot.global_position
|
||||
camera.look_at(target.global_position)
|
||||
if get_charge() >= 1.0:
|
||||
cancel_charge()
|
||||
|
||||
|
@ -68,7 +46,6 @@ func release():
|
|||
%ChargeReleaseSound.play()
|
||||
var billiard := target.get_billiard()
|
||||
billiard.hit((target.global_position - %camera_spot.global_position).normalized(), get_charge())
|
||||
|
||||
%radial_ui.set_charge(0.0)
|
||||
%ChargeSound.stop()
|
||||
if charge_tween != null:
|
||||
|
@ -90,13 +67,8 @@ func rotate_view(amount: Vector2):
|
|||
%rotate_helper.rotate_z(amount.y)
|
||||
%rotate_helper.rotation_degrees.z = clampf(%rotate_helper.rotation_degrees.z, -77, 77)
|
||||
|
||||
|
||||
func set_target(node: Node3D, should_create_tween=true):
|
||||
camera_tweening = should_create_tween
|
||||
|
||||
func set_target(node: Node3D):
|
||||
var ntarget = Targetable.is_targetable(node)
|
||||
var billiard = ntarget.get_billiard()
|
||||
billiard.can_hit = true
|
||||
if ntarget == null:
|
||||
push_error("Node is node targetable", node)
|
||||
return
|
||||
|
|
|
@ -35,6 +35,8 @@ func change_all_materials(mesh: MeshInstance3D):
|
|||
layer1.render_priority = 20
|
||||
layer2.render_priority = 30
|
||||
|
||||
|
||||
|
||||
layer0.no_depth_test = true
|
||||
layer0.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA_DEPTH_PRE_PASS
|
||||
layer0.grow = true
|
||||
|
@ -45,12 +47,26 @@ func change_all_materials(mesh: MeshInstance3D):
|
|||
layer2.depth_draw_mode = BaseMaterial3D.DEPTH_DRAW_ALWAYS
|
||||
|
||||
mesh.set_surface_override_material(i, layer0)
|
||||
#mesh.set_surface_override_material(i, mat)
|
||||
#mat.next_pass = preload("control_target_overlay.material")
|
||||
|
||||
|
||||
func unchange_all_materials(mesh: MeshInstance3D):
|
||||
for i in range(mesh.get_surface_override_material_count()):
|
||||
var mat := mesh.get_active_material(i)
|
||||
var layer2: StandardMaterial3D = mat.next_pass.next_pass
|
||||
mesh.set_surface_override_material(i, layer2)
|
||||
layer2.transparency = BaseMaterial3D.TRANSPARENCY_DISABLED
|
||||
layer2.depth_draw_mode = BaseMaterial3D.DEPTH_DRAW_OPAQUE_ONLY
|
||||
unchange_material(mat)
|
||||
while mat.next_pass != null:
|
||||
unchange_material(mat.next_pass)
|
||||
mat = mat.next_pass
|
||||
mat.next_pass = null
|
||||
|
||||
func change_material(mat: BaseMaterial3D) -> BaseMaterial3D:
|
||||
mat = mat.duplicate()
|
||||
mat.render_priority = 100
|
||||
mat.no_depth_test = true
|
||||
return mat
|
||||
|
||||
func unchange_material(mat: BaseMaterial3D) -> BaseMaterial3D:
|
||||
mat.render_priority = 0
|
||||
mat.no_depth_test = false
|
||||
return mat
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
extends Node
|
||||
|
||||
signal new_target(node: Billiard)
|
||||
signal billiard_touched_billiard(who: Billiard, touched: Billiard)
|
||||
signal new_target(node: Node)
|
||||
|
|
|
@ -8,9 +8,3 @@ var can_hit = true
|
|||
|
||||
func hit(impulse: Vector3, power: float):
|
||||
apply_central_impulse(impulse * lerp(power_min, power_max, power))
|
||||
|
||||
|
||||
func _on_body_shape_entered(_body_rid, body, _body_shape_index, _local_shape_index):
|
||||
if body is Billiard:
|
||||
ControllerEventBus.billiard_touched_billiard.emit(self, body)
|
||||
|
||||
|
|
|
@ -6,13 +6,9 @@
|
|||
|
||||
[node name="billiard" type="RigidBody3D"]
|
||||
continuous_cd = true
|
||||
max_contacts_reported = 1
|
||||
contact_monitor = true
|
||||
script = ExtResource("1_a0fke")
|
||||
|
||||
[node name="is_targetable" parent="." instance=ExtResource("2_yrk4o")]
|
||||
|
||||
[node name="is_TASable" parent="." node_paths=PackedStringArray("_assignedRigidBody3D") instance=ExtResource("3_oj26f")]
|
||||
_assignedRigidBody3D = NodePath("..")
|
||||
|
||||
[connection signal="body_shape_entered" from="." to="." method="_on_body_shape_entered"]
|
||||
|
|
Loading…
Reference in New Issue