immersive-home/app/content/system/house/room/states/view.gd

39 lines
1.1 KiB
GDScript3
Raw Normal View History

2023-12-19 00:15:48 +02:00
extends RoomState
2024-03-07 15:21:31 +02:00
const RoomState = preload ("./room_state.gd")
2023-12-19 00:15:48 +02:00
func _on_enter():
2024-01-27 16:13:43 +02:00
var room_store = Store.house.get_room(room.name)
2023-12-19 00:15:48 +02:00
2024-04-29 18:18:15 +03:00
if room_store == null:
2023-12-19 00:15:48 +02:00
return
2024-04-29 18:18:15 +03:00
room.wall_mesh.mesh = room.generate_wall_mesh()
2023-12-19 00:15:48 +02:00
if room.wall_mesh.mesh == null:
return
2024-03-07 15:21:31 +02:00
room.room_ceiling.position.y = room_store.height
2024-01-25 13:36:33 +02:00
var ceiling_shape = room.room_ceiling.get_node("CollisionShape3D")
var floor_shape = room.room_floor.get_node("CollisionShape3D")
ceiling_shape.disabled = false
floor_shape.disabled = false
2024-01-27 16:13:43 +02:00
room.ceiling_mesh.mesh = Room.generate_ceiling_mesh(room_store)
2024-01-25 13:36:33 +02:00
ceiling_shape.shape = room.ceiling_mesh.mesh.create_trimesh_shape()
floor_shape.shape = room.ceiling_mesh.mesh.create_trimesh_shape()
ceiling_shape.shape.backface_collision = true
2023-12-19 00:15:48 +02:00
2024-04-10 17:52:23 +03:00
var wall_collisions = room.wall_mesh.mesh.create_trimesh_shape()
wall_collisions.backface_collision = true
room.wall_collision.shape = wall_collisions
2023-12-19 00:15:48 +02:00
func _on_leave():
2024-01-25 13:36:33 +02:00
room.room_ceiling.get_node("CollisionShape3D").disabled = true
room.room_floor.get_node("CollisionShape3D").disabled = true
2024-04-10 17:52:23 +03:00
room.wall_collision.shape = null
room.wall_mesh.mesh = null
room.ceiling_mesh.mesh = null