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 3 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 @@ -33,8 +33,11 @@ resource_local_to_scene = true
resource_name = "InteractTask"
script = ExtResource( 5 )
task_text = ""
random_numbers = 0
task_id = -1
ui_resource = SubResource( 2 )
outputs/toggle_map_interactions = false
is_task_global = false

[resource]
resource_local_to_scene = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ resource_local_to_scene = true
resource_name = "InteractTask"
script = ExtResource( 1 )
task_text = ""
random_numbers = 0
task_id = -1
ui_resource = SubResource( 1 )
outputs/toggle_map_interactions = false
is_task_global = false
9 changes: 8 additions & 1 deletion 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_ins(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_ins(ui_name:String):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this function do(maybe a more descriptive name)?

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

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

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

class_name MarginContainerBase

export (String) var menu_name

export (bool) var disable_movement

var ui_data: Dictionary = {}

func _init():
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()

# warning-ignore:unused_argument

func _on_visibility_changed():
if not disable_movement:
return
if visible:
UIManager.ui_opened(menu_name)
else:
UIManager.ui_closed(menu_name)
11 changes: 8 additions & 3 deletions src/assets/items/item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ var can_pickup_with_mouse: bool
var holding_player: Player
var being_held: bool
var being_picked_up: bool
var item_location:NodePath #The location of the item
var item_from_container:bool #Checks item is from container or not

func _ready() -> void:
$ItemAnimator.play("hover")

func _ready() -> void:
# Wait another frame for map to finish setting up
yield(get_tree(), "idle_frame")
# print("(items.gd/_ready)")
Expand All @@ -34,7 +35,11 @@ func picked_up() -> void:
"""Item is picked up."""
set_collision_layer_bit(4, false)
being_held = true
map_items.remove_child(self)
if item_from_container:
var path = get_tree().get_root().get_node(item_location)
path.remove_child(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bug @nicemicro and I found(where items get teleported to (0,0) coordinate) is because item_from_container is never set to false. you could set it to false here...

else:
map_items.remove_child(self)
holding_player.item_handler.add_child(self)
position = Vector2.ZERO

Expand Down
5 changes: 5 additions & 0 deletions src/assets/main/maps.gd
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func switchMap(newMap: String) -> void:
# actual current map to position 0 manually.
move_child(mapClone, 0)
emit_signal("spawn", getSpawnPoints())
if newMap == "Test":
init_all_tasks()
Copy link
Contributor

@Damjan94 Damjan94 Jan 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved below line 128 in uimnager, because it is ui based, and that's where I have put open_ui("rolescreen").

wait for other peoples input, before you change this one, as I'm not 100% sure myself


func instance_map(map_name: String) -> Node:
# print("instancing map ", map_name)
Expand Down Expand Up @@ -107,3 +109,6 @@ func load_map_info_resources() -> Array:
if not res is MapInfo:
resources.erase(res)
return resources

func init_all_tasks():
UIManager.pre_ins("container")
45 changes: 45 additions & 0 deletions src/assets/maps/test/Container.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
extends Area2D

#export(Resource) var interact_resource
var pressed:bool = false
var interacting:bool = false
var interactor:Dictionary
#TODO:Add a shader


func _ready():
#interact_resource.init_resource(self)
pass

func reset() -> void: #Resets the node
interacting = false
pressed = false
interactor.clear()

func register(body) -> void:#Register a body
interactor[body.id] = body.get_path()
interactor["bool"] = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this bool do? more descriptive names can never hurt

return

func _input(event):#Checks that the player presses the key is in interacting dic
if event.is_action_pressed("interact") and interactor.keys().has(Network.get_my_id()):
interacting = true
pressed = true
UIManager.open_ui("container", interactor)
#interact(interactor)

func _on_Container_body_entered(_body):#Check wether the body is player or not and record the player
for bodies in get_overlapping_bodies():
if bodies.is_in_group("players"):
if interactor.empty():
register(bodies)
else:
return
Copy link
Contributor

@Damjan94 Damjan94 Jan 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be better structured as

	# Can't register a new body, if there is an already registered body
	if is_body_registered():
		return

	for bodies in get_overlapping_bodies():
		if not bodies.is_in_group("players"):
			continue

		register(bodies)
		return

func is_body_registered() -> bool:
	return interactor.size() > 0



func _on_Container_body_exited(_body):#Closes the ui
UIManager.close_ui("container")
reset()

#func interact(interactor):#The main func to pass data
# interact_resource.interact(self,interactor)
52 changes: 42 additions & 10 deletions src/assets/maps/test/test.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=38 format=2]
[gd_scene load_steps=41 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]
Expand All @@ -11,9 +11,11 @@
[ext_resource path="res://addons/opensusinteraction/resources/interact/interact.gd" type="Script" id=9]
[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]
[ext_resource path="res://assets/maps/test/Container.gd" type="Script" id=12]
[ext_resource path="res://assets/items/battery.tscn" type="PackedScene" id=13]
[ext_resource path="res://assets/items/wrench.tscn" type="PackedScene" id=14]
[ext_resource path="res://assets/maps/map.gd" type="Script" id=15]
[ext_resource path="res://assets/player/textures/characters/black/black-proto-1.png" type="Texture" id=16]

[sub_resource type="Resource" id=1]
resource_local_to_scene = true
Expand All @@ -33,8 +35,9 @@ ui_name = ""
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=3]
resource_local_to_scene = true
Expand All @@ -55,8 +58,9 @@ ui_name = ""
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=5]
resource_local_to_scene = true
Expand Down Expand Up @@ -94,8 +98,9 @@ ui_name = "clockset"
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=9]
resource_local_to_scene = true
Expand All @@ -115,8 +120,9 @@ ui_name = ""
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=11]
resource_local_to_scene = true
Expand All @@ -133,8 +139,9 @@ ui_name = "clockset"
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=13]
resource_local_to_scene = true
Expand All @@ -152,8 +159,9 @@ ui_name = ""
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=15]
resource_local_to_scene = true
Expand All @@ -172,8 +180,9 @@ ui_name = "chatbox"
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=17]
resource_local_to_scene = true
Expand Down Expand Up @@ -209,8 +218,9 @@ ui_name = "clockset"
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=21]
resource_local_to_scene = true
Expand All @@ -230,8 +240,9 @@ ui_name = ""
ui_data = {

}
action = 0
advanced/reinstance = false
advanced/only_instance = false
advanced/free_on_close = false

