Tales-of-PKMN/game/player/aim/aim_reticule.gd
TheThomaas 250976d170 Squashed commit of the following:
commit 8e7da96bfcd52b230feaf40fbc6d4a42b80c5723
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Sat Oct 17 18:55:14 2026 +0200

    Make state machine more reusable

commit 37da7248b8c33ce95cff7ef9332c5ccf6e3cd418
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Sat Oct 17 18:44:34 2026 +0200

    Change aim state into flag

commit fbb3a84a12e2cabff9b36390da7483b8de7e9379
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Sat Oct 17 18:33:08 2026 +0200

    Replace fixed references with ui references

commit 913955b13e9980780ac88761845d9e1f165f0d0e
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Fri Oct 16 13:32:21 2026 +0200

    Update camera action handling

commit 4ce0ac13ffea473cf62c2fefd1571e9df1fbbcaa
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Fri Oct 16 13:04:39 2026 +0200

    Update mounting system

commit e410eca38760955b2866eecd6ac0281e2041e76d
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Fri Oct 16 12:57:25 2026 +0200

    Update aiming system

commit 4c788df485ccbff5f91fd51d9f480e495f11da5f
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Thu Oct 15 21:50:26 2026 +0200

    Centralize states names into constants

commit 6059479c87d749e986a48adb520ef33121104da5
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Thu Oct 15 21:25:32 2026 +0200

    Refator Crouch state into flag

commit 08faec70e770042d36eed6f173a63f3aac1f67c6
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Wed Oct 14 10:19:35 2026 +0200

    Update player input management and state machine

commit 11a0aecc58c50c5862a03b4fd0b55e8db024031f
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Wed Oct 14 10:17:06 2026 +0200

    Delete charizard.tres

commit 399eac2b6c64f242a1c2e12360d811127f87681c
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Tue Oct 13 18:20:45 2026 +0200

    Remove unused MountedState

commit 42a3668c52fe96a7509a74290a94fc5a8084b713
Author: TheThomaas <thethomaas@protonmail.ch>
Date:   Tue Oct 13 18:18:08 2026 +0200

    Group grounded states under common class
2026-10-17 18:56:13 +02:00

53 lines
1.8 KiB
GDScript

extends CanvasLayer
class_name AimReticle
#reticule 2D au centre de l'ecran (visee libre / charge du lancer)
#cree a la volee, une seule instance partagee : affichee / masquee par AimTargeting.update_reticle() (appele par tick() et par ThrowState)
static var _instance : AimReticle
static func get_instance(from : Node) -> AimReticle:
if is_instance_valid(_instance): return _instance
_instance = AimReticle.new()
from.get_tree().current_scene.add_child(_instance)
return _instance
static func show_instance(from : Node) -> void:
get_instance(from).visible = true
static func hide_instance() -> void:
if is_instance_valid(_instance): _instance.visible = false
func _init() -> void:
layer = 10
visible = false
add_child(Drawer.new())
class Drawer extends Control:
@export var radius : float = 14.0
@export var tick_length : float = 8.0
@export var color : Color = Color(1.0, 1.0, 1.0, 0.9)
@export var outline_color : Color = Color(0.0, 0.0, 0.0, 0.5) #contour sombre pour rester lisible sur fond clair
func _init() -> void:
set_anchors_preset(Control.PRESET_FULL_RECT)
mouse_filter = Control.MOUSE_FILTER_IGNORE
func _ready() -> void:
resized.connect(queue_redraw)
func _draw() -> void:
var c : Vector2 = size / 2.0
#contour sombre, puis trait clair par-dessus
draw_arc(c, radius, 0.0, TAU, 40, outline_color, 4.0, true)
draw_circle(c, 3.0, outline_color)
for dir : Vector2 in [Vector2.UP, Vector2.DOWN, Vector2.LEFT, Vector2.RIGHT]:
draw_line(c + dir * (radius + 2.0), c + dir * (radius + 2.0 + tick_length), outline_color, 4.0)
draw_arc(c, radius, 0.0, TAU, 40, color, 2.0, true)
draw_circle(c, 1.5, color)
for dir : Vector2 in [Vector2.UP, Vector2.DOWN, Vector2.LEFT, Vector2.RIGHT]:
draw_line(c + dir * (radius + 2.0), c + dir * (radius + 2.0 + tick_length), color, 2.0)