generated from krampus/template-godot4
Interaction sequence for wall switch
Some checks failed
linting & formatting / build (push) Failing after 4s
Some checks failed
linting & formatting / build (push) Failing after 4s
This commit is contained in:
parent
1204123705
commit
42f59962f5
@ -40,7 +40,12 @@ func get_spray() -> Spray:
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
player_hud.select_interactive(interact_ray.get_collider() as Interactive)
|
# Will be null if no valid interactor is selected.
|
||||||
|
var interactive: Interactive = interact_ray.get_collider() as Interactive
|
||||||
|
player_hud.select_interactive(interactive)
|
||||||
|
|
||||||
|
if interactive and Input.is_action_just_pressed("interact"):
|
||||||
|
interactive.activate()
|
||||||
|
|
||||||
if Input.is_action_pressed("fire"):
|
if Input.is_action_pressed("fire"):
|
||||||
get_spray().fire()
|
get_spray().fire()
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
class_name Interactive extends StaticBody3D
|
class_name Interactive extends StaticBody3D
|
||||||
## Props the player can interact with.
|
## Props the player can interact with.
|
||||||
|
|
||||||
signal activate
|
signal activated
|
||||||
|
|
||||||
@export var disabled := false
|
@export var enabled := false
|
||||||
|
|
||||||
|
|
||||||
|
func activate() -> void:
|
||||||
|
if enabled:
|
||||||
|
activated.emit()
|
||||||
|
# TODO: bonk
|
||||||
|
@ -1 +1,45 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
|
signal cleared
|
||||||
|
signal activated
|
||||||
|
|
||||||
|
const CLEAR_THRESHOLD := 2750
|
||||||
|
|
||||||
|
@export var enabled := false
|
||||||
|
|
||||||
|
@onready var animation_player: AnimationPlayer = %AnimationPlayer
|
||||||
|
@onready var light_animation: AnimationPlayer = %LightAnimation
|
||||||
|
@onready var gunk_body: GunkBody = %GunkBody
|
||||||
|
@onready var interactive: Interactive = %Interactive
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if enabled:
|
||||||
|
enable()
|
||||||
|
|
||||||
|
|
||||||
|
func enable() -> void:
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
# Clear off the rest of the gunk
|
||||||
|
gunk_body.clear_all()
|
||||||
|
light_animation.play("success")
|
||||||
|
interactive.enabled = true
|
||||||
|
|
||||||
|
|
||||||
|
func _on_gunk_body_painted() -> void:
|
||||||
|
if not enabled:
|
||||||
|
var clear_total := gunk_body.get_clear_total()
|
||||||
|
if clear_total >= CLEAR_THRESHOLD:
|
||||||
|
enable()
|
||||||
|
|
||||||
|
|
||||||
|
func _activate() -> void:
|
||||||
|
animation_player.play("activate")
|
||||||
|
activated.emit()
|
||||||
|
# Disable while animation is playing
|
||||||
|
interactive.enabled = false
|
||||||
|
|
||||||
|
|
||||||
|
func _animation_finished(_anim_name: StringName) -> void:
|
||||||
|
interactive.enabled = true
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
class_name PlayerHUD extends Control
|
class_name PlayerHUD extends Control
|
||||||
|
|
||||||
const TRANSITION_TIME := 0.05
|
const TRANSITION_TIME := 0.06
|
||||||
|
|
||||||
const COLOR_VISIBLE := Color("#ffffffee")
|
const COLOR_VISIBLE := Color("#ffffffee")
|
||||||
const COLOR_DISABLED := Color("#cccccc44")
|
const COLOR_DISABLED := Color("#cccccc44")
|
||||||
@ -29,9 +29,9 @@ func _to_invisible(element: Control) -> void:
|
|||||||
|
|
||||||
func select_interactive(prop: Interactive) -> void:
|
func select_interactive(prop: Interactive) -> void:
|
||||||
if prop:
|
if prop:
|
||||||
if prop.disabled:
|
if prop.enabled:
|
||||||
_to_disabled(interact_hud)
|
|
||||||
else:
|
|
||||||
_to_visible(interact_hud)
|
_to_visible(interact_hud)
|
||||||
|
else:
|
||||||
|
_to_disabled(interact_hud)
|
||||||
else:
|
else:
|
||||||
_to_invisible(interact_hud)
|
_to_invisible(interact_hud)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
class_name GunkBody extends StaticBody3D
|
class_name GunkBody extends StaticBody3D
|
||||||
## StaticBody3D with an associated "gunkable" mesh.
|
## StaticBody3D with an associated "gunkable" mesh.
|
||||||
|
|
||||||
|
signal painted
|
||||||
|
|
||||||
const CONTINUITY_LIMIT := 128
|
const CONTINUITY_LIMIT := 128
|
||||||
const BUFFER_LIMIT := 3
|
const BUFFER_LIMIT := 3
|
||||||
const FACE_EPSILON := 0.01
|
const FACE_EPSILON := 0.01
|
||||||
@ -35,6 +37,15 @@ func _ready() -> void:
|
|||||||
meshtool.create_from_surface(mesh, 0)
|
meshtool.create_from_surface(mesh, 0)
|
||||||
|
|
||||||
|
|
||||||
|
func clear_all() -> void:
|
||||||
|
mask_control.queue_draw(
|
||||||
|
func() -> void:
|
||||||
|
mask_control.draw_rect(
|
||||||
|
Rect2(0, 0, mask_control.size.x, mask_control.size.y), MASK_COLOR
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
## Get the precise number of gunk pixels cleared from this image.
|
## Get the precise number of gunk pixels cleared from this image.
|
||||||
##
|
##
|
||||||
## This will use a cached result unless the mask has been painted since the last calculation.
|
## This will use a cached result unless the mask has been painted since the last calculation.
|
||||||
@ -184,3 +195,4 @@ func _process(_delta: float) -> void:
|
|||||||
|
|
||||||
func _on_mask_painted() -> void:
|
func _on_mask_painted() -> void:
|
||||||
_clear_total_dirty = true
|
_clear_total_dirty = true
|
||||||
|
painted.emit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user