forked from xiangwang25/whale-town-front-v2
feat: add nearby social interactions
This commit is contained in:
@@ -31,6 +31,7 @@ var _isInsideMall: bool = false
|
||||
var _mallCanEnter: bool = true
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("whaletown_interactable")
|
||||
_apply_spawn_point()
|
||||
_configure_camera()
|
||||
_ensure_mall_panel()
|
||||
@@ -38,12 +39,23 @@ func _ready() -> void:
|
||||
_ensure_mall_entrance_area()
|
||||
EventSystem.connect_event(EventNames.OBJECT_INTERACTED, _on_object_interacted, self)
|
||||
EventSystem.connect_event(EventNames.MALL_CLOSED, _on_mall_closed, self)
|
||||
_discover_destination()
|
||||
|
||||
func _discover_destination() -> void:
|
||||
var destination_id := SceneManager.get_next_destination_id()
|
||||
if destination_id.is_empty():
|
||||
destination_id = "work_entrance"
|
||||
var socialManager := get_node_or_null("/root/SocialManager")
|
||||
if socialManager != null and socialManager.has_method("discover_destination"):
|
||||
socialManager.call("discover_destination", destination_id)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
EventSystem.disconnect_event(EventNames.OBJECT_INTERACTED, _on_object_interacted, self)
|
||||
EventSystem.disconnect_event(EventNames.MALL_CLOSED, _on_mall_closed, self)
|
||||
|
||||
func _apply_spawn_point() -> void:
|
||||
if player.has_scene_position_override:
|
||||
return
|
||||
var spawnName: String = SceneManager.get_next_spawn_name()
|
||||
var markerName: String = spawnName if not spawnName.is_empty() else "DefaultSpawn"
|
||||
var marker := $Markers.get_node_or_null(markerName) as Marker2D
|
||||
@@ -112,15 +124,14 @@ func _ensure_mall_entrance_area() -> void:
|
||||
|
||||
func _setup_mall_entrance_trigger(entrance: Area2D) -> void:
|
||||
_mallEntranceArea = entrance
|
||||
_mallEntranceArea.collision_mask = PLAYER_COLLISION_LAYER
|
||||
if not _mallEntranceArea.body_entered.is_connected(_on_mall_entrance_body_entered):
|
||||
_mallEntranceArea.body_entered.connect(_on_mall_entrance_body_entered)
|
||||
_mallEntranceArea.collision_mask = 0
|
||||
|
||||
func _on_object_interacted(data: Dictionary) -> void:
|
||||
var buildingId := str(data.get("buildingId", ""))
|
||||
if buildingId.is_empty():
|
||||
return
|
||||
if buildingId == "whale_super_mall":
|
||||
_enter_mall()
|
||||
return
|
||||
if buildingId == "virtual_whale_recruitment_board":
|
||||
_open_course_board()
|
||||
@@ -142,9 +153,7 @@ func _open_course_board() -> void:
|
||||
_courseBoardPanel.call("show_panel")
|
||||
|
||||
func _on_mall_entrance_body_entered(body: Node2D) -> void:
|
||||
if body != player or not _mallCanEnter:
|
||||
return
|
||||
_enter_mall()
|
||||
return
|
||||
|
||||
func _enter_mall() -> void:
|
||||
if _isInsideMall:
|
||||
|
||||
Reference in New Issue
Block a user