14 lines
631 B
GDScript
14 lines
631 B
GDScript
class_name ReflexAlignment
|
|||
|
|
extends RefCounted
|
||
|
|
|
||
|
|
static func equipped(p: Fighter) -> bool:
|
||
|
|
return WeaponAttachments.clean(p.skin_designs.get(str(p.weapon), {}).get("attachments", {})).get("optic", 0) == 1
|
||
|
|
|
||
|
|
static func align(view: Node3D, p: Fighter, blend: float) -> void:
|
||
|
|
if not equipped(p) or blend <= 0 or p.reload_left > 0 or p.melee_left > 0: return
|
||
|
|
var lens := view.model.get_meta("reflex_lens", null) as Node3D
|
||
|
|
if lens == null: return
|
||
|
|
# Project the actual animated lens center onto the camera's optical axis.
|
||
|
|
var center := p.camera.to_local(lens.global_position)
|
||
|
|
view.position -= Vector3(center.x, center.y, 0) * blend
|