feat: Implement nausea symptom system and related features
- Added SymptomManager autoload for managing symptom intensities. - Introduced nausea tilt effect for camera roll based on nausea intensity. - Created color desaturation shader and overlay for visual feedback. - Developed TreatmentManager to handle nausea ramping during IV treatment. - Added hospital room scene with first-person controller and interactions. - Implemented sit-down interaction for the treatment chair. - Created IV insertion sequence with animations and completion signal. - Added player controller with movement and interaction capabilities. - Integrated nausea effects into the player experience with smooth transitions.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
extends ColorRect
|
||||
## Drives the desaturation shader's `desaturation` uniform from nausea intensity.
|
||||
##
|
||||
## Nausea ramps desaturation from 0 (no effect) up to full grayscale at
|
||||
## `max_at_intensity`. The uniform is smoothly faded toward its target.
|
||||
## Attach to a full-screen ColorRect that uses `desaturation.gdshader`.
|
||||
|
||||
## Nausea intensity at (and above) which the screen is fully desaturated.
|
||||
@export var max_at_intensity: float = 80.0
|
||||
## How fast the shader uniform follows its target, per second.
|
||||
@export var fade_speed: float = 2.0
|
||||
|
||||
var _target: float = 0.0
|
||||
var _current: float = 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Cover the whole viewport and never block input.
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
|
||||
var sm: Node = null
|
||||
if is_inside_tree():
|
||||
sm = get_tree().root.get_node_or_null("SymptomManager")
|
||||
if sm == null:
|
||||
sm = SymptomManager
|
||||
if sm:
|
||||
sm.nausea_intensity_changed.connect(_on_nausea_changed)
|
||||
_set_target_from_intensity(sm.get_intensity(sm.NAUSEA))
|
||||
_current = _target
|
||||
_apply()
|
||||
|
||||
|
||||
func _on_nausea_changed(value: float) -> void:
|
||||
_set_target_from_intensity(value)
|
||||
|
||||
|
||||
func _set_target_from_intensity(intensity: float) -> void:
|
||||
_target = clampf(intensity / max_at_intensity, 0.0, 1.0)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if is_equal_approx(_current, _target):
|
||||
return
|
||||
_current = move_toward(_current, _target, fade_speed * delta)
|
||||
_apply()
|
||||
|
||||
|
||||
func _apply() -> void:
|
||||
if material is ShaderMaterial:
|
||||
(material as ShaderMaterial).set_shader_parameter("desaturation", _current)
|
||||
Reference in New Issue
Block a user