2024-01-20 12:17:43 +00:00
|
|
|
class_name InteractionManager extends Node
|
|
|
|
|
|
|
|
@export var sign : Signature
|
|
|
|
@export var brief : BriefcaseMachine
|
|
|
|
@export var heaven : Heaven
|
|
|
|
@export var intro : IntroManager
|
|
|
|
@export var cursor : CursorManager
|
|
|
|
@export var mouseRay : MouseRaycast
|
|
|
|
@export var shotgun : ShotgunShooting
|
|
|
|
@export var decision : DecisionTextManager
|
|
|
|
@export var itemManager : ItemManager
|
|
|
|
@export var itemInteraction : ItemInteraction
|
2024-04-05 10:52:30 +01:00
|
|
|
@export var crt : CRT
|
2024-01-20 12:17:43 +00:00
|
|
|
var activeParent
|
|
|
|
var activeInteractionBranch
|
|
|
|
var checking = true
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
CheckPickupLerp()
|
|
|
|
CheckInteractionBranch()
|
|
|
|
if (checking): CheckIfHovering()
|
|
|
|
pass
|
|
|
|
|
|
|
|
func _input(event):
|
|
|
|
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
2024-04-05 10:52:30 +01:00
|
|
|
MainInteractionEvent()
|
|
|
|
|
|
|
|
func MainInteractionEvent():
|
|
|
|
if (activeInteractionBranch != null && activeInteractionBranch.interactionAllowed && !activeInteractionBranch.interactionInvalid):
|
|
|
|
var childArray = activeInteractionBranch.get_parent().get_children()
|
|
|
|
for i in range(childArray.size()): if (childArray[i] is PickupIndicator): childArray[i].SnapToMax()
|
|
|
|
if (!activeInteractionBranch.isGrid): InteractWith(activeInteractionBranch.interactionAlias)
|
|
|
|
else: InteractWithGrid(activeInteractionBranch.gridIndex)
|
2024-01-20 12:17:43 +00:00
|
|
|
|
|
|
|
func CheckIfHovering():
|
|
|
|
if (activeInteractionBranch != null && activeInteractionBranch.interactionAllowed):
|
|
|
|
if (activeInteractionBranch.interactionAllowed && !activeInteractionBranch.interactionInvalid):
|
|
|
|
cursor.SetCursorImage("hover")
|
|
|
|
else: if (activeInteractionBranch.interactionAllowed && activeInteractionBranch.interactionInvalid):
|
|
|
|
cursor.SetCursorImage("invalid")
|
|
|
|
else:
|
|
|
|
cursor.SetCursorImage("point")
|
|
|
|
|
2024-04-10 19:19:04 +01:00
|
|
|
var fs_dec = false
|
2024-01-20 12:17:43 +00:00
|
|
|
func InteractWith(alias : String):
|
|
|
|
match(alias):
|
|
|
|
"shotgun":
|
|
|
|
shotgun.GrabShotgun()
|
|
|
|
"text dealer":
|
2024-04-10 19:19:04 +01:00
|
|
|
if (!fs_dec):
|
|
|
|
shotgun.Shoot("dealer")
|
|
|
|
decision.SetUI(false)
|
|
|
|
fs_dec = true
|
2024-01-20 12:17:43 +00:00
|
|
|
"text you":
|
2024-04-10 19:19:04 +01:00
|
|
|
if (!fs_dec):
|
|
|
|
shotgun.Shoot("self")
|
|
|
|
decision.SetUI(false)
|
|
|
|
fs_dec = true
|
2024-01-20 12:17:43 +00:00
|
|
|
"briefcase intake":
|
|
|
|
itemManager.GrabItem()
|
|
|
|
"item":
|
|
|
|
if (activeInteractionBranch.itemName != ""):
|
|
|
|
itemInteraction.PickupItemFromTable(activeInteractionBranch.get_parent(), activeInteractionBranch.itemName)
|
|
|
|
"bathroom door":
|
|
|
|
intro.Interaction_BathroomDoor()
|
|
|
|
"backroom door":
|
|
|
|
intro.Interaction_BackroomDoor()
|
|
|
|
"heaven door":
|
|
|
|
heaven.Fly()
|
|
|
|
"latch left":
|
|
|
|
brief.OpenLatch("L")
|
|
|
|
"latch right":
|
|
|
|
brief.OpenLatch("R")
|
|
|
|
"briefcase lid":
|
|
|
|
brief.OpenLid()
|
|
|
|
"release form on table":
|
|
|
|
sign.PickUpWaiver()
|
|
|
|
"signature machine button":
|
|
|
|
sign.GetInput(activeInteractionBranch.signatureButton_letterAlias, activeInteractionBranch.signatureButton_specialAlias)
|
|
|
|
activeInteractionBranch.assignedSignatureButton.Press()
|
2024-01-28 11:58:35 +00:00
|
|
|
"pill bottle":
|
|
|
|
intro.Interaction_PillBottle()
|
|
|
|
"pill choice no":
|
|
|
|
intro.SelectedPill(false)
|
|
|
|
"pill choice yes":
|
|
|
|
intro.SelectedPill(true)
|
|
|
|
"double yes":
|
|
|
|
shotgun.roundManager.Response(true)
|
|
|
|
"double no":
|
|
|
|
shotgun.roundManager.Response(false)
|
2024-04-05 10:52:30 +01:00
|
|
|
"crt":
|
|
|
|
intro.Interaction_CRT()
|
|
|
|
"crt button":
|
|
|
|
if (activeInteractionBranch.crtButton_alias != ""):
|
|
|
|
#activeInteractionBranch.get_parent().get_child(1).Press()
|
|
|
|
crt.Interaction(activeInteractionBranch.crtButton_alias)
|
|
|
|
|
|
|
|
func SignatureButtonRemote(assignedBranch : SignButton, alias : String):
|
|
|
|
sign.GetInput(alias, alias)
|
|
|
|
assignedBranch.Press()
|
|
|
|
pass
|
2024-01-20 12:17:43 +00:00
|
|
|
|
|
|
|
func InteractWithGrid(tempGridIndex : int):
|
|
|
|
itemManager.PlaceDownItem(tempGridIndex)
|
|
|
|
pass
|
|
|
|
|
|
|
|
func CheckPickupLerp():
|
|
|
|
if (mouseRay.result != null && mouseRay.result.has("collider") && cursor.cursor_visible):
|
|
|
|
var parent = mouseRay.result.collider.get_parent()
|
|
|
|
activeParent = parent
|
|
|
|
var childArray = parent.get_children()
|
|
|
|
for i in range(childArray.size()):
|
|
|
|
if (childArray[i] is PickupIndicator):
|
|
|
|
var indicator = childArray[i]
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
activeParent = null
|
|
|
|
pass
|
|
|
|
|
|
|
|
func CheckInteractionBranch():
|
|
|
|
var isFound = null
|
|
|
|
if (activeParent != null):
|
|
|
|
var childArray = activeParent.get_children()
|
|
|
|
for i in range(childArray.size()):
|
|
|
|
if (childArray[i] is InteractionBranch):
|
|
|
|
var branch = childArray[i]
|
|
|
|
# activeInteractionBranch = childArray[i]
|
|
|
|
isFound = childArray[i]
|
|
|
|
break
|
|
|
|
if (isFound):
|
|
|
|
activeInteractionBranch = isFound
|
|
|
|
else:
|
|
|
|
activeInteractionBranch = null
|