-
Notifications
You must be signed in to change notification settings - Fork 28
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
base: main
Are you sure you want to change the base?
Container tasks #293
Changes from 3 commits
8993e56
aed76a8
8d62ec3
04185c2
68548db
8d235b3
43bf38c
71a40f3
02cd2b1
409bc6e
3530845
8d229fc
a8b3f17
8996940
58ea05c
ca16166
6bc7a25
3d35c41
63a890d
7162681
b1ec4d5
422e28d
fc83e06
6d4f183
d3f3743
5233618
b9cfc4d
885e262
6175723
e58b129
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)") | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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) | ||
|
@@ -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") |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be better structured as
|
||
|
||
|
||
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) |
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 |
There was a problem hiding this comment.
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)?