Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container tasks #293

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8993e56
Container task running good
zapzoop0099 Jan 30, 2021
aed76a8
Merge branch 'main' of https://github.com/opensuspect/opensuspect int…
zapzoop0099 Jan 30, 2021
8d62ec3
Removed test debug messages
zapzoop0099 Jan 30, 2021
04185c2
Fixed both bugs proposed by damjan94 and NiceMicro
zapzoop0099 Feb 4, 2021
68548db
implemented rest of the changes
zapzoop0099 Feb 6, 2021
8d235b3
added the chemical cabinet and UI opening using the interaction resource
nicemicro Feb 10, 2021
43bf38c
Merge pull request #1 from nicemicro/container-refactor
zapzoop0099 Feb 10, 2021
71a40f3
updated with main
zapzoop0099 Feb 24, 2021
02cd2b1
Updated with main
zapzoop0099 Feb 27, 2021
409bc6e
Fixed merge mistakes
zapzoop0099 Feb 27, 2021
3530845
Custom task resource
zapzoop0099 Feb 28, 2021
8d229fc
Merge branch 'main' of https://github.com/opensuspect/opensuspect int…
zapzoop0099 Feb 28, 2021
a8b3f17
Sync work
zapzoop0099 Mar 2, 2021
8996940
renaming files
nicemicro Mar 2, 2021
58ea05c
Merge pull request #2 from nicemicro/container-help
zapzoop0099 Mar 3, 2021
ca16166
Fixed sync state
zapzoop0099 Mar 3, 2021
6bc7a25
Merge branch 'container-tasks' of https://github.com/zapzoop0099/open…
zapzoop0099 Mar 3, 2021
3d35c41
Some basic item_holding_dic added
zapzoop0099 Mar 3, 2021
63a890d
added new items for the chemical cabinet
nicemicro Mar 5, 2021
7162681
Merge pull request #3 from nicemicro/container-help
zapzoop0099 Mar 5, 2021
b1ec4d5
Interaction done
zapzoop0099 Mar 5, 2021
422e28d
Merge branch 'container-tasks' of https://github.com/zapzoop0099/open…
zapzoop0099 Mar 5, 2021
fc83e06
Basic stacking of items
zapzoop0099 Mar 6, 2021
6d4f183
added new items
nicemicro Mar 19, 2021
d3f3743
Merge pull request #4 from nicemicro/container-help
zapzoop0099 Mar 26, 2021
5233618
Basic scene setup
zapzoop0099 Mar 28, 2021
b9cfc4d
Merge branch 'main' of https://github.com/opensuspect/opensuspect int…
zapzoop0099 Mar 28, 2021
885e262
Cleanup
zapzoop0099 Mar 28, 2021
6175723
Merge branch 'main' of https://github.com/opensuspect/opensuspect int…
zapzoop0099 Mar 28, 2021
e58b129
Working Container
zapzoop0099 Mar 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ interact_data = {
}
advanced/network_sync = false

[sub_resource type="Resource" id=4]
[sub_resource type="Resource" id=2]
resource_local_to_scene = true
resource_name = "InteractUI"
script = ExtResource( 4 )
ui_name = ""
ui_name = "container"
ui_data = {

}
Expand All @@ -32,8 +32,8 @@ advanced/free_on_close = false
resource_local_to_scene = true
resource_name = "InteractTask"
script = ExtResource( 5 )
task_text = ""
ui_resource = SubResource( 4 )
task_text = "container"
ui_resource = SubResource( 2 )
outputs/toggle_map_interactions = false
outputs/output_map_interactions = [ ]
is_task_global = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func is_task_completed(player_id: int) -> bool:
return get_task_state(player_id) == TaskManager.task_state.COMPLETED

func get_task_state(player_id: int) -> int:
player_id = normalize_player_id(player_id)
player_id= normalize_player_id(player_id)
if not is_player_assigned(player_id):
#this player has not been assigned this task
return TaskManager.task_state.INVALID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
[gd_resource type="Resource" load_steps=4 format=2]
[gd_resource type="Resource" load_steps=6 format=2]

[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]
[ext_resource path="res://addons/opensusinteraction/resources/interactmap/interactmap.gd" type="Script" id=3]

[sub_resource type="Resource" id=1]
resource_local_to_scene = true
resource_name = "InteractUI"
resource_name = "InteractMap"
script = ExtResource( 3 )
interact_with = NodePath("")
interact_data = {

}
advanced/network_sync = false

