mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-16 00:44:50 +00:00
⚡️ Headless optimizations
This commit is contained in:
parent
4157ae7ba5
commit
bc5aa8a41f
8 changed files with 48 additions and 49 deletions
|
|
@ -43,4 +43,3 @@ func drop(dropper : Player) -> void:
|
|||
_mesh.show()
|
||||
flag_state = FlagState.FLAG_STATE_DROPPED
|
||||
dropped.emit(dropper)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ func _ready() -> void:
|
|||
Vector3(0, flag.get_node("CollisionShape3D").shape.size.y, 0))
|
||||
|
||||
func _process(_delta : float) -> void:
|
||||
# disable waypoint repositioning when running headless
|
||||
if DisplayServer.get_name() == "headless":
|
||||
set_process(false)
|
||||
return
|
||||
|
||||
# repositon iff on viewport
|
||||
var camera : Camera3D = get_viewport().get_camera_3d()
|
||||
var viewport_rect : Rect2 = get_viewport_rect()
|
||||
# if the player is NOT infront of the camera or camera does NOT have LOS to player
|
||||
|
|
@ -32,15 +38,12 @@ func _process(_delta : float) -> void:
|
|||
return
|
||||
else:
|
||||
_iff_container.show() # display the IFF
|
||||
|
||||
# get the screen location of the players head
|
||||
var new_iff_position : Vector2 = camera.unproject_position(attach_point.global_position)
|
||||
|
||||
# check if the unprojected point lies inside the viewport
|
||||
if !Rect2(Vector2(0, 0), viewport_rect.size).has_point(new_iff_position):
|
||||
_iff_container.hide() # hide the IFF and exit function
|
||||
return
|
||||
|
||||
# move the IFF up so the bottom of it is at the players head
|
||||
new_iff_position.y -= _iff_container.size.y
|
||||
# move the IFF left so it's centered horizontally above players head
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue