This commit is contained in:
2026-01-21 23:40:20 +01:00
commit d1f8068081
478 changed files with 24902 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
extends Area2D
class_name MouseInteractionComponent
@export var stickyHold: bool = false #When this is true the action can be held even tho the mouse has allready left the area
var mouseInside: bool = false #When mouse is inside collision
var mousePressedL: bool = false #When Left mouse button is pressed down
var actionHeld: bool = false
signal actionPressed
func _input(event: InputEvent) -> void:
if event.is_action_pressed("MinigameClick"):
mousePressedL = true
if event.is_action_released("MinigameClick"):
mousePressedL = false
func _process(_delta: float) -> void:
if mousePressedL and (mouseInside or (stickyHold and actionHeld)):
if !actionHeld:
actionPressed.emit()
actionHeld = true
else:
actionHeld = false
func _mouse_enter() -> void:
mouseInside = true
func _mouse_exit() -> void:
mouseInside = false

View File

@@ -0,0 +1 @@
uid://dikeg0o7owamv

View File

@@ -0,0 +1,88 @@
extends Node2D
class_name DragComponent
@export var MouseIntComp: MouseInteractionComponent ##Where the player klicks to drag the component
@export var intBox: InteractBoxMinigame ##Used to determine if this component interacts with another component
@export var canDrag: bool = true ##If true the component can be moved by dragging it
@export var singleDrag: bool = true ##If true the component can only be moved when its the only dragged component
@export var resetWhenLetGo: bool = false ##If the player stops dragging the component returns to its home pos
@export var lockWhenatGoal: bool = false ##If the component reaches a goal, it cannot be dragged anymore
@export var openLockOnClick: bool = false ##If the component is clicked (Impulse) it will stop being locked at its goal (THIS REQUIRES LOCK WHEN AT GOAL TO BE TRUE)
@export var goalID: int = 0 ##What goals this component can interact with (All goals of the same ID)
@export var homePos: Vector2 = Vector2(0,0) ##If this is 0,0 it gets set to the current position on ready
@export var goalPos: Vector2 = Vector2(0,0) ##Position of goal where to component can be dragged to stay there
var leftMouseClicked: bool = false
var atGoal: bool = false
var goalSocket: GoalBox
var mousePos: Vector2 = Vector2(0,0)
func _ready() -> void:
if intBox:
intBox.area_entered.connect(areaEntered)
intBox.area_exited.connect(areaExited)
if MouseIntComp:
MouseIntComp.stickyHold = true
MouseIntComp.actionPressed.connect(interactionClicked)
if !homePos:
homePos = self.position
else:
self.position = homePos
func _input(event: InputEvent) -> void:
if event is InputEventMouse:
mousePos = event.position
func _process(_delta: float) -> void:
if atGoal and lockWhenatGoal:
self.position = goalPos
canDrag = false
MouseIntComp.monitorable = false
return
else:
MouseIntComp.monitorable = true
if openLockOnClick and !atGoal:
lockWhenatGoal = true
if !canDrag: return
if MouseIntComp.actionHeld:
self.position = mousePos
elif atGoal:
self.position = goalPos
elif resetWhenLetGo:
self.position = homePos
func interactionClicked() -> void:
if openLockOnClick and atGoal:
lockWhenatGoal = false
canDrag = true
func areaEntered(area: Area2D) -> void:
if area is GoalBox:
if area.goalID == goalID:
goalPos = area.position
atGoal = true
goalSocket = area
if area is MouseInteractionComponent and singleDrag and canDrag:
MouseIntComp.actionHeld = false
self.position = homePos
func areaExited(area: Area2D) -> void:
if area is GoalBox:
if area.goalID == goalID:
atGoal = false
if area == goalSocket:
goalSocket = null
func adaptCoordinateScale(input: Vector2) -> Vector2:
return input / Vector2(1152,648) * Vector2(DisplayServer.window_get_size())

View File

@@ -0,0 +1 @@
uid://djrwyn7u5y1eh

View File

@@ -0,0 +1,8 @@
extends Area2D
class_name GoalBox
@export var goalID: int = 0
#func _ready() -> void:
#collision_layer = 2
#collision_mask = 2

View File

@@ -0,0 +1 @@
uid://bt0fia4w2r4qv

View File

@@ -0,0 +1,6 @@
extends Area2D
class_name InteractBoxMinigame
#func _ready() -> void:
#collision_layer = 2
#collision_mask = 2

View File

@@ -0,0 +1 @@
uid://bxwi8drvl4kec

View File

@@ -0,0 +1,17 @@
extends Node2D
class_name MinigameController
var winState: bool = false #Indicates if the minigame has been solved
signal minigameWon
signal minigameLost
func win() -> void:
minigameWon.emit()
Minigames.endMinigame(true)
winState = true
func loose() -> void:
minigameLost.emit()
Minigames.endMinigame(false)
winState = false

View File

@@ -0,0 +1 @@
uid://ckjr8awjg22gw

View File

@@ -0,0 +1,8 @@
extends Line2D
@export var point2pos: Node2D
func _process(_delta: float) -> void:
points[2] = point2pos.position - self.position

View File

@@ -0,0 +1 @@
uid://bfrgkhri72myr