classname InteractionRayCast extends RayCast3D signal interactableseen(interactable)…
- User
class_name InteractionRayCast extends RayCast3D
signal interactable_seen(interactable) signal interactable_unseen()
@onready var shapecast : ShapeCast3D = $InteractionShapecast
currently a node, but could just be an offset position
if shapecasting, the collider closest to the hotspot's position is used
@onready var hotspot : Node3D = $ShapecastHotspot
the starting position of the hotspot, which is closer to the raycast target position
var hotspot_base_pos_z : float = -1.5
DEBUGGING
@onready var raycast_highlighter = TargetHighlighter
- Assistant
- User
- Assistant
- User
class_name InteractionShapeCast extends ShapeCast3D
signal interactable_seen(interactable) signal interactable_unseen()
var _interactable = null: set = _set_interactable
func _ready() -> void: pass
func _process(_delta: float) -> void: _update_interactable()
func _set_interactable(value) -> void: _interactable = value if _interactable == null: interactable_unseen.emit() else: interactable_seen.emit(_interactable)
func _update_interactable() -> void: if !is_colliding(): return var collider = get_collider(0)
# Handle freed objects. # is_instance_valid() will be false for null and for freed objects, but only # null will return 0 for typeof() if not is_instance_valid(_interactable): if typeof(_interactable) != 0: _interactable = null return # Handle all colliders that aren't in the interactable group as null. if collider != null and not collider.is_in_group("interactable"): collider = null if collider == _interactable: return # HACK: Turns out a null from the collider is/can be an object. # This changes it to an actual null, so the freed object handling # won't trigger on it. if collider == null and typeof(collider) != 0: collider = null _interactable = collider - Assistant
- User
extends Node
signal item_found
@export var container_to_check : CogitoContainer @export var item_to_check_for : InventoryItemPD
var container_inventory : CogitoInventory
Called when the node enters the scene tree for the first time.
func _ready() -> void: container_inventory = container_to_check.inventory_data
func is_item_in_inventory(sought_item:InventoryItemPD, inventory: CogitoInventory) -> bool: for slot in inventory.inventory_slots: if slot != null and slot.inventory_item == sought_item: return true
return falsefunc update_inventory() -> void: container_inventory = container_to_check.inventory_data
func check_inventory() -> void: print("Inventory checker: Checking for ", item_to_check_for.name, " in ", container_inventory) if is_item_in_inventory(item_to_check_for, container_inventory): print("Inventory Checker: Item found: ", item_to_check_for) item_found.emit()
- Assistant
- User
extends Node
Filepath to the main menu scene.
@export_file("*.tscn") var main_menu_scene
Filepath to the scene the player should start in, when pressing "Start game" button.
@export_file("*.tscn") var start_game_scene
func _on_main_menu_start_game_pressed(): if start_game_scene: CogitoSceneManager.load_next_scene(start_game_scene, "", "temp", CogitoSceneManager.CogitoSceneLoadMode.RESET) #Load_mode 2 means there's no attempt to load a state. else: print("No start game scene set in the Scene switcher.")
func _on_pause_menu_back_to_main_pressed(): if main_menu_scene: CogitoSceneManager.load_next_scene(main_menu_scene, "", "temp", CogitoSceneManager.CogitoSceneLoadMode.RESET) #Load_mode 2 means there's no attempt to load a state. else: print("No main menu scene set in the Scene switcher.")
- Assistant