From b25cc8c08db3dd89aed34d81e46fbc6389ba2711 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Fri, 26 Apr 2024 13:58:20 +0200 Subject: [PATCH] fix rotation and entity in mini view --- app/content/functions/movable.gd | 4 ++++ app/content/system/house/mini/Entity.gd | 9 +++++++-- app/content/system/house/mini/miniature.gd | 2 ++ app/content/system/house/mini/miniature.tscn | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/content/functions/movable.gd b/app/content/functions/movable.gd index 4447883..8d3c33a 100644 --- a/app/content/functions/movable.gd +++ b/app/content/functions/movable.gd @@ -8,10 +8,14 @@ signal on_moved() @export var restricted: bool = false @export var restrict_movement: Callable @export var lock_rotation: bool = false +@export var disabled: bool = false var hit_node := Node3D.new() var initiator = null func _on_grab_down(event: EventPointer): + if disabled: + return + if restricted&&event.target != get_parent(): return diff --git a/app/content/system/house/mini/Entity.gd b/app/content/system/house/mini/Entity.gd index 67ee467..7f5671a 100644 --- a/app/content/system/house/mini/Entity.gd +++ b/app/content/system/house/mini/Entity.gd @@ -4,17 +4,20 @@ const DotScene = preload ("res://content/system/dot/dot.tscn") const Entity = preload ("res://content/entities/entity.gd") @onready var dots = $"../Small/Dots" +@onready var main = $"/root/Main" var active_type = null var editing = R.state([]) var group_entity = null +var house_small = null + func _ready(): await House.body.ready # Update Group Entity R.effect(func(_arg): - if editing.value.size() == 0: + if house_small.value == false||editing.value.size() == 0: if group_entity != null: group_entity.queue_free() group_entity=null @@ -23,7 +26,9 @@ func _ready(): group_entity=EntityFactory.create_entity(id, active_type) for entity_node in group_entity.get_children(): if entity_node is Movable: - group_entity.remove_child(entity_node) + entity_node.disabled=true + + group_entity.transform=Transform3D().looking_at(to_local((main.camera.global_position)), Vector3.UP, true) add_child(group_entity) else: HomeApi.groups.update_entities(group_entity.entity_id, editing.value.map(func(entity): return entity.entity_id)) diff --git a/app/content/system/house/mini/miniature.gd b/app/content/system/house/mini/miniature.gd index 9dccb84..724da7b 100644 --- a/app/content/system/house/mini/miniature.gd +++ b/app/content/system/house/mini/miniature.gd @@ -38,6 +38,8 @@ func _ready(): wall_material.set_shader_parameter("data", []) wall_material.set_shader_parameter("data_size", 0) + entity_select.house_small = small + if Store.house.is_loaded() == false: await Store.house.on_loaded diff --git a/app/content/system/house/mini/miniature.tscn b/app/content/system/house/mini/miniature.tscn index f89f869..f462726 100644 --- a/app/content/system/house/mini/miniature.tscn +++ b/app/content/system/house/mini/miniature.tscn @@ -18,6 +18,7 @@ disabled = true [node name="Movable" type="Node" parent="Body"] script = ExtResource("2_x7oed") restricted = true +disabled = null [node name="Small" type="Node3D" parent="Body"]