54 lines
1.6 KiB
GDScript
54 lines
1.6 KiB
GDScript
@tool
|
|
extends Node2D
|
|
|
|
|
|
|
|
@export var shake_distance := 12.0
|
|
@export var shake_duration := 0.3
|
|
@export var shake_step_count := 5
|
|
@export_tool_button('Damage Painting') var damage_painting_action = damage_painting
|
|
|
|
|
|
@export var custom_paintings: Array[Texture2D]
|
|
@export_tool_button('Next Custom') var next_custom_action = func next_custom():
|
|
var idx: int = (%Painting.painting_id + 1) % custom_paintings.size()
|
|
%Painting.overwrite_texture = custom_paintings[idx]
|
|
%Painting.painting_id = idx
|
|
|
|
|
|
@export_tool_button('Random Procedual') var random_procedual_action = func random_procedual():
|
|
%Painting.painting_id = randi()
|
|
%Painting.overwrite_texture = null
|
|
|
|
|
|
func get_n_unique_custom_paintings(count: int) -> Array[int]:
|
|
var list: Array[int] = []
|
|
for idx in custom_paintings.size(): list.push_back(idx)
|
|
list.shuffle()
|
|
list.resize(count)
|
|
return list
|
|
|
|
|
|
var _shake_tween: Tween
|
|
|
|
func animate_shake():
|
|
if _shake_tween: _shake_tween.kill()
|
|
var shake_step := shake_duration / shake_step_count
|
|
_shake_tween = create_tween()
|
|
for i in shake_step_count:
|
|
var pos := Vector2(randf_range(-shake_distance, shake_distance), randf_range(-shake_distance, shake_distance))
|
|
_shake_tween.set_ease(Tween.EASE_OUT_IN)
|
|
_shake_tween.set_trans(Tween.TRANS_ELASTIC)
|
|
_shake_tween.tween_property(%Rela1, ^'position', pos, shake_step)
|
|
_shake_tween.set_ease(Tween.EASE_OUT)
|
|
_shake_tween.set_trans(Tween.TRANS_ELASTIC)
|
|
_shake_tween.tween_property(%Rela1, ^'position', Vector2.ZERO, shake_duration)
|
|
_shake_tween.tween_callback(func(): _shake_tween = null)
|
|
|
|
|
|
func damage_painting():
|
|
if %Painting.damage == 3:
|
|
%Painting.damage = 0
|
|
else:
|
|
%Painting.damage += 1
|
|
animate_shake()
|