[sub_resource type="Resource" id=2]
resource_local_to_scene = true
script = ExtResource( 2 )
ui_name = ""
ui_data = {
Expand All @@ -20,7 +30,7 @@ resource_local_to_scene = true
resource_name = "InteractTask"
script = ExtResource( 1 )
task_text = ""
ui_resource = SubResource( 1 )
ui_resource = SubResource( 2 )
outputs/toggle_map_interactions = false
outputs/output_map_interactions = [ ]
outputs/output_map_interactions = [ SubResource( 1 ) ]
is_task_global = false
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
resource_local_to_scene = true
resource_name = "InteractUI"
script = ExtResource( 1 )
ui_name = ""
ui_name = "container"
ui_data = {

}
action = 0
action = 3
advanced/reinstance = false
advanced/free_on_close = false
6 changes: 6 additions & 0 deletions src/assets/autoload/taskmanager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ var player_tasks: Dictionary = {}
#format: {<task id>: {name: <task_name>, type: <task type>, state: <task state>, resource: <InteractTask resource>, assigned_players: [<network IDs of players task is assigned to>]}
var task_dict: Dictionary = {}

var available_items:Dictionary = {
"large-liquid-bottle":{"scene":preload("res://assets/items/large-liquid-bottle.tscn"),"position":Vector2(40,56),"shift":8,"scale":Vector2(1.5,1.5)},
"powder-bottle":{"scene":preload("res://assets/items/powder-bottle.tscn"),"position":Vector2(40,80),"shift":8,"scale":Vector2(2,2)},
"small-liquid-bottle":{"scene":preload("res://assets/items/small-liquid-bottle.tscn"),"position":Vector2(40,64),"shift":8,"scale":Vector2(2,2)}
}

var node_path_resource: Dictionary = {}

const PLAYER_ID_KEY = "player_id"
Expand Down
17 changes: 14 additions & 3 deletions src/assets/autoload/uimanager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var ui_list: Dictionary = {
"appearance_editor": {"scene": preload("res://assets/ui/submenus/appearance_editor/appearance_editor.tscn")},

#task UI
"clockset": {"scene": preload("res://assets/ui/tasks/clockset/clockset.tscn")}
"clockset": {"scene": preload("res://assets/ui/tasks/clockset/clockset.tscn")},
"container":{"scene": preload("res://assets/ui/tasks/container/container.tscn")}
}

var current_ui: Control
Expand All @@ -35,6 +36,7 @@ signal close_ui(ui_name, free)
signal instance_ui(ui_name, ui_data)
signal update_ui(ui_name, ui_data)
signal free_ui(ui_name)
signal pre_instance(ui_name)
signal close_all_ui()

func _ready():
Expand Down Expand Up @@ -85,6 +87,11 @@ func free_ui(ui_name: String):
push_error("free_ui() called with invalid ui name " + ui_name)
emit_signal("free_ui", ui_name)

func pre_instance(ui_name:String):
if not ui_list.keys().has(ui_name):
push_error("pre_ins() called with invalid ui name " + ui_name)
emit_signal("pre_instance", ui_name)

func close_all_ui(free: bool = false):
emit_signal("close_all_ui", free)

Expand Down Expand Up @@ -116,9 +123,13 @@ func state_changed(old_state, new_state):
func state_changed_priority(old_state, new_state, priority):
if priority != 0:
return
if new_state == GameManager.State.Normal:
match new_state:
GameManager.State.Normal:
# needs to call _on_ready to connect signals, before roles are assigned
open_ui("rolescreen")
open_ui("rolescreen")
pre_instance("container")
GameManager.State.Lobby:
free_ui("container")
func in_ui() -> bool:
return not open_uis.empty()

Expand Down
31 changes: 31 additions & 0 deletions src/assets/common/classes/ui/base/margincontainerbase.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extends MarginContainer

class_name MarginContainerBase

export (String) var menu_name

export (bool) var disable_movement

var ui_data: Dictionary = {}

func _init():
# warning-ignore:return_value_discarded
connect("visibility_changed", self, "_on_visibility_changed")
#called by ui system
func base_open():
show()

#called by self or ui system
func base_close():
hide()



func _on_visibility_changed():
if not disable_movement:
return
if visible:
UIManager.ui_opened(menu_name)
else:
UIManager.ui_closed(menu_name)

30 changes: 19 additions & 11 deletions src/assets/items/battery.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=10 format=2]

[ext_resource path="res://assets/items/item.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/items/textures/battery.png" type="Texture" id=2]
[ext_resource path="res://assets/common/shaders/items.shader" type="Shader" id=3]

[sub_resource type="RectangleShape2D" id=6]
[sub_resource type="ShaderMaterial" id=1]
resource_local_to_scene = true
shader = ExtResource( 3 )
shader_param/line_color = Color( 1, 1, 1, 1 )
shader_param/line_thickness = 5.0

[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 9.5, 4.4 )

[sub_resource type="Shader" id=2]
[sub_resource type="Shader" id=3]
resource_local_to_scene = true
code = "shader_type canvas_item;

Expand Down Expand Up @@ -34,41 +41,42 @@ void fragment()
COLOR = mix(color, outlined_result, outlined_result.a);
}"

