move selector to selection_manager global
This commit is contained in:
parent
a54f7b6529
commit
0440fcb1fc
@ -26,6 +26,7 @@ QuittingManager="*res://scripts/globals/quitting_manager.gd"
|
||||
DebugDraw="*res://scripts/globals/debug_draw.gd"
|
||||
UiManager="*res://scripts/globals/ui_manager.gd"
|
||||
HoveringManager="*res://scripts/globals/hovering_manager.gd"
|
||||
SelectionManager="*res://scripts/globals/selection_manager.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
|
||||
17
resources/styles/selection_rect.tres
Normal file
17
resources/styles/selection_rect.tres
Normal file
@ -0,0 +1,17 @@
|
||||
[gd_resource type="StyleBoxTexture" load_steps=2 format=3 uid="uid://dw8lv0nxj2qrf"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bgbe5l2woe5b2" path="res://assets/textures/gui/selection_box.png" id="1_um7v1"]
|
||||
|
||||
[resource]
|
||||
texture = ExtResource("1_um7v1")
|
||||
texture_margin_left = 21.0
|
||||
texture_margin_top = 20.0
|
||||
texture_margin_right = 23.0
|
||||
texture_margin_bottom = 20.0
|
||||
expand_margin_left = 5.0
|
||||
expand_margin_top = 5.0
|
||||
expand_margin_right = 5.0
|
||||
expand_margin_bottom = 5.0
|
||||
axis_stretch_horizontal = 1
|
||||
axis_stretch_vertical = 1
|
||||
draw_center = false
|
||||
@ -1,10 +1,8 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://ceru75se7ifkb"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://ceru75se7ifkb"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/main_camera.gd" id="1_gnxhh"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfixshlmwhpmi" path="res://scenes/units/test_unit.tscn" id="2_4bgm6"]
|
||||
[ext_resource type="PackedScene" uid="uid://d4c6ujs1ra1ob" path="res://scenes/units/aphid.tscn" id="3_eh22j"]
|
||||
[ext_resource type="Script" path="res://scripts/selector.gd" id="4_5avpj"]
|
||||
[ext_resource type="Texture2D" uid="uid://bgbe5l2woe5b2" path="res://assets/textures/gui/selection_box.png" id="5_g1xtt"]
|
||||
[ext_resource type="PackedScene" uid="uid://clftjlaotf2g2" path="res://scenes/structures/Anthill.tscn" id="7_f30w3"]
|
||||
[ext_resource type="PackedScene" uid="uid://d8ut24fit87x" path="res://scenes/ui/anthill_info.tscn" id="8_ohyy4"]
|
||||
|
||||
@ -37,23 +35,6 @@ background_mode = 1
|
||||
background_color = Color(0.547785, 0.658701, 0.745764, 1)
|
||||
sky = SubResource("Sky_au5yl")
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_16ver"]
|
||||
texture = ExtResource("5_g1xtt")
|
||||
texture_margin_left = 21.0
|
||||
texture_margin_top = 20.0
|
||||
texture_margin_right = 23.0
|
||||
texture_margin_bottom = 20.0
|
||||
expand_margin_left = 5.0
|
||||
expand_margin_top = 5.0
|
||||
expand_margin_right = 5.0
|
||||
expand_margin_bottom = 5.0
|
||||
axis_stretch_horizontal = 1
|
||||
axis_stretch_vertical = 1
|
||||
draw_center = false
|
||||
|
||||
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_n34fh"]
|
||||
points = PackedVector3Array(-0.0778407, 1.54508, 4.75528, -31.3231, -5, -72.1516, 31.0442, -5, -72.1516, -5.20198, -5, -6.07939, 5.0261, -5, -6.07939)
|
||||
|
||||
[node name="World" type="Node3D"]
|
||||
|
||||
[node name="Static" type="Node" parent="."]
|
||||
@ -129,23 +110,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.79455, 0, 1.78811)
|
||||
|
||||
[node name="AnthillInfo" parent="UI" instance=ExtResource("8_ohyy4")]
|
||||
|
||||
[node name="Selector" type="Node" parent="."]
|
||||
script = ExtResource("4_5avpj")
|
||||
|
||||
[node name="SelectionRect" type="Panel" parent="Selector"]
|
||||
offset_left = 267.0
|
||||
offset_top = 229.0
|
||||
offset_right = 424.0
|
||||
offset_bottom = 287.0
|
||||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxTexture_16ver")
|
||||
|
||||
[node name="FrustrumArea" type="Area3D" parent="Selector"]
|
||||
input_ray_pickable = false
|
||||
|
||||
[node name="FrustrumCollisionShape" type="CollisionShape3D" parent="Selector/FrustrumArea"]
|
||||
shape = SubResource("ConvexPolygonShape3D_n34fh")
|
||||
|
||||
[node name="MainCamera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.819152, 0.573576, 0, -0.573576, 0.819152, 0, 1, 2)
|
||||
current = true
|
||||
|
||||
@ -18,12 +18,12 @@ var mouse_pressed: bool = false
|
||||
var selecting: bool = false
|
||||
var selection_rect: Rect2 = Rect2()
|
||||
|
||||
var rect_style := preload("res://resources/styles/selection_rect.tres")
|
||||
|
||||
@onready var camera: Camera3D = get_viewport().get_camera_3d()
|
||||
@onready var frustrum_area: Area3D = $FrustrumArea
|
||||
@onready var frustrum_collision_shape: CollisionShape3D = (
|
||||
$FrustrumArea/FrustrumCollisionShape
|
||||
)
|
||||
@onready var rect_panel: Panel = $SelectionRect
|
||||
@onready var frustrum_area: Area3D = Area3D.new()
|
||||
@onready var frustrum_collision_shape: CollisionShape3D = CollisionShape3D.new()
|
||||
@onready var rect_panel: Panel = Panel.new()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@ -32,6 +32,12 @@ func _ready() -> void:
|
||||
rect_panel.visible = false
|
||||
frustrum_area.body_entered.connect(_on_frustrum_area_unit_entered)
|
||||
frustrum_area.body_exited.connect(_on_frustrum_area_unit_exited)
|
||||
frustrum_area.input_ray_pickable = false
|
||||
rect_panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
rect_panel.add_theme_stylebox_override("panel", rect_style)
|
||||
add_child(rect_panel)
|
||||
add_child(frustrum_area)
|
||||
frustrum_area.add_child(frustrum_collision_shape)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
@ -96,6 +96,7 @@ func _handle_movement(delta: float) -> void:
|
||||
window_out_of_focus
|
||||
or state != CameraState.FREE
|
||||
or CursorManager.disable_confinement
|
||||
or SelectionManager.selecting
|
||||
):
|
||||
return
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user