From bac94c2c5b69c2c5234e37416677b315d7d48814 Mon Sep 17 00:00:00 2001 From: TheSecondReal0 Date: Sat, 28 Nov 2020 02:29:04 -0500 Subject: [PATCH] Basic functionality done The task system and resource now has basic functionality --- .../opensusinteraction/opensusinteraction.gd | 4 +- .../resources/interact/interact.gd | 16 +- .../resources/interact/interact.tres | 25 ++- .../resources/interacttask/interacttask.gd | 108 ++++++------ .../resources/interacttask/interacttask.tres | 9 +- src/assets/autoload/taskmanager.gd | 23 +-- src/assets/main/main.gd | 1 - .../interactpoint/interactpoint.gd | 10 +- .../interactpoint/interactpoint.tscn | 34 +--- .../interactables/standbutton/standbutton.gd | 8 +- .../standbutton/standbutton.tscn | 38 +---- src/assets/maps/test/test.tscn | 160 +++++++++++++----- src/assets/ui/hud/interactui/interactui.gd | 17 +- 13 files changed, 250 insertions(+), 203 deletions(-) diff --git a/src/addons/opensusinteraction/opensusinteraction.gd b/src/addons/opensusinteraction/opensusinteraction.gd index b7f83cf5..48e9d500 100644 --- a/src/addons/opensusinteraction/opensusinteraction.gd +++ b/src/addons/opensusinteraction/opensusinteraction.gd @@ -23,11 +23,11 @@ func _enter_tree(): #add custom resources add_custom_type("Interact", "Resource", interact_resource_script, object_icon) add_custom_type("InteractMap", "Resource", interactmap_resource_script, object_icon) - add_custom_type("Task", "Resource", task_resource_script, object_icon) + add_custom_type("InteractTask", "Resource", task_resource_script, object_icon) add_custom_type("InteractUI", "Resource", interactui_resource_script, object_icon) func _exit_tree(): remove_custom_type("Interact") remove_custom_type("InteractMap") - remove_custom_type("Task") + remove_custom_type("InteractTask") remove_custom_type("InteractUI") diff --git a/src/addons/opensusinteraction/resources/interact/interact.gd b/src/addons/opensusinteraction/resources/interact/interact.gd index ba8699de..95343c40 100644 --- a/src/addons/opensusinteraction/resources/interact/interact.gd +++ b/src/addons/opensusinteraction/resources/interact/interact.gd @@ -4,7 +4,7 @@ extends Resource #class_name Interact enum type {task = 0, ui = 1, map = 2} -export(type) var interact_type = 1 +export(type) var interact_type #needed to instance new unique resources in editor var base_task_resource:Resource = ResourceLoader.load("res://addons/opensusinteraction/resources/interacttask/interacttask.tres") @@ -68,6 +68,13 @@ func _set(property, value): # #so you can figure out how to handle it #print("setting ", property, " to ", value) match property: + "task_resource": + #if new resource is a ui interact resource + if value is preload("res://addons/opensusinteraction/resources/interacttask/interacttask.gd"): + task_res = value + else: + #create new ui interact resource + task_res = base_task_resource.duplicate() "ui_resource": #if new resource is a ui interact resource if value is preload("res://addons/opensusinteraction/resources/interactui/interactui.gd"): @@ -88,6 +95,8 @@ func _set(property, value): #overrides get(), for property groups and to display custom/fake properties/vars func _get(property): match property: + "task_resource": + return task_res "ui_resource": return ui_res "map_resource": @@ -98,6 +107,11 @@ func _get_property_list(): # #if not Engine.editor_hint: # # return [] var property_list: Array = [] + property_list.append({"name": "task_resource", + "type": TYPE_OBJECT, + "usage": PROPERTY_USAGE_DEFAULT, + "hint": PROPERTY_HINT_RESOURCE_TYPE, + }) property_list.append({"name": "ui_resource", "type": TYPE_OBJECT, "usage": PROPERTY_USAGE_DEFAULT, diff --git a/src/addons/opensusinteraction/resources/interact/interact.tres b/src/addons/opensusinteraction/resources/interact/interact.tres index 1a634907..f5144ec3 100644 --- a/src/addons/opensusinteraction/resources/interact/interact.tres +++ b/src/addons/opensusinteraction/resources/interact/interact.tres @@ -1,8 +1,10 @@ -[gd_resource type="Resource" load_steps=5 format=2] +[gd_resource type="Resource" load_steps=9 format=2] [ext_resource path="res://addons/opensusinteraction/resources/interactmap/interactmap.gd" type="Script" id=1] [ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.tres" type="Resource" id=2] [ext_resource path="res://addons/opensusinteraction/resources/interact/interact.gd" type="Script" id=3] +[ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.gd" type="Script" id=4] +[ext_resource path="res://addons/opensusinteraction/resources/interacttask/interacttask.gd" type="Script" id=5] [sub_resource type="Resource" id=1] resource_local_to_scene = true @@ -13,10 +15,29 @@ interact_data = { } +[sub_resource type="Resource" id=13] +resource_local_to_scene = true +resource_name = "InteractUI" +script = ExtResource( 4 ) +ui_name = "clockset" +ui_data = { + +} +advanced/reinstance = false + +[sub_resource type="Resource" id=14] +resource_local_to_scene = true +resource_name = "InteractTask" +script = ExtResource( 5 ) +task_text = "" +ui_resource = SubResource( 13 ) +outputs/toggle_map_interactions = false + [resource] resource_local_to_scene = true resource_name = "Interact" script = ExtResource( 3 ) -interact_type = 1 +interact_type = 0 +task_resource = SubResource( 14 ) ui_resource = ExtResource( 2 ) map_resource = SubResource( 1 ) diff --git a/src/addons/opensusinteraction/resources/interacttask/interacttask.gd b/src/addons/opensusinteraction/resources/interacttask/interacttask.gd index e89b9578..06ede766 100644 --- a/src/addons/opensusinteraction/resources/interacttask/interacttask.gd +++ b/src/addons/opensusinteraction/resources/interacttask/interacttask.gd @@ -29,35 +29,39 @@ var ui_res: Resource = base_ui_resource.duplicate() #node this task is attached to var attached_to: Node -func init_task(_from: Node = null): - print(task_text) +#assigned by TaskManager +var task_id: int + +func interact(_from: Node = null): if attached_to == null and _from != null: attached_to = _from if attached_to == null: - push_error("Task resource trying to be used with no defined node") - return - pass + push_error("InteractTask resource trying to be used with no defined node") + ui_res.interact(_from) func init_resource(_from: Node): if attached_to == null and _from != null: attached_to = _from if attached_to == null: - push_error("Task resource trying to be initiated with no defined node") + push_error("InteractTask resource trying to be initiated with no defined node") + task_id = TaskManager.register_task(gen_task_info()) func get_interact_data(_from: Node = null) -> Dictionary: if attached_to == null and _from != null: attached_to = _from if attached_to == null: - push_error("Task resource trying to be used with no defined node") + push_error("InteractTask resource trying to be used with no defined node") return gen_task_info() func gen_task_info() -> Dictionary: - var info:Dictionary = {} + var info: Dictionary = {} info["task_text"] = task_text -# info["ui_name"] = ui_name info["item_inputs"] = item_inputs info["item_outputs"] = item_outputs info["task_outputs"] = task_outputs + info["attached_node"] = attached_to + info["task_resource"] = self + #info["ui_resource"] = ui_res return info func _init(): @@ -148,8 +152,6 @@ func _get(property): #overrides get_property_list(), tells editor to show more properties in inspector func _get_property_list(): -# if not Engine.editor_hint: -# return [] var property_list: Array = [] property_list.append({"name": "ui_resource", @@ -159,36 +161,36 @@ func _get_property_list(): }) #item input toggle - property_list.append({ - "name": "inputs/toggle_items", - "type": TYPE_BOOL, - "usage": PROPERTY_USAGE_DEFAULT, - "hint": PROPERTY_HINT_NONE, - }) - #item input array field - if item_inputs_on: - property_list.append({ - "name": "inputs/input_items", - "type": TYPE_STRING_ARRAY, - "usage": PROPERTY_USAGE_DEFAULT, - "hint": PROPERTY_HINT_NONE, - }) +# property_list.append({ +# "name": "inputs/toggle_items", +# "type": TYPE_BOOL, +# "usage": PROPERTY_USAGE_DEFAULT, +# "hint": PROPERTY_HINT_NONE, +# }) +# #item input array field +# if item_inputs_on: +# property_list.append({ +# "name": "inputs/input_items", +# "type": TYPE_STRING_ARRAY, +# "usage": PROPERTY_USAGE_DEFAULT, +# "hint": PROPERTY_HINT_NONE, +# }) #item output toggle - property_list.append({ - "name": "outputs/toggle_items", - "type": TYPE_BOOL, - "usage": PROPERTY_USAGE_DEFAULT, - "hint": PROPERTY_HINT_NONE, - }) - #item output array field - if item_outputs_on: - property_list.append({ - "name": "outputs/output_items", - "type": TYPE_STRING_ARRAY, - "usage": PROPERTY_USAGE_DEFAULT, - "hint": PROPERTY_HINT_NONE, - }) +# property_list.append({ +# "name": "outputs/toggle_items", +# "type": TYPE_BOOL, +# "usage": PROPERTY_USAGE_DEFAULT, +# "hint": PROPERTY_HINT_NONE, +# }) +# #item output array field +# if item_outputs_on: +# property_list.append({ +# "name": "outputs/output_items", +# "type": TYPE_STRING_ARRAY, +# "usage": PROPERTY_USAGE_DEFAULT, +# "hint": PROPERTY_HINT_NONE, +# }) #item output toggle property_list.append({ @@ -207,18 +209,18 @@ func _get_property_list(): }) #task output toggle - property_list.append({ - "name": "outputs/toggle_tasks", - "type": TYPE_BOOL, - "usage": PROPERTY_USAGE_DEFAULT, - "hint": PROPERTY_HINT_NONE, - }) - if task_outputs_on: - property_list.append({ - "name": "outputs/output_tasks", - "type": TYPE_ARRAY, - "usage": PROPERTY_USAGE_DEFAULT, - "hint": PROPERTY_HINT_DIR, - "hint_string": "" - }) +# property_list.append({ +# "name": "outputs/toggle_tasks", +# "type": TYPE_BOOL, +# "usage": PROPERTY_USAGE_DEFAULT, +# "hint": PROPERTY_HINT_NONE, +# }) +# if task_outputs_on: +# property_list.append({ +# "name": "outputs/output_tasks", +# "type": TYPE_ARRAY, +# "usage": PROPERTY_USAGE_DEFAULT, +# "hint": PROPERTY_HINT_DIR, +# "hint_string": "" +# }) return property_list diff --git a/src/addons/opensusinteraction/resources/interacttask/interacttask.tres b/src/addons/opensusinteraction/resources/interacttask/interacttask.tres index 41be91cd..68c78291 100644 --- a/src/addons/opensusinteraction/resources/interacttask/interacttask.tres +++ b/src/addons/opensusinteraction/resources/interacttask/interacttask.tres @@ -3,11 +3,11 @@ [ext_resource path="res://addons/opensusinteraction/resources/interacttask/interacttask.gd" type="Script" id=1] [ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.gd" type="Script" id=2] -[sub_resource type="Resource" id=1] +[sub_resource type="Resource" id=13] resource_local_to_scene = true resource_name = "InteractUI" script = ExtResource( 2 ) -ui_name = "" +ui_name = "clockset" ui_data = { } @@ -18,8 +18,5 @@ resource_local_to_scene = true resource_name = "InteractTask" script = ExtResource( 1 ) task_text = "" -ui_resource = SubResource( 1 ) -inputs/toggle_items = false -outputs/toggle_items = false +ui_resource = SubResource( 13 ) outputs/toggle_map_interactions = false -outputs/toggle_tasks = false diff --git a/src/assets/autoload/taskmanager.gd b/src/assets/autoload/taskmanager.gd index 99715866..fc321fee 100644 --- a/src/assets/autoload/taskmanager.gd +++ b/src/assets/autoload/taskmanager.gd @@ -12,18 +12,11 @@ var task_transitions: Dictionary = {task_state.HIDDEN: [task_state.NOT_STARTED], task_state.COMPLETED: [] } -#stores info of each task, for instance it's type (see task_type) -#var tasks: Dictionary = {"clockset": {"type": task_type.BINARY}} -#array with all names of tasks that can be assigned, most likely used for map specific tasks -#var enabled_tasks: Array = ["clockset"] -#dictionary that stores the task IDs corresponding to the tasks assigned to the player var player_tasks: Dictionary = {} #stores task info corresponding to task IDs #format: {: {name: , type: , state: , assigned_to: []} var task_dict: Dictionary = {} -signal init_tasks - func _ready(): randomize() #print(gen_unique_id()) @@ -56,19 +49,15 @@ func transition_task(task_id: int, new_state: int) -> bool: task_dict[task_id].state = new_state return true -func new_task(players: Array, task_info: Dictionary): - #register task - var new_task_id = register_task(task_info) - - #assign task to players - for i in players: - assign_task(i, new_task_id) - -func register_task(task_info: Dictionary) -> int: +func register_task(task_data: Dictionary) -> int: var new_task_id: int = gen_unique_id() - var new_task_dict: Dictionary = {"state": task_state.NOT_STARTED, "assigned_to": []} + print("registering task with ID ", new_task_id) + var new_task_dict: Dictionary = task_data + new_task_dict["state"] = task_state.NOT_STARTED + new_task_dict["assigned_to"] = [] #do stuff with task info here task_dict[new_task_id] = new_task_dict + print("task registered: ", new_task_dict) return new_task_id func assign_task(player_id: int, task_id: int) -> void: diff --git a/src/assets/main/main.gd b/src/assets/main/main.gd index c21aa56c..e763df08 100644 --- a/src/assets/main/main.gd +++ b/src/assets/main/main.gd @@ -141,4 +141,3 @@ master func _on_maps_spawn(spawnPositions: Array): spawnPointDict[players.keys()[i]] = spawn_pos #spawn players rpc("createPlayers", Network.get_player_names(), spawnPointDict) - TaskManager.emit_signal("init_tasks") diff --git a/src/assets/maps/common/interactables/interactpoint/interactpoint.gd b/src/assets/maps/common/interactables/interactpoint/interactpoint.gd index 178d6bc3..c4e8a959 100644 --- a/src/assets/maps/common/interactables/interactpoint/interactpoint.gd +++ b/src/assets/maps/common/interactables/interactpoint/interactpoint.gd @@ -1,20 +1,22 @@ extends StaticBody2D -export(Resource) var interact +export(Resource) var interact_resource export(String) var display_text var interact_data: Dictionary = {} setget , get_interact_data func _ready(): - interact.init_resource(self) + interact_resource.init_resource(self) # print(interact.get_interact_data()) func get_interact_data(): #var interact_resource: Interact = interact - interact_data = interact.get_interact_data() + interact_data = interact_resource.get_interact_data() interact_data["display_text"] = display_text + #interact_data["interact_resource"] = interact_resource + interact_data["interact_node"] = self return interact_data func interact(): #print(interact_data) - interact.interact(self) + interact_resource.interact(self) diff --git a/src/assets/maps/common/interactables/interactpoint/interactpoint.tscn b/src/assets/maps/common/interactables/interactpoint/interactpoint.tscn index f3c19f56..460294d7 100644 --- a/src/assets/maps/common/interactables/interactpoint/interactpoint.tscn +++ b/src/assets/maps/common/interactables/interactpoint/interactpoint.tscn @@ -1,35 +1,7 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://assets/maps/common/interactables/interactpoint/interactpoint.gd" type="Script" id=1] -[ext_resource path="res://addons/opensusinteraction/resources/interact/interact.gd" type="Script" id=4] -[ext_resource path="res://addons/opensusinteraction/resources/interactmap/interactmap.gd" type="Script" id=5] -[ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.gd" type="Script" id=6] - -[sub_resource type="Resource" id=1] -resource_local_to_scene = true -resource_name = "InteractMap" -script = ExtResource( 5 ) -interact_with = NodePath("") -interact_data = { - -} - -[sub_resource type="Resource" id=2] -resource_local_to_scene = true -resource_name = "InteractUI" -script = ExtResource( 6 ) -ui_name = "" -ui_data = { - -} -advanced/reinstance = false - -[sub_resource type="Resource" id=3] -resource_local_to_scene = true -script = ExtResource( 4 ) -interact_type = 0 -ui_resource = SubResource( 2 ) -map_resource = SubResource( 1 ) +[ext_resource path="res://addons/opensusinteraction/resources/interact/interact.tres" type="Resource" id=2] [sub_resource type="RectangleShape2D" id=4] extents = Vector2( 1, 1 ) @@ -43,7 +15,7 @@ script = ExtResource( 1 ) __meta__ = { "_editor_description_": "" } -interact = SubResource( 3 ) +interact_resource = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 4 ) diff --git a/src/assets/maps/common/interactables/standbutton/standbutton.gd b/src/assets/maps/common/interactables/standbutton/standbutton.gd index 3c180969..0daceba4 100644 --- a/src/assets/maps/common/interactables/standbutton/standbutton.gd +++ b/src/assets/maps/common/interactables/standbutton/standbutton.gd @@ -1,18 +1,18 @@ extends Area2D -export(Resource) var interact +export(Resource) var interact_resource export(bool) var only_main_player = false export(int, 1, 10000) var players_to_activate = 1 -export(bool) var interact_on_exit = true +export(bool) var interact_on_exit = false var overlappingBodies: Array = [] var pressed: bool = false func _ready(): - interact.init_resource(self) + interact_resource.init_resource(self) # print(interact.get_interact_data()) func interact(): - interact.interact(self) + interact_resource.interact(self) func update(): if overlappingBodies.size() < players_to_activate: diff --git a/src/assets/maps/common/interactables/standbutton/standbutton.tscn b/src/assets/maps/common/interactables/standbutton/standbutton.tscn index 85841552..2f033873 100644 --- a/src/assets/maps/common/interactables/standbutton/standbutton.tscn +++ b/src/assets/maps/common/interactables/standbutton/standbutton.tscn @@ -1,45 +1,17 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://assets/maps/common/interactables/standbutton/standbutton.gd" type="Script" id=1] -[ext_resource path="res://addons/opensusinteraction/resources/interact/interact.gd" type="Script" id=2] -[ext_resource path="res://addons/opensusinteraction/resources/interactmap/interactmap.gd" type="Script" id=3] -[ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.gd" type="Script" id=4] +[ext_resource path="res://addons/opensusinteraction/resources/interact/interact.tres" type="Resource" id=2] -[sub_resource type="Resource" id=1] -resource_local_to_scene = true -resource_name = "InteractMap" -script = ExtResource( 3 ) -interact_with = NodePath("") -interact_data = { - -} - -[sub_resource type="Resource" id=2] -resource_local_to_scene = true -resource_name = "InteractUI" -script = ExtResource( 4 ) -ui_name = "" -ui_data = { - -} -advanced/reinstance = false - -[sub_resource type="Resource" id=3] -resource_local_to_scene = true -script = ExtResource( 2 ) -interact_type = 0 -ui_resource = SubResource( 2 ) -map_resource = SubResource( 1 ) - -[sub_resource type="RectangleShape2D" id=4] +[sub_resource type="RectangleShape2D" id=18] [node name="standbutton" type="Area2D"] z_index = -1 script = ExtResource( 1 ) -interact = SubResource( 3 ) +interact_resource = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource( 4 ) +shape = SubResource( 18 ) [node name="Polygon2D" type="Polygon2D" parent="."] color = Color( 1, 0.960784, 0, 1 ) diff --git a/src/assets/maps/test/test.tscn b/src/assets/maps/test/test.tscn index 49619eb8..e4f2236a 100644 --- a/src/assets/maps/test/test.tscn +++ b/src/assets/maps/test/test.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=2] +[gd_scene load_steps=31 format=2] [ext_resource path="res://assets/common/textures/icons/spawnpad.png" type="Texture" id=1] [ext_resource path="res://assets/maps/common/dynamic/testdoor/testdoor.tscn" type="PackedScene" id=2] @@ -12,16 +12,34 @@ [ext_resource path="res://addons/opensusinteraction/resources/interactmap/interactmap.gd" type="Script" id=10] [ext_resource path="res://addons/opensusinteraction/resources/interactui/interactui.gd" type="Script" id=11] -[sub_resource type="Resource" id=13] +[sub_resource type="Resource" id=18] resource_local_to_scene = true resource_name = "InteractMap" script = ExtResource( 10 ) -interact_with = NodePath("") +interact_with = NodePath("../testdoor") interact_data = { } -[sub_resource type="Resource" id=14] +[sub_resource type="Resource" id=19] +resource_local_to_scene = true +resource_name = "InteractUI" +script = ExtResource( 11 ) +ui_name = "clockset" +ui_data = { + +} +advanced/reinstance = false + +[sub_resource type="Resource" id=20] +resource_local_to_scene = true +resource_name = "InteractTask" +script = ExtResource( 8 ) +task_text = "" +ui_resource = SubResource( 19 ) +outputs/toggle_map_interactions = false + +[sub_resource type="Resource" id=21] resource_local_to_scene = true resource_name = "InteractUI" script = ExtResource( 11 ) @@ -31,23 +49,43 @@ ui_data = { } advanced/reinstance = false -[sub_resource type="Resource" id=3] +[sub_resource type="Resource" id=22] resource_local_to_scene = true +resource_name = "Interact" script = ExtResource( 9 ) interact_type = 2 -ui_resource = SubResource( 14 ) -map_resource = SubResource( 13 ) +task_resource = SubResource( 20 ) +ui_resource = SubResource( 21 ) +map_resource = SubResource( 18 ) -[sub_resource type="Resource" id=15] +[sub_resource type="Resource" id=23] resource_local_to_scene = true resource_name = "InteractMap" script = ExtResource( 10 ) -interact_with = NodePath("") +interact_with = NodePath("clocktext") interact_data = { } -[sub_resource type="Resource" id=16] +[sub_resource type="Resource" id=24] +resource_local_to_scene = true +resource_name = "InteractUI" +script = ExtResource( 11 ) +ui_name = "clockset" +ui_data = { + +} +advanced/reinstance = false + +[sub_resource type="Resource" id=25] +resource_local_to_scene = true +resource_name = "InteractTask" +script = ExtResource( 8 ) +task_text = "" +ui_resource = SubResource( 24 ) +outputs/toggle_map_interactions = false + +[sub_resource type="Resource" id=26] resource_local_to_scene = true resource_name = "InteractUI" script = ExtResource( 11 ) @@ -57,14 +95,16 @@ ui_data = { } advanced/reinstance = false -[sub_resource type="Resource" id=6] +[sub_resource type="Resource" id=27] resource_local_to_scene = true +resource_name = "Interact" script = ExtResource( 9 ) interact_type = 2 -ui_resource = SubResource( 16 ) -map_resource = SubResource( 15 ) +task_resource = SubResource( 25 ) +ui_resource = SubResource( 26 ) +map_resource = SubResource( 23 ) -[sub_resource type="Resource" id=17] +[sub_resource type="Resource" id=7] resource_local_to_scene = true resource_name = "InteractMap" script = ExtResource( 10 ) @@ -73,11 +113,29 @@ interact_data = { } -[sub_resource type="Resource" id=18] +[sub_resource type="Resource" id=13] resource_local_to_scene = true resource_name = "InteractUI" script = ExtResource( 11 ) -ui_name = "" +ui_name = "clockset" +ui_data = { + +} +advanced/reinstance = false + +[sub_resource type="Resource" id=16] +resource_local_to_scene = true +resource_name = "InteractTask" +script = ExtResource( 8 ) +task_text = "" +ui_resource = SubResource( 13 ) +outputs/toggle_map_interactions = false + +[sub_resource type="Resource" id=8] +resource_local_to_scene = true +resource_name = "InteractUI" +script = ExtResource( 11 ) +ui_name = "chatbox" ui_data = { } @@ -85,12 +143,31 @@ advanced/reinstance = false [sub_resource type="Resource" id=9] resource_local_to_scene = true +resource_name = "Interact" script = ExtResource( 9 ) interact_type = 1 -ui_resource = SubResource( 18 ) -map_resource = SubResource( 17 ) +task_resource = SubResource( 16 ) +ui_resource = SubResource( 8 ) +map_resource = SubResource( 7 ) -[sub_resource type="Resource" id=19] +[sub_resource type="Resource" id=10] +resource_local_to_scene = true +resource_name = "InteractMap" +script = ExtResource( 10 ) +interact_with = NodePath("") +interact_data = { + +} + +[sub_resource type="Resource" id=17] +resource_local_to_scene = true +resource_name = "InteractTask" +script = ExtResource( 8 ) +task_text = "" +ui_resource = SubResource( 13 ) +outputs/toggle_map_interactions = false + +[sub_resource type="Resource" id=11] resource_local_to_scene = true resource_name = "InteractUI" script = ExtResource( 11 ) @@ -100,15 +177,14 @@ ui_data = { } advanced/reinstance = false -[sub_resource type="Resource" id=11] +[sub_resource type="Resource" id=12] resource_local_to_scene = true -script = ExtResource( 8 ) -task_text = "sup doggy" -ui_resource = SubResource( 19 ) -inputs/toggle_items = false -outputs/toggle_items = false -outputs/toggle_map_interactions = false -outputs/toggle_tasks = false +resource_name = "Interact" +script = ExtResource( 9 ) +interact_type = 0 +task_resource = SubResource( 17 ) +ui_resource = SubResource( 11 ) +map_resource = SubResource( 10 ) [node name="test" type="YSort"] @@ -116,9 +192,9 @@ outputs/toggle_tasks = false z_index = -100 [node name="ColorRect" type="ColorRect" parent="Node2D"] -margin_left = -1117.0 +margin_left = -1117.67 margin_top = -710.188 -margin_right = 1425.0 +margin_right = 1424.33 margin_bottom = 302.812 color = Color( 0.239216, 0.239216, 0.239216, 1 ) __meta__ = { @@ -138,21 +214,20 @@ scale = Vector2( 1.5, 3 ) [node name="standbutton" parent="." instance=ExtResource( 3 )] position = Vector2( 0, -200 ) scale = Vector2( 3, 6 ) -interact = SubResource( 3 ) +interact_resource = SubResource( 22 ) [node name="standbutton2" parent="." instance=ExtResource( 3 )] position = Vector2( 0, -350 ) -interact = SubResource( 6 ) +interact_resource = SubResource( 27 ) only_main_player = true -interact_on_exit = false [node name="clocktext2" type="Label" parent="standbutton2"] -margin_left = -10.918 -margin_top = -33.9052 -margin_right = 87.082 -margin_bottom = -11.9052 +margin_left = -170.0 +margin_top = -35.0 +margin_right = 170.0 +margin_bottom = -13.0 rect_pivot_offset = Vector2( 49, 11 ) -text = "clockset task" +text = "clockset task (does not use task system)" align = 1 __meta__ = { "_edit_use_anchors_": false @@ -171,8 +246,8 @@ __meta__ = { } [node name="interactpoint" parent="." instance=ExtResource( 5 )] -position = Vector2( -450, -1.26 ) -interact = SubResource( 9 ) +position = Vector2( -450, 0 ) +interact_resource = SubResource( 9 ) display_text = "Interact chat" [node name="Polygon2D" type="Polygon2D" parent="interactpoint"] @@ -195,7 +270,8 @@ margin_top = -130.0 margin_right = 570.0 margin_bottom = 130.0 size_flags_horizontal = 0 -text = "spooky empty room " +text = "task system testing +" align = 1 valign = 1 autowrap = true @@ -204,7 +280,9 @@ __meta__ = { } [node name="tasktest" parent="." instance=ExtResource( 5 )] -interact = SubResource( 11 ) +position = Vector2( 450, 0 ) +interact_resource = SubResource( 12 ) +display_text = "task test" [node name="spawnpoints" type="Node2D" parent="."] diff --git a/src/assets/ui/hud/interactui/interactui.gd b/src/assets/ui/hud/interactui/interactui.gd index b74e7dcc..bda7d753 100644 --- a/src/assets/ui/hud/interactui/interactui.gd +++ b/src/assets/ui/hud/interactui/interactui.gd @@ -15,7 +15,7 @@ func receiveInteractData(interactData: Dictionary): createButton(i) func createButton(interactKey): - print(buttonInteractDict) + #print(buttonInteractDict) var newButton = Button.new() newButton.name = interactKey #print(newButton.name) @@ -27,10 +27,11 @@ func buttonPressed(buttonName): #print(buttonName) if not buttonInteractDict.keys().has(buttonName): return - match typeof(buttonInteractDict[buttonName].interact): - TYPE_STRING: - #open a UI - UIManager.open_menu(buttonInteractDict[buttonName].interact) - TYPE_OBJECT: - #interact with map object - MapManager.interact_with(buttonInteractDict[buttonName].interact, self) + buttonInteractDict[buttonName].interact_node.interact() +# match typeof(buttonInteractDict[buttonName].interact): +# TYPE_STRING: +# #open a UI +# UIManager.open_menu(buttonInteractDict[buttonName].interact) +# TYPE_OBJECT: +# #interact with map object +# MapManager.interact_with(buttonInteractDict[buttonName].interact, self)