[sub_resource type="ShaderMaterial" id=3]
[sub_resource type="ShaderMaterial" id=4]
resource_local_to_scene = true
shader = SubResource( 2 )
shader = SubResource( 3 )
shader_param/line_color = Color( 1, 1, 0, 0 )
shader_param/line_thickness = 5.0

[sub_resource type="SpriteFrames" id=4]
[sub_resource type="SpriteFrames" id=5]
animations = [ {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]

[sub_resource type="CapsuleShape2D" id=5]
[sub_resource type="CapsuleShape2D" id=6]
radius = 8.0
height = 12.0

[node name="Battery" instance=ExtResource( 1 )]
material = SubResource( 1 )
position = Vector2( -0.0936432, 0 )

[node name="ItemCollision" parent="." index="0"]
rotation = 2.35619
shape = SubResource( 6 )
shape = SubResource( 2 )

[node name="SpritePosition" parent="." index="2"]
position = Vector2( 0, 0 )

[node name="ItemSprite" parent="SpritePosition" index="0"]
material = SubResource( 3 )
material = SubResource( 4 )
rotation = 2.35619
scale = Vector2( 0.1, 0.1 )
frames = SubResource( 4 )
frames = SubResource( 5 )
offset = Vector2( 0, 0 )

[node name="MouseCollision" parent="SpritePosition/MouseArea" index="0"]
rotation = 0.785398
shape = SubResource( 5 )
shape = SubResource( 6 )
56 changes: 56 additions & 0 deletions src/assets/items/beaker-empty.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[gd_scene load_steps=9 format=2]

[ext_resource path="res://assets/items/item.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/common/shaders/items.shader" type="Shader" id=2]
[ext_resource path="res://assets/items/textures/beaker-empty.png" type="Texture" id=3]

[sub_resource type="ShaderMaterial" id=1]
resource_local_to_scene = true
shader = ExtResource( 2 )
shader_param/line_color = Color( 1, 1, 1, 1 )
shader_param/line_thickness = 5.0

[sub_resource type="CapsuleShape2D" id=2]
radius = 11.125
height = 4.872

[sub_resource type="ShaderMaterial" id=3]
resource_local_to_scene = true
shader = ExtResource( 2 )
shader_param/line_color = Color( 1, 1, 0, 0 )
shader_param/line_thickness = 5.0

[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ ExtResource( 3 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]

[sub_resource type="CapsuleShape2D" id=5]
radius = 13.125
height = 7.5

[node name="BeakerEmpty" instance=ExtResource( 1 )]
material = SubResource( 1 )
position = Vector2( 0, 0.436 )

[node name="ItemCollision" parent="." index="0"]
visible = false
position = Vector2( 3.5, 10 )
shape = SubResource( 2 )

[node name="ItemSprite" parent="SpritePosition" index="0"]
material = SubResource( 3 )
position = Vector2( 4, 8 )
scale = Vector2( 0.15, 0.15 )
frames = SubResource( 4 )
offset = Vector2( 0, 0 )

[node name="MouseArea" parent="SpritePosition" index="1"]
visible = false

[node name="MouseCollision" parent="SpritePosition/MouseArea" index="0"]
position = Vector2( 3, 6 )
shape = SubResource( 5 )
54 changes: 54 additions & 0 deletions src/assets/items/flask-empty.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[gd_scene load_steps=9 format=2]

[ext_resource path="res://assets/items/item.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/common/shaders/items.shader" type="Shader" id=2]
[ext_resource path="res://assets/items/textures/flask-empty.png" type="Texture" id=3]

[sub_resource type="ShaderMaterial" id=1]
resource_local_to_scene = true
shader = ExtResource( 2 )
shader_param/line_color = Color( 1, 1, 1, 1 )
shader_param/line_thickness = 5.0

[sub_resource type="CapsuleShape2D" id=2]
radius = 8.98537
height = 5.18001

[sub_resource type="ShaderMaterial" id=3]
resource_local_to_scene = true
shader = ExtResource( 2 )
shader_param/line_color = Color( 1, 1, 0, 0 )
shader_param/line_thickness = 5.0

[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ ExtResource( 3 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]

[sub_resource type="CapsuleShape2D" id=5]
radius = 10.8208
height = 6.84969

[node name="FlaskEmpty" instance=ExtResource( 1 )]
material = SubResource( 1 )

[node name="ItemCollision" parent="." index="0"]
visible = false
position = Vector2( 0, 7 )
shape = SubResource( 2 )

[node name="ItemSprite" parent="SpritePosition" index="0"]
material = SubResource( 3 )
position = Vector2( 0, 8 )
scale = Vector2( 0.15, 0.15 )
frames = SubResource( 4 )

[node name="MouseArea" parent="SpritePosition" index="1"]
visible = false

[node name="MouseCollision" parent="SpritePosition/MouseArea" index="0"]
position = Vector2( 0, 5 )
shape = SubResource( 5 )
Loading