[sub_resource type="Resource" id=23]
resource_local_to_scene = true
Expand All @@ -241,6 +252,9 @@ task_resource = SubResource( 21 )
ui_resource = SubResource( 22 )
map_resource = SubResource( 18 )

[sub_resource type="RectangleShape2D" id=24]
extents = Vector2( 24, 24 )

[node name="test" type="YSort"]
script = ExtResource( 15 )

Expand Down Expand Up @@ -454,6 +468,24 @@ position = Vector2( 155.052, -40.363 )
material = null
position = Vector2( -96.3763, 93.3395 )

[node name="Tasks" type="YSort" parent="Interactive"]

[node name="Containers" type="YSort" parent="Interactive/Tasks"]

[node name="Container" type="Area2D" parent="Interactive/Tasks/Containers"]
position = Vector2( 232, 56 )
script = ExtResource( 12 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="Interactive/Tasks/Containers/Container"]
shape = SubResource( 24 )

[node name="Sprite" type="Sprite" parent="Interactive/Tasks/Containers/Container"]
position = Vector2( 0, 3.8147e-06 )
scale = Vector2( 0.625, 0.625 )
texture = ExtResource( 16 )

[node name="Props" type="YSort" parent="."]

[node name="Corpses" type="YSort" parent="Props"]
[connection signal="body_entered" from="Interactive/Tasks/Containers/Container" to="Interactive/Tasks/Containers/Container" method="_on_Container_body_entered"]
[connection signal="body_exited" from="Interactive/Tasks/Containers/Container" to="Interactive/Tasks/Containers/Container" method="_on_Container_body_exited"]
3 changes: 3 additions & 0 deletions src/assets/ui/tasks/container/Textures/Container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions src/assets/ui/tasks/container/Textures/Container.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/Container.png-879c764ee37a9377f78340a313b4b235.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/ui/tasks/container/Textures/Container.png"
dest_files=[ "res://.import/Container.png-879c764ee37a9377f78340a313b4b235.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Loading