use tweens for mini view
This commit is contained in:
parent
493baf85c6
commit
7278b68437
|
@ -6,7 +6,6 @@ const RoomType = preload ("./room/room.gd")
|
||||||
@onready var levels = $Levels
|
@onready var levels = $Levels
|
||||||
@onready var collision_shape = $Levels/CollisionShape3D
|
@onready var collision_shape = $Levels/CollisionShape3D
|
||||||
@onready var align_reference = $AlignReference
|
@onready var align_reference = $AlignReference
|
||||||
@onready var animate_timer = $AnimateTimer
|
|
||||||
|
|
||||||
var fixing_reference: bool = false
|
var fixing_reference: bool = false
|
||||||
var editing_room: RoomType = null
|
var editing_room: RoomType = null
|
||||||
|
@ -15,20 +14,11 @@ var mini_view: bool = false:
|
||||||
mini_view = value
|
mini_view = value
|
||||||
update_mini_view()
|
update_mini_view()
|
||||||
|
|
||||||
var target_size: float = 1.0
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Store.house.on_loaded.connect(func():
|
Store.house.on_loaded.connect(func():
|
||||||
update_house()
|
update_house()
|
||||||
)
|
)
|
||||||
|
|
||||||
func _physics_process(delta):
|
|
||||||
|
|
||||||
if animate_timer.is_stopped() == false:
|
|
||||||
levels.scale.x = lerp(levels.scale.x, target_size, 10.0 * delta)
|
|
||||||
levels.scale.y = lerp(levels.scale.y, target_size, 10.0 * delta)
|
|
||||||
levels.scale.z = lerp(levels.scale.z, target_size, 10.0 * delta)
|
|
||||||
|
|
||||||
func update_house():
|
func update_house():
|
||||||
for old_room in get_rooms(0):
|
for old_room in get_rooms(0):
|
||||||
old_room.queue_free()
|
old_room.queue_free()
|
||||||
|
@ -205,6 +195,10 @@ func create_entity_in(entity_id: String, room_name: String):
|
||||||
func update_mini_view():
|
func update_mini_view():
|
||||||
collision_shape.disabled = !mini_view
|
collision_shape.disabled = !mini_view
|
||||||
|
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.set_parallel(true)
|
||||||
|
tween.set_trans(Tween.TRANS_CUBIC)
|
||||||
|
|
||||||
if mini_view:
|
if mini_view:
|
||||||
var aabb = get_level_aabb(0)
|
var aabb = get_level_aabb(0)
|
||||||
aabb.position.y = -0.03
|
aabb.position.y = -0.03
|
||||||
|
@ -222,15 +216,19 @@ func update_mini_view():
|
||||||
camera_direction.y = 0.0
|
camera_direction.y = 0.0
|
||||||
|
|
||||||
var target_position = camera_position + camera_direction.normalized() * 0.2
|
var target_position = camera_position + camera_direction.normalized() * 0.2
|
||||||
levels.global_position = target_position - center * 0.1
|
var new_position = target_position - center * 0.1
|
||||||
|
tween.tween_property(levels, "global_position", new_position, 0.5)
|
||||||
|
tween.tween_property(levels, "scale", Vector3(0.1, 0.1, 0.1), 0.5)
|
||||||
|
|
||||||
|
for room in get_rooms(0):
|
||||||
|
room.state_machine.change_to("Mini")
|
||||||
else:
|
else:
|
||||||
levels.position = Vector3(0, 0, 0)
|
tween.tween_property(levels, "global_position", Vector3(0, 0, 0), 0.5)
|
||||||
|
tween.tween_property(levels, "scale", Vector3(1.0, 1.0, 1.0), 0.5)
|
||||||
|
await tween.finished
|
||||||
|
|
||||||
target_size = 0.1 if mini_view else 1.0
|
for room in get_rooms(0):
|
||||||
animate_timer.start()
|
room.state_machine.change_to("View")
|
||||||
|
|
||||||
for room in get_rooms(0):
|
|
||||||
room.state_machine.change_to("Mini" if mini_view else "View")
|
|
||||||
|
|
||||||
func edit_reference():
|
func edit_reference():
|
||||||
fixing_reference = false
|
fixing_reference = false
|
||||||
|
|
|
@ -25,6 +25,3 @@ lock_rotation = true
|
||||||
[node name="AlignReference" parent="." instance=ExtResource("3_e1tcn")]
|
[node name="AlignReference" parent="." instance=ExtResource("3_e1tcn")]
|
||||||
visible = false
|
visible = false
|
||||||
disabled = true
|
disabled = true
|
||||||
|
|
||||||
[node name="AnimateTimer" type="Timer" parent="."]
|
|
||||||
one_shot = true
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user